imview-1.1.9c/0000755000076500007650000000000010756343257014007 5ustar talbottalbot00000000000000imview-1.1.9c/aclocal.m40000644000076500007650000002377410364220666015655 0ustar talbottalbot00000000000000dnl useful macros dnl C++ LANGUAGE SUPPORT dnl always a bit of a nightmare... dnl from the autoconf-archive: dnl http://research.cys.de/autoconf-archive dnl now at: dnl http://www.gnu.org/software/ac-archive/ AC_DEFUN([AC_CXX_MEMBER_TEMPLATES], [AC_CACHE_CHECK(whether the compiler supports member templates, ac_cv_cxx_member_templates, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ template class A { public: template A operator=(const A& z) { return A(); } };],[A x; A y; x = y; return 0;], ac_cv_cxx_member_templates=yes, ac_cv_cxx_member_templates=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_member_templates" = yes; then AC_DEFINE(HAVE_MEMBER_TEMPLATES,,[define if the compiler supports member templates]) fi ]) AC_DEFUN([AC_CXX_TEMPLATE_KEYWORD_QUALIFIER], [AC_CACHE_CHECK(whether the compiler supports use of the template keyword as a qualifier, ac_cv_cxx_template_keyword_qualifier, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ class A { public : A() {}; template static T convert() { return T(); } }; ],[double z = A::template convert(); return 0;], ac_cv_cxx_template_keyword_qualifier=yes, ac_cv_cxx_template_keyword_qualifier=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_template_keyword_qualifier" = yes; then AC_DEFINE(HAVE_TEMPLATE_KEYWORD_QUALIFIER,, [define if the compiler supports use of the template keyword as a qualifier]) fi ]) AC_DEFUN([AC_CXX_TEMPLATES_AS_TEMPLATE_ARGUMENTS], [AC_CACHE_CHECK(whether the compiler supports templates as template arguments, ac_cv_cxx_templates_as_template_arguments, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ template class allocator { public : allocator() {}; }; template class T_alloc> class A { public : A() {} private : T_alloc alloc_; }; ],[A x; return 0;], ac_cv_cxx_templates_as_template_arguments=yes, ac_cv_cxx_templates_as_template_arguments=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_templates_as_template_arguments" = yes; then AC_DEFINE(HAVE_TEMPLATES_AS_TEMPLATE_ARGUMENTS,, [define if the compiler supports templates as template arguments]) fi ]) AC_DEFUN([AC_CXX_DEFAULT_TEMPLATE_PARAMETERS], [AC_CACHE_CHECK(whether the compiler supports default template parameters, ac_cv_cxx_default_template_parameters, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ template class A {public: int f() {return 0;}}; ],[A a; return a.f();], ac_cv_cxx_default_template_parameters=yes, ac_cv_cxx_default_template_parameters=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_default_template_parameters" = yes; then AC_DEFINE(HAVE_DEFAULT_TEMPLATE_PARAMETERS,, [define if the compiler supports default template parameters]) fi ]) dnl This is one of my own, testing some weaknesses in egcs compilers dnl AC_DEFUN([AC_CXX_TEMPLATE_CAST_ARRAY], [AC_CACHE_CHECK(whether the compiler accepts array type casts in templates, ac_cv_cxx_template_cast_array, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ typedef unsigned char uchar; template void testfeeble0(void *p, T dummy) { uchar (*q)[256] = (uchar (*)[256]) p;} ],[uchar a[3][256], d; testfeeble0(a,d); return 0;], ac_cv_cxx_template_cast_array=yes, ac_cv_cxx_template_cast_array=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_template_cast_array" = yes; then AC_DEFINE(HAVE_TEMPLATE_CAST_ARRAY,, [define if your compiler accepts array type casts in templates]) fi ]) dnl Testing for the presence of std::char_traits, missing in gcc 2.96 and before dnl AC_DEFUN([AC_CXX_STD_CHAR_TRAITS], [AC_CACHE_CHECK(whether the compiler supports standard char traits, ac_cv_cxx_standard_char_traits, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ #include template > class A {public: charT f() {return 'c';}}; ],[A a; return a.f();], ac_cv_cxx_standard_char_traits=yes, ac_cv_cxx_standard_char_traits=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_standard_char_traits" = yes; then AC_DEFINE(HAVE_STANDARD_CHAR_TRAITS,, [define if the compiler supports standard char classes traits]) fi ]) dnl Testing for the -fpermissive stuff dnl AC_DEFUN([AC_CXX_X11_HEADER_PERMISSIVE], [AC_CACHE_CHECK(whether the compiler needs -fpermissive to compile the X11 headers, ac_cv_cxx_needs_permissive, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ #include ],, ac_cv_cxx_needs_permissive=no, ac_cv_cxx_needs_permissive=yes) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_needs_permissive" = yes ; then if test -n "$GXX" ; then CPPFLAGS="-fpermissive $CPPFLAGS" else echo "*** Compiler is not GCC, cannot fix that problem" fi fi ]) dnl Testing for the presence or absence of strstream dnl AC_DEFUN([AC_CXX_STRSTREAM], [AC_CACHE_CHECK(whether the C++ library knows about string streams, ac_cv_cxx_has_strstream, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ #include ],, ac_cv_cxx_has_strstream=yes,ac_cv_cxx_has_strstream=no) AC_LANG_RESTORE ]) if test "$ac_cv_cxx_has_strstream" = no ; then CXXFLAGS="-I$srcdirfull/stl/sstream $CXXFLAGS" fi ]) dnl check for presence of Xinerama dnl AC_DEFUN([AC_X11_HAS_XINERAMA], [AC_CACHE_CHECK(check for the xinerama extension, ac_x11_has_xinerama, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ #include #include ],[ (void) XineramaIsActive(0); return 0; ], ac_x11_has_xinerama=yes,ac_x11_has_xinerama=no) AC_LANG_RESTORE ]) if test "$ac_x11_has_xinerama" = yes ; then XINERAMA="-lXinerama" AC_DEFINE(HAVE_XINERAMA,, [define if your multiple-screen system supports xinerama]) else XINERAMA="" fi ]) dnl I'm starting to HATE ImageMagick. They change the API for no reasons all the time. dnl AC_DEFUN([AC_MAGICK_REASON], [AC_CACHE_CHECK(whether ImageMagick uses the new exception structure, ac_cv_magick_reason, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ #include #include #include ],[ ExceptionInfo exception; MagickWarning(exception.severity,exception.reason,exception.description); return 0;], ac_cv_magick_reason=yes,ac_cv_magick_reason=no) AC_LANG_RESTORE ]) if test "$ac_cv_magick_reason" = yes ; then AC_DEFINE(MAGICK_USES_REASON,,[define if ImageMagick uses the new exception structure]) fi ]) AC_DEFUN([AC_MAGICK_INIT], [AC_CACHE_CHECK(whether ImageMagick uses InitializeMagick, ac_cv_magick_init, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ #include #include #include ],[ InitializeMagick(NULL); return 0;], ac_cv_magick_init=yes,ac_cv_magick_init=no) AC_LANG_RESTORE ]) if test "$ac_cv_magick_init" = yes ; then AC_DEFINE(MAGICK_USES_INIT,,[define if ImageMagick uses InitializeMagick()]) fi ]) AC_DEFUN([AC_MAGICK_NEEDS_MORE_EXCEPTION], [AC_CACHE_CHECK(whether ImageMagick passes around an extra exception reference all over the place, ac_cv_magick_needs_more_exception, [AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_TRY_COMPILE([ #include #include #include ],[ ExceptionInfo exception; Image *image; IsGrayImage(image, &exception); return 0;], ac_cv_magick_needs_more_exception=yes,ac_cv_magick_needs_more_exception=no) AC_LANG_RESTORE ]) if test "$ac_cv_magick_needs_more_exception" = yes ; then AC_DEFINE(MAGICK_NEEDS_MORE_EXCEPTION,,[define if ImageMagick requires extra reference to exceptions in arguments]) fi ]) AC_DEFUN([AC_ACCEPT_USES_SOCKLEN_T], [AC_CACHE_CHECK(whether accept uses socklen_t, ac_cv_accept_uses_socklen_t_init, [AC_LANG_SAVE AC_LANG_C AC_TRY_COMPILE([ #include #include #include ],[ accept (1, NULL, (socklen_t*)NULL); return 0;], ac_cv_accept_uses_socklen_t_init=yes,acc_cv_accept_uses_socklen_t_init=no) AC_LANG_RESTORE ]) if test "$ac_cv_accept_uses_socklen_t_init" = yes ; then AC_DEFINE(ACCEPT_USES_SOCKLEN_T,,[define if accept*uses socklen_t]) fi ]) # OK, so gcc-3.1 complains about adding -I when is # a system path. Fair enough, but sometimes you need to add this something # and you have no idea that it is a system path unless gcc tells you (this # depends on the way gcc has been installed). # This macro checks for it. AC_DEFUN([GCC_ACCEPTS_INCLUDE_DIR], [AC_CACHE_CHECK(whether gcc bitches when told to look inside INCLUDE_DIR, ac_cv_gcc_complains_about_system_headers, [AC_LANG_SAVE AC_LANG_C CPPSAVE=$CPPFLAGS CPPFLAGS="$CPPFLAGS -I$INCLUDE_DIR -Werror" AC_TRY_COMPILE([ #include ], [ printf("hello world\n");], ac_cv_gcc_complains_about_system_headers=no,ac_cv_gcc_complains_about_system_headers=yes) AC_LANG_RESTORE CPPFLAGS=$CPPSAVE ]) if test "$ac_cv_gcc_complains_about_system_headers" = no ; then CPPFLAGS="$CPPFLAGS -I$INCLUDE_DIR" else CPPFLAGS="$CPPFLAGS -isystem $INCLUDE_DIR" fi ]) # bitchy gcc-3.1 complains about `deprecated header' which is a pain # when you *have* to support older compiler. Shut off the complaint if # necessary AC_DEFUN([GCC_ACCEPTS_DEPRECATED_HEADERS], [AC_CACHE_CHECK(whether gcc bitches when including some deprecated headers, ac_cv_gcc_complains_about_deprecated_headers, [AC_LANG_SAVE AC_LANG_CPLUSPLUS CPPSAVE=$CPPFLAGS CPPFLAGS="$CPPFLAGS -I$INCLUDE_DIR -Werror" AC_TRY_COMPILE([ #include #include ], [ std::cout << "Hello world\n";], ac_cv_gcc_complains_about_deprecated_headers=no,ac_cv_gcc_complains_about_deprecated_headers=yes) AC_LANG_RESTORE CPPFLAGS=$CPPSAVE ]) if test "$ac_cv_gcc_complains_about_deprecated_headers" = yes ; then CXXFLAGS="$CXXFLAGS -Wno-deprecated" fi ]) imview-1.1.9c/annotatePoints.cxx0000644000076500007650000000415710632004146017530 0ustar talbottalbot00000000000000/*------------------------------------------------------------------------ * * The top-level code for point annotation. * * Hugues Talbot 13 Jan 2001 * * Following discussions with PSL. * *-----------------------------------------------------------------------*/ #include "imview.hxx" #include "annotatePoints.hxx" #include "pointfile.hxx" extern pointfile *PtFileMngr; annotatept::annotatept() { dbgprintf("Point annotation dialog created\n"); annotateWindow = 0; // fluid depends on this return; } annotatept::~annotatept() { dbgprintf("Point annotation dialog destroyed\n"); return; } void annotatept::setDefaults() { return; } void annotatept::show() { annotateWindow->show(); } void annotatept::hide() { annotateWindow->hide(); } void annotatept::getPointParams(void) { int font, size, length; string ann; Fl_Color col; str_quadrant q; bool h; int ptsize; if (PtFileMngr->getNearestPointParameters(X_,Y_, ann, col, font, size, length, q, h, ptsize)) { setAnnotation(ann.c_str()); fontChoice->value(font); fontColourChoice->value(col); fontSizeSlider->value(size); distanceValue->value(length); fontQuadrant = q; hide(h); setPointSize(ptsize); } // else do nothing. } // the annotatept callbacks void setdistance_cb(Fl_Roller *r, annotatept *panel) { panel->setDistance((int)(r->value())); // forward value to Value holder } void cancelbutton_cb(Fl_Button *b, annotatept *panel) { panel->hide(); } void okbutton_cb(Fl_Return_Button *b, annotatept *panel) { int xx, yy; panel->getXY(xx,yy); PtFileMngr->annotatePoint(xx, yy); panel->hide(); } void annotateinput_cb(Fl_Input *, annotatept *) { return; } void SE_cb(Fl_Round_Button *, annotatept *panel) { panel->setFontQuadrant(STR_SE); } void NE_cb(Fl_Round_Button *, annotatept *panel) { panel->setFontQuadrant(STR_NE); } void NW_cb(Fl_Round_Button *, annotatept *panel) { panel->setFontQuadrant(STR_NW); } void SW_cb(Fl_Round_Button *, annotatept *panel) { panel->setFontQuadrant(STR_SW); } imview-1.1.9c/annotatePoints.hxx0000644000076500007650000001064307653236453017553 0ustar talbottalbot00000000000000/* * $Id: annotatePoints.hxx,v 4.0 2003/04/28 14:39:39 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Point annotation header file. * * Hugues Talbot 13 Jan 2001 * *-----------------------------------------------------------------------*/ #ifndef ANNOTATEPT_H #define ANNOTATEPT_H #include "imview.hxx" #include "imnmspc.hxx" // namespace def. if required #include #include #include #include #include #include #include #include #include #include #include #include #include #include // the GUI interface class annotatept { public: annotatept(); ~annotatept(); void setDefaults(); const char *getAnnotation(void) {return annotateInput->value();} void setAnnotation(const char *s) { annotateInput->value(s); } int getDistance(void) {return (int)(distanceValue->value());} void setDistance(int v) { distanceValue->value(v);} int getFont(void) {return fontChoice->value();} void setFont(int v) { fontChoice->value(v);} int getFontColour(void) {return fontColourChoice->value();} void setFontColour(int v) {fontColourChoice->value(v);} int getFontSize(void) {return (int)(fontSizeSlider->value());} void setFontSize(int v) {fontSizeSlider->value(v);} void setFontQuadrant(str_quadrant v) {fontQuadrant = v;} str_quadrant getFontQuadrant(void) {return fontQuadrant;} void setXY(int xx, int yy) {X_ = xx; Y_ = yy;} void getXY(int &xx, int &yy) {xx = X_, yy = Y_;} void hide(bool h) { hiddenButton->value((int)(h));} bool isHidden(void) {return (hiddenButton->value() > 0);} int getPointSize(void) {return ((int)pointsizeValueSlider->value());} void setPointSize(int s) {pointsizeValueSlider->value(s);} void getPointParams(void); void show(); void hide(); friend Fl_Window *annotatept_panel(annotatept &anpp); private: int X_, Y_; Fl_Window *annotateWindow; Fl_Input *annotateInput; Fl_Button *CancelButton; Fl_Return_Button *OKButton; Fl_Choice *fontChoice; Fl_Roller *distanceRoller; Fl_Value_Output *distanceValue; Fl_Choice *fontColourChoice; Fl_Slider *fontSizeSlider; Fl_Round_Button *hiddenButton; Fl_Value_Slider *pointsizeValueSlider; str_quadrant fontQuadrant; }; #endif // ANNOTATEPT_H imview-1.1.9c/axisBox.cxx0000644000076500007650000000707610632004146016142 0ustar talbottalbot00000000000000/* * $Id: axisBox.cxx,v 4.3 2007/06/07 13:30:14 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Code for axis drawing box. * * Hugues Talbot 6 Aug 1998 * *-----------------------------------------------------------------------*/ #include #include "axisBox.hxx" void axisBox::draw(void) { draw_box(); draw_label(); fl_color(FL_BLACK); if (w() > h()) { // single horizontal line fl_line(x(), y()+1, x()+w()-1, y()+1); if (minval != maxval) { char p[20]; int stringw, stringh; fl_font(FL_HELVETICA, 10); fl_color(FL_GRAY); // default colour fl_push_clip(x(),y(),w(),h()); // draw a quick erasing box // nb. fl_width() returns a double and assumed to be +ve here!! k_ fl_rectf(x()+w()-(int)(fl_width("-0.1234")+0.5)-1, y()+2, (int)(fl_width("-0.1234")+0.5), h()-2); fl_color(FL_BLACK); sprintf(p, "%.4g", minval); fl_draw(p, x(), y()+h()-1); sprintf(p, "%.4g", maxval); fl_measure(p, stringw, stringh); if (stringw <= w()/2) fl_draw(p, x()+w()-stringw, y()+h()-1); else fl_draw(p, x()+w()/2, y()+h()-1); // uses at most max half of the box. fl_pop_clip(); } } else { // single vertical line fl_line(x()+w()-1, y(), x()+w()-1, y()+h()); if (minval != maxval) { char p[20]; int stringw, stringh; fl_font(FL_HELVETICA, 10); fl_color(FL_GRAY); // default colour fl_push_clip(x(),y(),w(),h()); // draw a quick erasing box fl_rectf(x(), y()+h()-fl_height(), w()-1, fl_height()); fl_color(FL_BLACK); sprintf(p, "%.4g", minval); fl_measure(p, stringw, stringh); if (w()-stringw-5 >= 0) fl_draw(p, x()+w()-stringw-5, y()+h()); else fl_draw(p, x(), y()+h()); fl_color(FL_GRAY); // default colour fl_rectf(x(), y(), w()-1, fl_height()+1); fl_color(FL_BLACK); sprintf(p, "%.4g", maxval); fl_measure(p, stringw, stringh); if (w()-stringw-5 >= 0) fl_draw(p, x()+w()-stringw-5, y()+fl_height()); else fl_draw(p, x(), y()+fl_height()); fl_pop_clip(); } } return; } imview-1.1.9c/axisBox.hxx0000644000076500007650000000440007653236455016156 0ustar talbottalbot00000000000000/* * $Id: axisBox.hxx,v 4.0 2003/04/28 14:39:41 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Simple axis drawing object * * Hugues Talbot 6 Aug 1998 * *-----------------------------------------------------------------------*/ #ifndef AXISBOX_H #define AXISBOX_H #include #include #include #include class axisBox : public Fl_Box { public: axisBox(int x, int y, int w, int h, const char *l=0) : Fl_Box(x, y, w, h, l) { minval = maxval = 0.0; } void setRange(double minrange, double maxrange) { minval = minrange; maxval = maxrange; } void draw(); private: double minval, maxval; }; #endif imview-1.1.9c/bivHist.cxx0000644000076500007650000003123007667144305016142 0ustar talbottalbot00000000000000/* * $Id: bivHist.cxx,v 4.2 2003/06/03 16:11:49 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * This file contains the code for the bivariate histogram, * Both the GUI interface (with bivhist) and the code for the * histogram `canvas' * * Hugues Talbot 26 Apr 1999 * *-----------------------------------------------------------------------*/ #include #include // for sprintf #include #include "imview.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "machine.hxx" #include "bivHist.hxx" #include "nocase.hxx" #include "io/newprefio.hxx" using std::upper_bound; using std::lower_bound; using std::sort; extern imageIO *IOBlackBox; extern imageViewer *mainViewer; extern imprefs *fileprefs; // // Comparison function for points // // returns true if a is less than b bool cmpBHPoints::operator() (const BHPoint &a, const BHPoint &b) const { // order by Y first if (a.Yvalue < b.Yvalue) return true; else if (a.Yvalue > b.Yvalue) return false; // then order by X else if (a.Xvalue < b.Xvalue) return true; else return false; // if b <= a } // // Implementation for bivHistBox class. // bivHistBox::bivHistBox(int x, int y, int w, int h, const char *l) : Fl_Box(x,y,w,h,l) { box(FL_FLAT_BOX); color(FL_WHITE); dataIsInteger = true; xCorrection = yCorrection = 1.0; return; } int bivHistBox::handle(int event) { int retval = 0; double xval, yval; if (!allPoints.empty()) { switch (event) { case FL_ENTER: fl_cursor(FL_CURSOR_CROSS); retval = 1; break; case FL_MOVE: // no button held down retval = handleMouseMoved(xval, yval); // in this case the xval and yval are thrown away break; case FL_PUSH: case FL_DRAG: retval = handleMouseButtonPushed(); break; case FL_RELEASE: //IOBlackBox->applyOverlayToCurrentImage(); IOBlackBox->applyImageParameters(0, 0, 0, true); mainViewer->displayCurrentImage(); // this can be quite slow retval = 1; break; case FL_LEAVE: fl_cursor(FL_CURSOR_DEFAULT); retval = 1; break; } } return retval; } int bivHistBox::handleMouseMoved(double &xval, double &yval) { int Xmouse, Ymouse; char p[100]; int retval = 1; double realw, realh; Xmouse = Fl::event_x() - x(); Ymouse = Fl::event_y() - y(); realw = (double) w() - xCorrection; realh = (double) h() - yCorrection; xval = minXval + ((double)Xmouse * (maxXval - minXval)) / realw; yval = minYval + ((h() - (double)Ymouse) * (maxYval - minYval)) / realh; if (dataIsInteger) { xval = floor(xval); yval = floor(yval); } sprintf(p, "X= %.5g , Y=%.5g", xval, yval); parentPanel->setPosition(p); return retval; } int bivHistBox::handleMouseButtonPushed(void) { double xval, yval, delta, mindelta, distance; int retval = handleMouseMoved(xval, yval); BHPColour currentColour; bhpointIterator l,u,p; BHPoint highPoint, lowPoint; if (parentPanel->selectRegionIsOn()) currentColour = (BHPColour)(parentPanel->getCurrentColour() + 1); else currentColour = BHPBlack; delta = parentPanel->getPenWidth() * (maxYval - minYval)/h() ; mindelta = trivmin(delta, parentPanel->getPenWidth() * (maxXval - minXval)/w() ); highPoint = BHPoint(currentColour, 0, xval, yval+delta); lowPoint = BHPoint(currentColour, 0, xval, yval-delta); // and paint the point... u = std::upper_bound(allPoints.begin(), allPoints.end(), highPoint, cmpBHPoints()); l = std::lower_bound(allPoints.begin(), allPoints.end(), lowPoint, cmpBHPoints()); dbgprintf("Mouse coordinates: (%g, %g)\n", xval, yval); dbgprintf("Lower and upper bounds:\n"); if (u != allPoints.end()) { dbgprintf(" Lower: (%g,%g)\n", (*l).Xvalue, (*l).Yvalue); } if (l != allPoints.end()) { dbgprintf(" Upper: (%g,%g)\n", (*u).Xvalue, (*u).Yvalue); } if ((l == allPoints.end()) && (u == allPoints.end())) { dbgprintf(" No upper or lower bounds !\n"); } parentPanel->makeCurrent(); fl_color((int)currentColour); for (p = l; p != u ; ++p) { distance = sqrt(((*p).Xvalue - xval) * ((*p).Xvalue - xval) + ((*p).Yvalue - yval) * ((*p).Yvalue - yval)); if (distance <= mindelta) { (*p).colour = currentColour; drawPointWithJitter((*p).Xvalue, (*p).Yvalue, currentColour); // this is the `linked window' bit. IOBlackBox->setPixelInOverlay((*p).imgOffset, (int)currentColour); } } return retval; } void bivHistBox::draw(void) { bhpointIterator i; // superclass draw: draw_box(); draw_label(); // clip to scroll area dimensions parentPanel->getScrollClip(xo,yo,wo,ho); fl_clip(xo,yo,wo,ho); workoutCorrection(); for (i = allPoints.begin() ; i != allPoints.end() ; ++i) { // draw with jitter drawPointWithJitter((*i).Xvalue, (*i).Yvalue, (*i).colour); } fl_pop_clip(); return; } // Work out the size of the jitter. Depends // a lot on whether the data is integer or double. void bivHistBox::workoutCorrection(void) { if (dataIsInteger) { xCorrection = ((double)w()/(maxXval - minXval)); yCorrection = ((double)h()/(maxYval - minYval)); } else { xCorrection = 1.0; yCorrection = 1.0; } } // this assumes that the drawing environment is in place: i.e: within draw, or after make_current // In this function, it turns out that INT_MAX is more portable than RAND_MAX. void bivHistBox::drawPointWithJitter(double xval, double yval, BHPColour colour) { int xa, ya; double realwidth,realheight; double jitterX, jitterY; jitterX = (double)random()/INT_MAX * xCorrection; jitterY = (double)random()/INT_MAX * yCorrection; realwidth = (double)w() - xCorrection; realheight = (double)h() - yCorrection ; xa = (int)(x() + realwidth*((xval-minXval)/(maxXval-minXval)) + jitterX); ya = (int)(y() + realheight*(1.0 - (yval-minYval)/(maxYval-minYval)) + jitterY); if ((xa >= xo) && (ya >= yo) && (xa < xo+wo) && (ya < yo+wo)) { fl_color(colour); fl_point(xa, ya); } return; } void bivHistBox::setData(int Xcomp, int Ycomp) { bhpointIterator i; IOBlackBox->subsetForBH(allPoints, Xcomp, Ycomp, minXval, minYval, maxXval, maxYval); dbgprintf("Collected %d points, minX = %g, minY = %g\n" " maxX = %g, maxY = %g\n", allPoints.size(), minXval, minYval, maxXval, maxYval); // sample the data and determine if integer or not dataIsInteger = true; for (i = allPoints.begin(); i < allPoints.end(); i += 101) { if ((floor((*i).Xvalue) != (*i).Xvalue) || (floor((*i).Yvalue) != (*i).Yvalue)) { dataIsInteger = false; break; } } if (dataIsInteger) dbgprintf("Data is integer\n"); else dbgprintf("Data is floating point\n"); // sort the data std::sort(allPoints.begin(), allPoints.end(), cmpBHPoints()); return; } // the bivhist implementation bivhist::bivhist() { dbgprintf("Bivariate histogram dialog created\n"); bivhistWindow=0; // fluid depend on this behaviour histoBox=0; return; } bivhist::~bivhist() { dbgprintf("Bivariate histogram dialog destroyed\n"); return; } void bivhist::show() { bivhistWindow->show(); } void bivhist::hide() { bivhistWindow->hide(); } // The coordinate change in this case is quite difficult // void bivhist::enlargeHisto() { int x, y, w, h, x2, y2, w2, h2; int relx, rely, newx, newy; x = histoBox->x(); y = histoBox->y(); w = histoBox->w(); h = histoBox->h(); x2 = bivhistScroll->x(); y2 = bivhistScroll->y(); w2 = bivhistScroll->w(); h2 = bivhistScroll->h(); // relative coordinates relx = x2 - x; rely = y2 - y; newx = -2*relx-w2/2 + x2; newy = -2*rely-h2/2 + y2; dbgprintf("oldx: %d, relx: %d, newx, %d\n", x, relx, newx); histoBox->resize(newx, newy, w*2, h*2); bivhistScroll->type(Fl_Scroll::BOTH); bivhistScroll->redraw(); } // and this is just as hard void bivhist::shrinkHisto() { int x, y, w, h, x2, y2, w2, h2; int relx, rely, newx, newy; x = histoBox->x(); y = histoBox->y(); w = histoBox->w(); h = histoBox->h(); x2 = bivhistScroll->x(); y2 = bivhistScroll->y(); w2 = bivhistScroll->w(); h2 = bivhistScroll->h(); // relative coordinates relx = x2 - x; rely = y2 - y; newx = relx/2 + w2/4 + x2; newy = rely/2 + h2/4 + y2; histoBox->resize(newx, newy, w/2, h/2); bivhistScroll->type(Fl_Scroll::BOTH); bivhistScroll->redraw(); } void bivhist::fitHisto() { int x, y, w, h; x = bivhistScroll->x(); y = bivhistScroll->y(); w = bivhistScroll->w(); h = bivhistScroll->h(); histoBox->resize(x+BHP_MARGIN/2, y+BHP_MARGIN/2, w+BHP_MARGIN, h+BHP_MARGIN); bivhistScroll->type(0); // get rid of the scrollbars bivhistScroll->redraw(); } // must be called first void bivhist::setDefaults(void) { // we are viewing comp. #1 vs. #2 by default. Xinput->value("0"); Yinput->value("1"); histoBox = 0; // very important return; } // the crux of the matter void bivhist::computeNewBH() { int Xcomp, Ycomp; double minX, minY, maxX, maxY; // get all the elements Xcomp = atoi(Xinput->value()); Ycomp = atoi(Yinput->value()); // delete the previous canvas if (histoBox) { bivhistScroll->remove(histoBox); delete histoBox; // this should destroy all the data associated with histoBox } // create a new bivHistBox with the same dimensions as the current canvas histoBox = new bivHistBox(bivhistScroll->x()+BHP_MARGIN/2, bivhistScroll->y()+BHP_MARGIN/2, bivhistScroll->w()-BHP_MARGIN, bivhistScroll->h()-BHP_MARGIN); histoBox->setParentPanel(this); bivhistScroll->add(histoBox); histoBox->setData(Xcomp, Ycomp); // set the limits histoBox->limits(minX, minY, maxX, maxY); absissaBox->setRange(minX, maxX); ordinateBox->setRange(minY, maxY); // redraw everything bivhistWindow->redraw(); return; } void bivhist::setTransparency(double v) { transparencyValue->value(v); fileprefs->overlayTransparency(v); mainViewer->displayCurrentImage(); // this should take the new transparency into account } ////////// All the bivhist callbacks void computebivhist_cb(Fl_Return_Button*, bivhist *panel) { dbgprintf("Computing a new 2-D histogram\n"); panel->computeNewBH(); } void dismissbutton_cb(Fl_Button*, bivhist *panel) { panel->hide(); } void setpenwidth_cb(Fl_Roller *r, bivhist *panel) { panel->setPenWidth(r->value()); } void zoominbutton_cb(Fl_Button*, bivhist *panel) { panel->enlargeHisto(); } void zoomoutbutton_cb(Fl_Button*, bivhist *panel) { panel->shrinkHisto(); } void resetbutton_cb(Fl_Button*, bivhist *panel) { panel->fitHisto(); } void settransparency_cb(Fl_Roller *r, bivhist *panel) { panel->setTransparency(r->value()); } imview-1.1.9c/bivHist.hxx0000644000076500007650000001270307653236455016156 0ustar talbottalbot00000000000000/* * $Id: bivHist.hxx,v 4.0 2003/04/28 14:39:41 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * the bivariate histogram panel, for multispectra images. * * Hugues Talbot 26 Apr 1999 * *-----------------------------------------------------------------------*/ #ifndef BIVHIST_H #define BIVHIST_H #include // STL vectors. #include "imnmspc.hxx" // namespace def. if required #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "imview.hxx" #include "axisBox.hxx" #define BHP_MARGIN 4 using std::vector; // define an iterator on vectors of BHPoints typedef vector::iterator bhpointIterator; // the `bivariate histogram canvas' class bivHistBox: public Fl_Box { public: bivHistBox(int x, int y, int w, int h, const char *l=0); int handle(int event); // we need this for mouse control int handleMouseMoved(double &, double &); int handleMouseButtonPushed(void); void draw(); // we need to re-implement this. void drawPointWithJitter(double xval, double yval, BHPColour colour); void setData(int xcomponent, int ycomponent); void workoutCorrection(void); void limits(double &minX, double &minY, double &maxX, double &maxY) { minX = minXval; minY = minYval; maxX = maxXval; maxY = maxYval; } void setParentPanel(class bivhist *it) {parentPanel = it;} private: vector allPoints; // we will push_back all the points that come through. class bivhist *parentPanel; double minXval, maxXval; // for the X and Y limits double minYval, maxYval; double xCorrection, yCorrection; bool dataIsInteger; // original dimensions. int xo, yo, wo, ho; }; // the GUI interface class bivhist { public: bivhist(); ~bivhist(); void setDefaults(); void show(); void hide(); void computeNewBH(); void setPosition(char *p) {positionOutput->value(p);} BHPColour getCurrentColour(void) {return (BHPColour)regioncolourChoice->value();} double getPenWidth(void) {return penWidthValue->value();} void setPenWidth(double v) { penWidthValue->value(v);} void setTransparency(double v); void makeCurrent(void) {bivhistWindow->make_current();} bool selectRegionIsOn(void) {return (selectRegionButton->value() != 0);} void enlargeHisto(void); void shrinkHisto(void); void fitHisto(void); void getScrollClip(int &x, int &y, int &w, int &h) { x = bivhistScroll->x(); y = bivhistScroll->y(); h = bivhistScroll->h(); w = bivhistScroll->w(); } friend Fl_Window *bivhist_panel(bivhist &bh); private: bivHistBox *histoBox; // where the drawing will occur // all of these declared in fluid Fl_Window *bivhistWindow; Fl_Scroll *bivhistScroll; Fl_Button *selectRegionButton; Fl_Button *clearRegionButton, *clearAllRegionsButton; Fl_Button *zoominButton, *zoomoutButton, *resetzoomButton; Fl_Button *dismissButton; Fl_Button *printButton, *saveButton; Fl_Return_Button *computeButton; Fl_Input *Xinput, *Yinput; Fl_Output *positionOutput; Fl_Roller *penRadiusRoller, *transparencyRoller; Fl_Value_Output *penWidthValue, *transparencyValue; axisBox *absissaBox, *ordinateBox; Fl_Choice *regioncolourChoice; }; #endif // BIVHIST_H imview-1.1.9c/buildnb0000755000076500007650000000121210720437041015332 0ustar talbottalbot00000000000000#!/bin/sh # increments build number buildno=`egrep '^int buildnb' patchlevel.h | awk '{print $4}'` totalbno=`egrep '^int totalbnb' patchlevel.h | awk '{print $4}'` buildno=`expr ${buildno} + 1` totalbno=`expr ${totalbno} + 1` sed -e '/^const char \*patchlevel/q' patchlevel.h > tmppatch mv tmppatch patchlevel.h echo "int buildnb = $buildno ;" >> patchlevel.h echo "int totalbnb = $totalbno ;" >> patchlevel.h # use the Real user name if available, else the logname if [ "${NAME}" != "" ] ; then echo "char *builder = \"$NAME\" ;" >> patchlevel.h else echo "char *builder = \"$USER\" ;" >> patchlevel.h fi echo "Incrementing build level" imview-1.1.9c/changehdr.sh0000755000076500007650000000065107653236455016276 0ustar talbottalbot00000000000000#! /bin/sh mkdir /tmp/imview mkdir /tmp/imview/io mkdir /tmp/imview/server for file in *.h *.c *.cxx *.hxx io/*.cxx io/*.hxx server/*.cxx server/*.hxx ; do tmpfile=/tmp/imview/$file sed -n -e '/^.*/p' -e '/^ \* \*\//q' $file > /tmp/imview/oldheader nblines=`wc -l /tmp/imview/oldheader | awk '{print $1}'` sed -e "1,$nblines d" $file > $tmpfile cat header.txt $tmpfile > $file done rm -rf /tmp/imview imview-1.1.9c/ChangeLog0000644000076500007650000003552310745372603015564 0ustar talbottalbot00000000000000## ## Imview change log ## Changes to Imview-1.1.9: Hugues Talbot 7 Jun 2007-- * Improved support for OS/X, now the main menu is native (but non-dynamic, an FLTK problem). The non-native menu is present, but hidden. A bundle .app can be created easily, DnD works, Imview can be assigned to read many image formats by default, and more. * '=' shortcut reverts the zoom to 1.0 * Improved the raw reader, now writes a header (.ivh) than imview reads back in when present. * Version 1.1.x for win32 compiles again * cross-compiling again supported (off-again, on-again :-) * Fixed the raw (arbitrary) panel, now byte swapping works (thanks to Teemu Ikonen), and upon re-reading the header, the correct fields are filled. Also the title is green and the message is different if a header was been read effectively. * Fixed correct display of pixel data for FLOAT type (thanks to Teemu Ikonen) * Restarted work for an improved version of imview on Windows (the stable version is long in the tooth) * Added the ITK Meta format input reader. * Fixed many bugs in the PPM reader. Changes to Imview-1-1.8: Hugues Talbot 28 February 2005 -- 06 June 2007 * Improved support fo x86_64 under Linux-FC3. Compiler problem fixed. * Fixed profile preview crash. * Started work on proper 3D viewer with sagittal etc views. * Worked on special PGM version (3D, long and floats) for PINK (Pink Is Not Khoros) * Worked on fixing problems with Magick under MacOS/X, a.k.a Darwin * Some work to create a real executable bundle under OS/X. Not terribly successful * Some work to make DnD work under OS/X. Changes to Imview-1.1.7: Hugues Talbot 25 June 2004 -- 28 February 2005 * Few Bug fixes, improved support on Mac OS/X Changes to Imview-1.1.6: Hugues Talbot 22 June 2004 -- 22 June 2004 * Drawing point mode * Modified the toolbar a bit (now with proper tooltips) * Fixed bug with redrawing of points re-read from a pointfile (they were filled in) * Fixed break immediately following a break in pointfile (no longer allowed) * Fixed add point mode, which required shift-rightclick to make a break. Use shift-R to unzoom. Changes to Imview-1.1.5: Hugues Talbot 01 June 2004 -- 22 June 2004 * Improved PS reader, somewhat inspired by the reader from ImageMagick. * Making imview compile again on Cygwin and Mingw. Currently it compile on mingw32 cross-compiled from Linux but doesn't run (why?) * Changes in configure.in due to feedback from users (missing libraries, better understanding of fltk-config, etc). Changes to Imview-1.1.4: Hugues Talbot 22 December 2003 -- 01 June 2004 * Made imview compile and run fine again on MacOS/X. This requires version 10.3.x at present, I don't have access to any other. The main part was the redesign of the jobbg() function which uses fork(). Now there is a double redirection in there as under Carbon, using the GUI is forbidden after fork(), one has to do an exec(). Changes to Imview-1.1.3: Hugues Talbot 08-November 2003 -- 22 December 2003 * Corrected several misconceptions about nbcomps vs. nbsamples * As a result, the spectrum panel now works again ; as this is important, this is a new bugfix release. * Jan (jan@dminfo.com) changed some interal logic in the configure.in file * Made it compile with CYGWIN again Changes to Imview-1.1.2: Hugues Talbot 15 May 2003 -- 07 November 2003 * Alt-shift-R strong redraws and reverts the zoom factor to 1.0 * Non-alt zoom keys (i.e: < > . and ,) now change the *default* zoom factor. * Fixed a redraw problem in 1.1.1, scrollbar not getting overwritten in window-fit-image display policy mode. Did this without needing yet another redraw. * Removed dependency on old HelpDialog, now using the fltk-1.1.x standard version. * Added fullscreen mode, the image is shown full screen (Xinerama aware) with no menu and a black border and the image is made to fit the screen as well as possible. Not tested with Windows. * Added 2 display modes: image fits to window and image/window decoupled * Fixed bug in handling of profile of images with number of components equal to precisely 1 or 3. * Global min/max for 3D and multispectral images. Cached for 3D (no point for others) * Slider / input value dialog for selecting sample -- 3D, spectrum, frame * Separated spectrum and 3D depth profiles (previously merged). * More tooltips. * Fixed underflow bug in my_Image.cxx introduced by using char* instead of uchar*. * Changed preferences to the FLTK mechanism (simpler and somewhat more powerful). Changes to Imview-1.1.1: Hugues Talbot 28 Apr 2003 -- 15 May 2003 * Ported to FLTK-1.1.x * Using more powerful file chooser (choose multiple files, create directory, preview) * Added a few tooltips (just to test!) to 1-D profile dialog. * Imported all relevant changes from 1.0.1 Changes to Imview-1.1.0: Hugues Talbot 28 Apr 2003 -- 28 Apr 2003 * Branch to work on new version based on FLTK 1.1.x Changes to Imview-1.0.1: Hugues Talbot 28 Apr 2003 -- 13 May 2003 * This is a bug fix release, no new feature * Branch from main trunk for maintenance * Cosmetic changes: spectrum and profile panels * Changes in ASCII documentation (README) * Vast but subtle changes in configure.in, Makefile.in -- Imview compiles again everywhere. * Changes for icc (Intel Compiler) 7.1 on Linux * Make rpm works again * Added target and MANIFEST file * Modified to not make it require a tag (harder with branching) * Added changes to socketstream.cxx to make it compile with gcc-2.95.x, which all lack char traits * Added compilation HOWTO for MSVC++ 6.0, including how to compile the various libraries * Bug fix in gplot2.cxx, no longer crashes if the pipe does not open (as always on Windows) * Added missing stub for overlay * Added .iss file for windows installer * Added config.sub and config.guess -- Why are those suddently necessary ? * Checked for more ISO/C++ non conformance * Added switch to ./configure to specify an fltk compile directory (not necessarily installed). * Many many changes in configure.in to make the build system allegedly more robust. Ha. Changes to Imview-1.0.0: Hugues Talbot 28 Apr 2002 -- 28 Apr 2003 * Branch to continue working with FLTK 1.0.x version. Changes to Imview-0.9.9: Hugues Talbot 18 Apr 2002 -- 28 Apr 2003 * Fixed small problem with NULL image list * Added backspace as a shortcut to go back in the image list * Fixed number width problem in profile box. * Compiled for Tru64 and Solaris, numerous little fixes in the distribution. * Put the HTML online documentation in doc/ * Revamped web site http://www.cmis.csiro.au/Hugues.Talbot/imview * Officially released imview (to the FLTK mailing list and the Bazaar) * Fixed bug in point list handling on windows (when deleting points using the selection tool) * Compiled version for windows again * Fixed bug in authentication of usernames with spaces in them (common on windows) * Fixed bug in reading of Z-IMAGE file formats with DOUBLE data type: there were potential for an infinite loop. * A little more STL-compliance in pointfile.cxx (removed one hand-made loop with 3 algorithms). * Fixed more bugs about username with spaces in them. NOTE: client code needs to be fixed as well. * Added the -fit switch for image display. In this mode (stretch to fit) imview does not allow scrollbars: the image always fits the window. Arbitrary aspect ratios are allowed too. * TCP/IP client code linked in (simple TCP socket wrapper). * Added the ability to link two or more imview windows (zooming on one zooms on the other). * Added support for POSIX IPC. Unfortunately only works well on Tru64 at present. * Fixed numerous issues with dialogs which resize very poorly. Resizing dialogs that allow it should not result in larger buttons, etc. * Added the -fit options to emulate a `stretch to fit' mode to imview. In that mode resizing the main window is unconstrained and the image in it fills the window completely. changing the aspect ratio of an image is therefore possible. This mode is incompatible with normal zoom. * Main menu can be hidden and shown again dynamically. * Imview can be used as a plugin for Mozilla (see Mozilla doc, nothing special, specify `imview' as the window title. * Saving of the raw data has been added. This is very useful in combination with the dialog that allows reading of arbitrary uncompressed image data. Previously once the unknown format image has been loaded nothing could be done with it but view it. You could save it if it was 2D, 8-bit grey-level or RGB data. However if it was 3D or non-8-bit data or multispectral then nothing much could be done. Changes to Imview-0.9.8: Hugues Talbot 1 Jun 2001 -- 17 Apr 2002 * Changed config.h to imcfg.h and made sure we are including the right one on top of that. * Ed found a new bug in window positioning, still partly eluding me, under some circumstances dealing with windows manager preferences and display command through the interpreter. Now the main window gets the right size but still gets shifted to the middle of the screen. * fixed bug with zoom + pan (hopefully), using synchronization option (-sync) * added a bunch of command-line options to hide the menubar, disable the menubar, disable some keyboard shortcut, and prevent users quitting imview. * added a bunch of show/hide commands through the interpreter to show or hide each imview dialog boxes. * added a pan command (much easier than zoom box). * optimized pointfile handling with line drawing. Imview was very slow at drawing lines when the number of point exceeded a few hundreds. * changed the pointfile saving semantic. Now a pointfile loaded into an image will not be modified without the user's interaction (before it was overwritten on image swapping and quitting the program, now a backup is made, with the name .bak). * Annick pointed out a couple of bugs in the profile box. * Empty pointfiles now get saved to empty if done through the menu (never by default). * Fixed bug in profile line redraw * Fixed bug in menubar management (bug occured when an image did not open properly: path to image was freed too early) * Fixed bug in readpnm. Even though an RGB image was read only buffp only had room for one buffer. * Added missing hiding button on the toolbar. * Changed the splash screen to a much nicer image (some people don't like it, eh). * RGB transfer panel (major piece of work). Changes to Imview-0.9.8: Kevin Cheong * Added An extra icon at the end of the toolbar + cb that hides the toobar. Currently I'm reusing one of the other XPMs. We'll need an appropriate pixmap for "hiding". * added Support for auto-loading an image's LUTs, if it exists. * Support for auto-loading an image's pointfile, if it exists. Logic still needs to be sorted out here. * Small updates to a few files, so that it'll compile on MSVC++, however I've not committed the .dsp/.dsw files. Still playing around with them. I don't know why (yet) the pop consoles when imview is executed. Changes to Imview-0.9.7: Hugues Talbot 7 Mar 2001 -- 31 Mar 2001 * Fixed very weird crashes with -server -debug under DEC Unix 4.x * Removed the check for inline in autoconf. This is creating too much trouble! * fixed incorrect saving of greyscale images via the ImageMagick interface. * Fixed the named pipe problem (example in the client directory). * *Maybe* fixed the redirection problem (> /dev/null => port number not saved). * Imview compiles and works fine on Solaris 2.5.1 again. * Added clearing the pointfile from the socket. * Fixed bug in ApplyParameter, which was called sometimes when no images were loaded. * added -no_dblbuf option to turn off double-buffering at zoom = 1.0, which sometimes creates problems. * added access to (some) imview variables from the interpreter. * fixed offset not saved when saving images to formats that support it. Changes to Imview-0.9.6: Hugues Talbot 15 Feb 2001 -- 6 Mar 2001 * Fixed flip + annotation problem. * Overlay over sockets now work. * Fixed saved pointfile to wrong format when annotation present but image still 2D grey-level only. * started working on overlay again. Added transparency. Alpha blending is easy but there is an issue with keeping the original data to access it again (as point information, profiles, etc). For the moment there is a hack in place. * Work on the overlay under way. I'm using a parallel mechanism to the normal I/O. This means writing another helper function for each image type, but is more efficient than simply re-using the existing I/O, which entails a copy of the data structures. For the moment only TIFF & Z-images. Other types to follow soon. * Made the rendering process more consitent. CLUT, gamma and overlay are now compatible with each other to some degree (not perfect yet). * Changed the convertXXX functions to a template, and added a number of features to the conversion. RGB images can have their 3 components separated, fitchar can be done on a sample basis or on all samples, non-char images that can be cast to char don't need to be now. * Added new features to points: they can be hidden and can have varying radii. Also an annotated point appears filled in now (rather than just the outline of a disk). o new bug: redirection of stdout to /dev/null interferes with server, try ./imview -server -portfile toto >/dev/null it display [0] in the title. The server is started correctly though Changes to Imview-0.9.5: * bug fix: the -display xx:xx switch was broken. Changes to Imview-0.9.4: * fixed bug with mass point deletion * improved points rotation (now rotates with the image). Still broken when reading the image back in Changes to Imview-0.9.3: * More comprehensive configure.in tests for C++ compliance. Lots of problems with templates and array arguments! Both DEC cxx and g++ are bad pieces of work there. * Made multi-platform build work. * Point annotation now works * Toolbar o Mode (Zoom, measure, select, add, remove, edit) o Simple transforms (Rotate, flips) Changes to Imview-0.9.2: * Re-organized client help. * Made client code part of distribution. * Added raise, hide and size function for client. * Build to RPM now works. Changes to Imview-0.9.1: * Added licence & (no) warranty menu items * Added install target to makefile Changes to Imview-0.9.0: * This is the first pre-release version. * See doc/imview.tex for a complete log of changes since 0.0.1 * PDF documentation (LaTeXPdf) imview-1.1.9c/check/0000755000076500007650000000000010756342325015057 5ustar talbottalbot00000000000000imview-1.1.9c/check/minimal.exp0000755000076500007650000000716110054565120017222 0ustar talbottalbot00000000000000#!/usr/bin/env expect # # This Expect script was generated by autoexpect on Wed Jan 3 18:29:00 2001 # Expect and autoexpect were both written by Don Libes, NIST. # # Note that autoexpect does not guarantee a working script. It # necessarily has to guess about certain things. Two reasons a script # might fail are: # # 1) timing - A surprising number of programs (rn, ksh, zsh, telnet, # etc.) and devices discard or ignore keystrokes that arrive "too # quickly" after prompts. If you find your new script hanging up at # one spot, try adding a short sleep just before the previous send. # Setting "force_conservative" to 1 (see below) makes Expect do this # automatically - pausing briefly before sending each character. This # pacifies every program I know of. The -c flag makes the script do # this in the first place. The -C flag allows you to define a # character to toggle this mode off and on. set force_conservative 1 ;# set to 1 to force conservative mode even if ;# script wasn't run conservatively originally if {$force_conservative} { set send_slow {1 .02} proc send {ignore arg} { sleep .1 exp_send -s -- $arg } } # # 2) differing output - Some programs produce different output each time # they run. The "date" command is an obvious example. Another is # ftp, if it produces throughput statistics at the end of a file # transfer. If this causes a problem, delete these patterns or replace # them with wildcards. An alternative is to use the -p flag (for # "prompt") which makes Expect only look for the last line of output # (i.e., the prompt). The -P flag allows you to define a character to # toggle this mode off and on. # # Read the man page for more info. # # -Don proc abort {} { puts "Script failed" exit 10 } proc cmdexpect {} { expect { timeout abort "500 Command failed" abort "000 OK\r" } } if { $argc < 2 } { puts "Usage: $argv0 Username Portnumber Imviewpath\n" exit 1 } else { set USER [lindex $argv 0] set IMVIEW [lindex $argv 1] set TOPDIR [lindex $argv 2] } puts "Got: USER = $USER" puts " IMVIEW = $IMVIEW" puts " TOPDIR = $TOPDIR" set timeout 10 #set send_slow {1 .1} puts "Starting $IMVIEW" system $IMVIEW -server -portfile pf.txt -fork sleep .1 if [catch {open pf.txt} fp] return gets $fp buf puts "Port number is: $buf \n" spawn telnet localhost $buf match_max 100000 expect { timeout abort "Escape character" } sleep .1 send -s "user $USER\r" expect { timeout abort "500 Command failed" abort "Welcome" } sleep .1 send -s "?\r" cmdexpect send -s "pf\r" cmdexpect send -s "load $TOPDIR/../imview-doc/images/distanceAngle.tif\r" cmdexpect send -s "hide\r" cmdexpect send -s "raise\r" cmdexpect sleep 1 send -s "move 100 100\r" cmdexpect send -s "move 200 100\r" cmdexpect send -s "move 300 100\r" cmdexpect send -s "move 300 300\r" cmdexpect send -s "load $TOPDIR/../imview-doc/images/helpmenu.tif\r" cmdexpect send -s "cmap regions.lut\r" cmdexpect send -s "close\r" cmdexpect send -s "zoom box 10 10 10 10\r" cmdexpect send -s "zoom default 1.0\r" cmdexpect send -s "zoom box 30 100 40 40\r" cmdexpect send -s "zoom box 70 120 65 50\r" cmdexpect send -s "zoom box 110 200 70 60\r" cmdexpect send -s "zoom box 150 250 80 40\r" cmdexpect send -s "zoom factor 1.0\r" cmdexpect send -s "zoom factor 10.\r" cmdexpect send -s "size 10 10.\r" cmdexpect sleep .1 send -s "size 1000 1000.\r" cmdexpect sleep .1 send -s "size 300 200.\r" cmdexpect sleep .1 send -s "reset\r" cmdexpect send -s "close\r" cmdexpect send -s "kill\r" expect { timeout abort eof } puts "All done" imview-1.1.9c/client/0000755000076500007650000000000010756342325015260 5ustar talbottalbot00000000000000imview-1.1.9c/client/democlient.c0000644000076500007650000001003310632004153017527 0ustar talbottalbot00000000000000/*------------------------------------------------------------------------ * * Demo client for imview * * Hugues Talbot 4 Jan 2001 * *-----------------------------------------------------------------------*/ #include #include #include "liarp.h" #include "liarwrap.h" #include "imclient.h" #define DFLTPORT 7600 const char *imview_cmd = "imview -debug -sync -server -fork"; int conn_id = -1; int upload_image(IMAGE *I, const char *lbl, const char *host, const ipctype method) { const char *user; int res; if (I != NULL) { user = getenv("USER"); if (user != NULL) { imview_set_transfer_method(method); res = imviewlogin(user, host, DFLTPORT, &conn_id); if (res != 0) imexception("Login failed\n"); res = imviewputimage(I, lbl, conn_id); if (res != 0) imexception("Put failed\n"); } } return res; } int load_image(const char *path, const char *host) { const char *user; int res; char cmd[200]; user = getenv("USER"); if (user != NULL) { res = imviewlogin(user, host, DFLTPORT, &conn_id); if (res != 0) imexception("Login failed\n"); sprintf(cmd, "load %s\r\n", path); if (imviewsendcommand(cmd, conn_id) == NULL) { imexception("Load failed\n"); res = 1; } } return res; } int zoombox_image(void) { /* test of zooming to a box */ char cmd[200]; int i, retval = 0; for (i = 0 ; i < 100 ; ++i) { sprintf(cmd, "zoom box %d %d 100 100\r\n", i, i); if (imviewsendcommand(cmd, conn_id) == NULL) { fprintf(stderr, "zoom box command failed\n"); retval = 1; break; } fprintf(stderr, "."); } fprintf(stderr, "\n"); return retval; } int pan_image(void) { /* test of image paning */ char cmd[200]; int i, retval = 0; sprintf(cmd, "zoom factor 3\r\n"); if (imviewsendcommand(cmd, conn_id) == NULL) { fprintf(stderr, "Zoom factor command failed\n"); retval = 1; } else { for (i = 0 ; i < 10 ; ++i) { sprintf(cmd, "pan %d %d\r\n", i, i); if (imviewsendcommand(cmd, conn_id) == NULL) { fprintf(stderr, "Pan command failed\n"); retval = 1; break; } fprintf(stderr, "."); } } fprintf(stderr, "\n"); return retval; } void usage(const char *prog) { fprintf(stderr, "Usage: %s [-d] [-ts/-tp/-tt] [-p]\n" " Displays image in running imview server\n" "Options:\n" " -d : debugging output\n" "-t{s,p,t} : transfer using SYSV IPC, POSIX IPC or TCP/IP respectively\n" " -p : just give the path to the image to imview\n", prog); exit(2); } int main(int argc, char *argv[]) { IMAGE *A; ipctype transfer = SHM_NONE; int res, narg, usepath = 0; const char *imenv; /* simple argument processing */ narg = 1; while (narg < argc) { if (argv[narg][0] == '-') { if (argv[narg][1] == 't') { if(argv[narg][2] == 's') transfer = SHM_SYSV; /* SYSV */ else if (argv[narg][2] == 'p') transfer = SHM_POSIX; /* POSIX */ else transfer = SHM_NONE; } else if (argv[narg][1] == 'd') { LIAREnableDebug(); } else if (argv[narg][1] == 'p') usepath = 1; } ++narg; } if (argc < 2) { usage(argv[0]); } imenv = getenv("IMVIEWCOMMAND"); if (imenv == NULL) imenv = imview_cmd; system(imenv); if (!usepath) { A = imloadtiff(argv[argc -1]); res = upload_image(A, argv[argc-1], "localhost", transfer); } else { res = load_image(argv[argc-1], "localhost"); } if (res == 0) res = pan_image(); if (conn_id != -1) imviewlogout(conn_id); return res; } imview-1.1.9c/client/imclient.c0000644000076500007650000017302407653236534017245 0ustar talbottalbot00000000000000/*------------------------------------------------------------------------ * * This file contains functions to connect to the Imview server. * * Hugues Talbot 9 Mar 2000 * *-----------------------------------------------------------------------*/ #include #include #include #include #include #include #include #include "liarp.h" #include "liarwrap.h" #include "imclient.h" #define ANSWER_MAX_SIZE 1024 #define BIN_MAX_SIZE 8192 #define HNDSHK_SIZE 300 #define DEFAULTPORT 7600 #define DEFAULTHOST "localhost" #define EOC "\r\n" #define HANDSHAKE "Imview >" #define TIMEOUT_SEC 10 #define TIMEOUT_USEC 150000 #define HEADER_ID_SIZE 8 #define MAX_CONN_ARRAY 100 #define NET_PUT "put" /* using socket for data transfer */ #define SYSV_SHM_PUT "putm" /* using System V shared memory for data transfer */ #define PX_SHM_PUT "putp" /* using Posix shared memory for data transfer */ static int force_socket = 0; static const char *putcmd[] = { NET_PUT, PX_SHM_PUT, SYSV_SHM_PUT }; #define OVERLAY_MARKER "" /* we all know it's a terrible macro */ #ifndef mymin # define mymin(X,Y) ((X) > (Y)) ? (Y) : (X) #endif #define SHM_SIZE 400000 /* valid for all shared memory models */ static ipctype use_shm_default = SHM_POSIX; /* by default we use POSIX IPC if we can */ /* data needed to describe a connection */ typedef struct connection_ { int opened; int fd; /* not important: the file descriptor */ char *hostname; ipctype use_shm; /* bool: yes or no */ char *sync_filename; /* shared memory uploads */ short port; } connection; #ifdef WIN32 int winsock_started=0; #endif #ifndef WIN32 # include # include # include # define im_close close # define USRID "USER" #else # include struct timezone { int tz_minuteswest; /* Minutes west of GMT. */ int tz_dsttime; /* Nonzero if DST is ever in effect. */ }; /* For now redefine gettimeofday() as timerclear() ie. sets timeval to zero (see and/or Else, define a new function for WIN32 :) extern int gettimeofday(); */ # define gettimeofday(tvp, tzp) (timerclear(tvp)) # define im_close closesocket # define USRID "USERNAME" #endif /* system V IPC */ #ifdef HAVE_SYSV_IPC #include #include #include #if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED) /* union semun is defined by including */ #else /* according to X/OPEN we have to define it ourselves */ union semun { int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */ unsigned short int *array; /* array for GETALL, SETALL */ struct seminfo *__buf; /* buffer for IPC_INFO */ }; #endif /* GNU lib, etc */ #define SEM_ACS 0 #define SEM_RD 1 #define SEM_WR 2 /* convenient globals */ int semid, shmid; static char *sysv_shm_data; #endif /* HAVE_SYSV_IPC */ /* POSIX IPC */ #ifdef HAVE_POSIX_IPC #include #include #include #include #include #define STR_ACCESS "_ACCESS" #define STR_READ "_READ" #define STR_WRITE "_WRITE" #define STR_SHM "_SHM" #define SEM_ACCESS 0 #define SEM_READ 1 #define SEM_WRITE 2 #define IPC_FILE_MODE 0600 // rw for creator only, must be Octal! /* convenience static global */ static char *posix_shm_data; static sem_t *imview_px_sem[3]; static char ipc_base_path[ANSWER_MAX_SIZE]; char *px_templ_name; static const char *px_resource_name[] = { STR_ACCESS, STR_READ, STR_WRITE }; #endif /* HAVE_POSIX_IPC */ static connection conn_array[MAX_CONN_ARRAY]; static int conn_inited = 0; /* static functions prototypes */ static int imview_open_connection(const char *hostname, short initial_port); static void imview_close_connection(int s); static int imview_watchForInput(int fd); static int imview_watchForInput_withDelay(int fd, int sec, int usec); static char *imview_command(int fd, const char *command); static char *imview_general_command(int fd, const char *command, int expect_answer, int waitsec, int waitusec); static char *reliable_imview_general_command(int fd, /* socket descriptor */ const char *command, /* the string command */ int expect_answer, int waitsec, int waitusec); static char *unlimited_imview_general_command(int fd, /* socket descriptor */ const char *command, /* the string command */ int expect_answer, int waitsec, int waitusec); static char *imview_command_noanswer(int fd, const char *command); #ifdef WIN32 static void init_winsock (void) { WSADATA wd; WSAStartup (MAKEWORD (1,1), &wd); winsock_started = 1; } #endif /* finds the first available port to which an connection is possible from a given port. It opens the connection and returns the file descriptor. Returns -1 if it fails. */ static int imview_open_connection(const char *hostname, short initial_port) { short port; int s, i, len, retval; struct hostent *hp; struct sockaddr_in name; #ifdef WIN32 if (!winsock_started) init_winsock(); #endif if ((hp = gethostbyname(hostname)) == NULL) { imexception("imview_open_connection: unknown host %s\n", hostname); return -1; } retval = -1; for (i = 0, port = initial_port ; i < 100 ; i += 2, port += 2) { if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { imexception("imview_open_connection: cannot create socket %s\n", strerror(errno)); return -1; } /* we need to reset the whole `name' structure each time we try to open a port. Just changing the port # is not sufficient */ memset(&name, 0, sizeof(struct sockaddr_in)); name.sin_family = AF_INET; memcpy(&name.sin_addr, hp->h_addr_list[0], hp->h_length); len = sizeof(struct sockaddr_in); name.sin_port = htons(port); if (connect(s, (struct sockaddr *) &name, len) == 0) { retval = s; LIARdebug("Connected to port %d:", port); break; /* success ! */ } else { LIARdebug("Cannot connect to port %d: %s", port, strerror(errno)); im_close(s); } } if (retval < 0) imexception("imview_open_connection: cannot connect to any port from %d\n", initial_port); return retval; } /* this creates a binary connection to a given port. There is no port discovery */ static int imview_open_binconn(const char *hostname, short given_port) { int s, len, retval; struct hostent *hp; struct sockaddr_in name; if ((hp = gethostbyname(hostname)) == NULL) { imexception("imview_open_binconn: unknown host %s\n", hostname); return -1; } if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { imexception("imview_open_binconn: cannot create socket %s\n", strerror(errno)); return -1; } memset(&name, 0, sizeof(struct sockaddr_in)); name.sin_family = AF_INET; memcpy(&name.sin_addr, hp->h_addr_list[0], hp->h_length); len = sizeof(struct sockaddr_in); retval = -1; name.sin_port = htons(given_port); if (connect(s, (struct sockaddr *) &name, len) == 0) { retval = s; } if (retval < 0) imexception("imview_open_binconn: cannot connect to binary port %d, %s\n", given_port, strerror(errno)); return retval; } static void imview_close_connection(int s) { int res; /* wait until everything in the pipe has been received */ /* be nice and polite: send a QUIT request */ imview_command_noanswer(s,"quit" EOC); /* then brutally close the socket! */ res= im_close(s); if (res < 0) imexception("imview_close_connection: cannot close connection, %s.\n", strerror(errno)); return; } static void imview_close_binconn(int s) { int res; /* brutally close the socket! */ res= im_close(s); if (res < 0) imexception("imview_close_binconn: cannot close connection, %s.\n", strerror(errno)); return; } /* flushes the input channel. A timeout WILL be called. */ static void imview_flush_input(int fd) { fd_set rfds; struct timeval tv; int retval, craprec; char crap[ANSWER_MAX_SIZE]; LIARdebug("Flushing the input"); /* Watch the given fd to see when it has input. */ FD_ZERO(&rfds); FD_SET(fd, &rfds); /* Wait 10s at the most. */ tv.tv_sec = TIMEOUT_SEC; tv.tv_usec = TIMEOUT_USEC; LIARdebug("Flushing: Waiting at most %d sec and %d usec", tv.tv_sec, tv.tv_usec); craprec = 0; while ((retval = select(FD_SETSIZE, &rfds, NULL, NULL, &tv)) > 0) { craprec += recv(fd, crap, ANSWER_MAX_SIZE, 0); tv.tv_sec = 0; /* we are expecting the second select to fail */ tv.tv_usec = TIMEOUT_USEC; /* reset to 10ms */ LIARdebug("Flushing: Waiting at most %d sec and %d usec", tv.tv_sec, tv.tv_usec); } LIARdebug("received %d crappy bytes we didn't want...", craprec); return; } /* to be used only when we KNOW we've had an answer and we want to get it */ static int imview_get_delayed_response(int fd, char *resp) { return(recv(fd, resp, ANSWER_MAX_SIZE, 0)); /* this will get one TCP packet back */ } static int imview_watchForInput(int fd) { return imview_watchForInput_withDelay(fd, 0, TIMEOUT_USEC); /* default wait is only 10ms */ } static int imview_watchForInput_withDelay(int fd, int sec, int usec) { fd_set rfds; struct timeval tv; int retval; /* Watch the given fd to see when it has input. */ FD_ZERO(&rfds); FD_SET(fd, &rfds); /* Wait up to some time */ LIARdebug("Waiting at most for %d sec and %d usec", sec, usec); tv.tv_sec = sec; tv.tv_usec = usec; retval = select(FD_SETSIZE, &rfds, NULL, NULL, &tv); if (retval == -1) imexception("imview_watchForInput: select returned error: %s\n", strerror(errno)); /* if retval = 0, nothing to read */ if (retval == 0) LIARdebug("imview_watchForInput: Timeout expired, there was nothing to read"); return retval; } /* command for which no answer is expected (typically: quit) */ static char *imview_command_noanswer(int fd, const char *command) { /* expect no answer, wait only 10 ms */ return imview_general_command(fd, command, 0, 0, TIMEOUT_USEC); /* can retun NULL, test for it! */ } /* normal commands (answer is returned) */ static char *imview_command(int fd, const char *command) { return imview_general_command(fd, command, 1, 0, TIMEOUT_USEC); } static char *imview_general_command(int fd, /* socket descriptor */ const char *command, /* the string command */ int expect_answer, int waitsec, int waitusec) { int res, len, tmp_rec; static char answer_buf[ANSWER_MAX_SIZE + 1]; char *answer; len = strlen(command); answer = NULL; if (len > 0) { /* send the bloody command in one go */ res = send(fd, command, len, 0); memset(answer_buf, 0, ANSWER_MAX_SIZE+1); if ((res == len) && expect_answer) { /* receive the freaking result in one go as well */ tmp_rec = recv(fd, answer_buf, ANSWER_MAX_SIZE, 0); if (tmp_rec < 0) { imexception("Receive failed: %s\n", strerror(errno)); return NULL; } else if (tmp_rec == 0) LIARdebug("Nothing received: socket was closed or missing EOC"); answer = answer_buf; } else { if (res < 0) { imexception("Send failed: Command wasn't sent properly, %s\n", strerror(errno)); return NULL; } else if (res < len) { imexception("Send failed: Command only partially sent\n"); return NULL; } } } else { imexception("Send failed: NULL command\n"); return NULL; } return answer_buf; } /* look for `end of command' */ #define BACKLINES 3 /* go back only 3 lines at most */ #define CMD_OK 1 #define CMD_FAILED 2 #define CMD_UNKNOWN 3 static int imview_EOC(char *message) { int i, j, reason; char *p[BACKLINES]; /* we look backwards through the lines */ for (i = 0 ; i < BACKLINES ; i++) { p[i] = strrchr(message, '\n'); reason = 0; if (p[i] != NULL) { if (((strncmp(p[i]+1, "000 OK", 6) == 0) && ((reason = CMD_OK) > 0)) /* I do mean = here, not == */ || ((strncmp(p[i]+1, "500 Command failed", 18) == 0) && ((reason = CMD_FAILED) > 0)) || ((strncmp(p[i]+1, "501 Unknown command", 19) == 0) && ((reason = CMD_UNKNOWN) > 0))) { LIARdebug("End of command detected %d lines from the end\n", i); /* make the command stop just before this message */ *(p[i]+1) = '\0'; /* we keep the last \n */ return reason; /* end of command, unknown */ } else { *(p[i]) = '\0'; /* remove the \n, shorten the string */ } } else { /* Maybe the whole command is the return */ if (((strncmp(message, "000 OK", 6) == 0) && ((reason = CMD_OK) > 0)) /* I do mean = here, not == */ || ((strncmp(message, "500 Command failed", 18) == 0) && ((reason = CMD_FAILED) > 0)) || ((strncmp(message, "501 Unknown command", 19) == 0) && ((reason = CMD_UNKNOWN) > 0))) { LIARdebug("End of command detected\n", i); /* message[0] = '\0'; no need to keep the returned command */ /* make the command stop just before this message */ return reason; /* end of command, unknown, etc */ } break; /* the end */ } } for (j = 0 ; j < i ; j++) *(p[j]) = '\n'; /* put back what we removed, we don't want to disturb the result */ return 0; /* not found */ } /* expects an unlimited answer */ /* the answer will be put in a static buffer that grows as needed. Subsequent calls to this function erase the previous content, obviously. */ static char *unlimited_imview_general_command(int fd, /* socket descriptor */ const char *command, /* the string command */ int expect_answer, int waitsec, int waitusec) { int res, len, tmp_rec, rec_so_far, has_more, eoc; static char tmp_buf[ANSWER_MAX_SIZE+1]; static char *answer_buf = NULL; static int answer_len; char *answer; if (!answer_buf) { answer_buf = (char *)malloc(ANSWER_MAX_SIZE +1); answer_len = ANSWER_MAX_SIZE +1; } len = strlen(command); answer = NULL; if (len > 0) { /* send the bloody command in one go */ res = send(fd, command, len, 0); memset(answer_buf, 0, answer_len); has_more = 0; if ((res == len) && expect_answer) { /* keep calling recv until we meet an EOF */ rec_so_far = 0; do { memset(tmp_buf, 0, ANSWER_MAX_SIZE+1); tmp_rec = recv(fd, tmp_buf, ANSWER_MAX_SIZE, 0); if (tmp_rec < 0) imexception("Receive failed: %s\n", strerror(errno)); else if (tmp_rec == 0) LIARdebug("Nothing received: socket was closed or missing EOC"); else { LIARdebug("Received %d bytes", tmp_rec); if ((rec_so_far + tmp_rec) > answer_len) { answer_buf = realloc(answer_buf, 2*answer_len); memset(answer_buf + answer_len, 0, answer_len); answer_len *= 2; } memcpy(answer_buf+rec_so_far, tmp_buf, tmp_rec); rec_so_far += tmp_rec; answer = answer_buf; /*watch for the marker of the `end-of-command' * a line starting with 3 digits followed by a message. */ if ((eoc=imview_EOC(answer_buf)) > 0) { if (eoc == CMD_FAILED) { imexception("The command that was sent failed, imview returned:\n%s", answer_buf); } else if (eoc == CMD_UNKNOWN) { imexception("The command that was sent is unknown to imview\n"); } else { LIARdebug("The command ran OK"); } /* in any case */ break; } /* wait for next packet to arrive, if any */ has_more = imview_watchForInput_withDelay(fd, 10, waitusec); } } while ((tmp_rec > 0) && (has_more > 0)); } else { if (res < 0) imexception("Send failed: Command wasn't sent properly, %s\n", strerror(errno)); else if (res < len) imexception("Send failed: Command only partially sent\n"); } } else { imexception("Send failed: NULL command\n"); } return answer; } static char *reliable_imview_general_command(int fd, /* socket descriptor */ const char *command, /* the string command */ int expect_answer, int waitsec, int waitusec) { /** Send an arbitrary command to imview and return its result RETURN VALUE: char * DESCRIPTION: Sends an arbitrary command to imview on a reputed hostname+port. returns the answer. The answer is in a static buffer so doesn't need to be freed, but only one command can be sent at a time. The port that will be opened may not be the one specified, but ports are tried from the one given. HISTORY: TESTS: REFERENCES: KEYWORDS: **/ int res, len, received, tmp_rec; static char answer_buf[BIN_MAX_SIZE], tmp_buf[ANSWER_MAX_SIZE+1]; char *answer; answer = NULL; /* pessimistic scenario */ /* send the commmand */ len = strlen(command); if (len > 0) { res = send(fd, command, len, 0); if (res < 0) { imexception("imview_command: send failed, %s\n", strerror(errno)); } else if (expect_answer) { /* wait for reply! */ tmp_rec = received = 0; /* clear receive buffer */ memset(tmp_buf, 0, ANSWER_MAX_SIZE); memset(answer_buf, 0, BIN_MAX_SIZE); while ((imview_watchForInput_withDelay(fd, waitsec, waitusec) != 0) && (tmp_rec >= 0)) { tmp_rec = recv(fd, tmp_buf, ANSWER_MAX_SIZE, 0); if (tmp_rec > 0) { if (strncmp(tmp_buf, HANDSHAKE, strlen(HANDSHAKE)) == 0) { LIARdebug("Handshake received"); break; } received += tmp_rec; strcat(answer_buf, tmp_buf); memset(tmp_buf, 0, tmp_rec+1); /* +1 for the \0 */ } } if (tmp_rec < 0) { imexception("imview_command: received failed\n"); } LIARdebug("Received: %d bytes", received); answer = answer_buf; } else { /* no answer expected */ received = 0; /* still watch for input, this allows the command to go through */ imview_watchForInput(fd); /* and then just return after timeout */ } } else { imexception("imview_command: NULL command\n"); } return answer; } static wsize_t imview_send_data(int bfd, /* socket descriptor */ char *data, /* the raw data */ wsize_t len, /* its length */ int eot) /* end of transmission */ { /** Send arbitrary binary data to imview RETURN VALUE: int DESCRIPTION: Sends an arbitrary buffer through a socket connection. The data is divided up in smallish chunks and sent packet by packet as a byte stream. HISTORY: TESTS: REFERENCES: KEYWORDS: **/ wsize_t res, sent, thislen; /* slct_res, */ static char sbuf[BIN_MAX_SIZE]; static char rbuf[HNDSHK_SIZE]; /* big enough for hanshake */ /* fd_set rfds; */ /* struct timeval tv; */ res = 0; sent = 0; while (sent < len) { thislen = mymin(len-sent, BIN_MAX_SIZE); memcpy(sbuf, data+sent, thislen); res = send(bfd, sbuf, thislen, 0); if (res != thislen) { imexception("imview_send_data: send failed, only %d bytes were sent, wanted to send %d\n" "reason: %s\n", sent, len, strerror(errno)); break; } sent += res; /* wait for handshake */ memset(rbuf, 0, HNDSHK_SIZE); /* tv.tv_sec = TIMEOUT_SEC; ** tv.tv_usec = TIMEOUT_USEC; ** FD_ZERO(&rfds); ** FD_SET(bfd, &rfds); ** slct_res = select(FD_SETSIZE, &rfds, NULL, NULL, &tv); ** if (slct_res == 0) ** imexception("Timeout waiting for binary handshake\n"); **else { */ res = recv(bfd, rbuf, HNDSHK_SIZE, 0); /* if (strncmp(rbuf, "OK\n", 3) != 0) ** imexception("Send handshake failed, received: (%s)\n", rbuf); ** } */ if (res == 0) break; /* connection closed */ } if (eot && (len > HEADER_ID_SIZE)) while (res != 0) { /* wait for `end of transmission: read of 0' */ res = recv(bfd, rbuf, HNDSHK_SIZE, 0); } return sent; } void imview_set_transfer_method(const ipctype method) { /* this just sets the default, no guarantee that this will be the method actually used -- depends if it's available for a start... -- */ use_shm_default = method; } void imview_force_socket(void) { /* use sockets even if shared memory is available */ force_socket = 1; } #ifdef HAVE_SYSV_IPC int imview_sysv_ipc_setup(char *sync_filename) { key_t key; struct sembuf sb = {0, -1, 0}; /* set to allocate resource */ LIARdebug("Connecting to the ipc facilities setup by imview"); if ((key = ftok(sync_filename, 'A')) == -1) { imexception("imview_ipc_setup, ftok sem: %s\n", strerror(errno)); return(1); } /* grab the semaphore set created by imview: */ if ((semid = semget(key, 3, 0)) == -1) { imexception("imview_ipc_setup, semget: %s\n", strerror(errno)); return(1); } LIARdebug("We are now connected"); /* now try to access the shared memory buffer */ sb.sem_num = SEM_ACS; sb.sem_op = -1; /* down */ if (semop(semid, &sb, 1) == -1) { imexception("imview_ipc_setup, semop_access: %s\n", strerror(errno)); return(1); } LIARdebug("Access to shared memory granted, connecting to it"); if ((key = ftok(sync_filename, 'B')) == -1) { imexception("imview_ipc_setup, ftok shm: %s\n", strerror(errno)); return(2); } LIARdebug("Reference filename: %s, key: %p", sync_filename, key); if ((shmid = shmget(key, SHM_SIZE, 0)) == -1) { imexception("imview_ipc_setup, shmget: %s\n", strerror(errno)); return(2); } /* attach to the segment to get a pointer to it: */ sysv_shm_data = shmat(shmid, (void *)0, 0); if (sysv_shm_data == (char *)(-1)) { imexception("imview_ipc_setup, shmat: %s\n", strerror(errno)); return(2); } LIARdebug("OK, shared memory is ready to be used"); return 0; } /* send data via shm */ int imview_sysv_shm_sendata(char *in_data, /* the raw data */ wsize_t len) /* amount of data to be sent */ { int total, this_one; int tbs; struct sembuf sb = {0, -1, 0}; /* set to allocate resource */ total = 0; tbs = len; do { /* attempt to write (should block if not OK) */ sb.sem_num = SEM_WR; sb.sem_op = -1; if (semop(semid, &sb, 1) == -1) { imexception("imview_shm_sendata, semop_W: %s\n", strerror(errno)); return(-1); } this_one = mymin((SHM_SIZE-sizeof(int)), tbs); tbs -= this_one; memcpy(sysv_shm_data, &this_one, sizeof(int)); memcpy(sysv_shm_data+sizeof(int), in_data+total, this_one); /* OK, now imview can read this data */ sb.sem_num = SEM_RD; sb.sem_op = 1; /* up */ if (semop(semid, &sb, 1) == -1) { imexception("imview_shm_sendata, semop_R: %s\n", strerror(errno)); return(-1); } total += this_one; } while (tbs > 0); return total; } int imview_sysv_ipc_wind_down(void) { struct sembuf sb = {0, -1, 0}; /* set to allocate resource */ /* releases the access to the shared memory buffer */ sb.sem_num = SEM_ACS; sb.sem_op = 1; /* up */ if (semop(semid, &sb, 1) == -1) { imexception("imview_ipc_wind_down, semop_access: %s\n", strerror(errno)); return(1); } /* detach from the memory segment */ if (shmdt(sysv_shm_data) == -1) { imexception("imview_ipc_wind_down, shmdet: %s\n", strerror(errno)); return(1); } return 0; } #else /* stubs */ int imview_sysv_ipc_setup(const char *sync_filename) { imexception("imview_sysv_ipc_setup should not have been called, this is just a stub.\n"); return 1; } int imview_sysv_shm_sendata(char *in_data, /* the raw data */ wsize_t len) /* amount of data to be sent */ { imexception("imview_sysv_shm_sendata should not have been called, this is just a stub.\n"); return -1; } int imview_sysv_ipc_wind_down(void) { imexception("imview_sysv_ipc_wind_down should not have been called, this is just a stub.\n"); return 1; } #endif /* HAVE_SYSV_IPC */ #ifdef HAVE_POSIX_IPC static char *imview_px_ipc_name(const char *name) { char *dir, *dst; const char *slash; if ( (dst = (char *)malloc(ANSWER_MAX_SIZE * sizeof(char))) == NULL) return(NULL); /* can override default directory with environment variable */ if ( (dir = getenv("PX_IPC_NAME")) == NULL) { #ifdef POSIX_IPC_PREFIX dir = POSIX_IPC_PREFIX; /* from "config.h" */ #else dir = "/tmp/"; /* default */ #endif } /* dir must end in a slash */ slash = (dir[strlen(dir) - 1] == '/') ? "" : "/"; snprintf(dst, ANSWER_MAX_SIZE, "%s%s%s", dir, slash, name); return(dst); /* caller can free() this pointer */ } int imview_px_ipc_setup(const char *sync_filename) { int l, shmfd, i; char *tmprid; char tmppathbuf[ANSWER_MAX_SIZE]; /* template name is platform-dependent */ tmprid = strstr(sync_filename + 1, "/") + 1; /* get rid of '/tmp/' */ px_templ_name = imview_px_ipc_name(tmprid); /* will need to be freed */ /* then connect to all the semaphores */ l = strlen(px_templ_name); for (i = 0 ; i < 3 ; ++i) { strcpy(tmppathbuf, px_templ_name); strncat(tmppathbuf, px_resource_name[i], ANSWER_MAX_SIZE-l); imview_px_sem[i] = sem_open(tmppathbuf, 0, IPC_FILE_MODE, 0); /* semaphore is NOT created, value is ignored */ if ( imview_px_sem[i] == SEM_FAILED) { imexception("imview_px_ipc_setup, sem_open(%s) failed: %s\n", tmppathbuf, strerror(errno)); return(1); } } LIARdebug("We are now connected"); /* now try to access the shared memory buffer */ if (sem_wait(imview_px_sem[SEM_ACCESS]) != 0) { imexception("imview_px_ipc_setup, sem_wait failed on ACCESS: %s\n", strerror(errno)); return(1); } LIARdebug("Access to shared memory granted, connecting to it"); /* construct path to shared memory */ strcpy(tmppathbuf, px_templ_name); strncat(tmppathbuf, STR_SHM, ANSWER_MAX_SIZE-l); /* file descriptor */ shmfd = shm_open(tmppathbuf, O_RDWR, IPC_FILE_MODE); /* should have been created by server */ if (shmfd < 0) { imexception("imview_px_ipc_setup, shm_open(%s) failed: %s\n", tmppathbuf, strerror(errno)); return(2); } /* get pointer */ if ((posix_shm_data = mmap(NULL, SHM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0)) == MAP_FAILED) { imexception("imview_px_ipc_setup, mmap failed: %s\n", strerror(errno)); return(3); } /* the shm file can be closed now */ close(shmfd); LIARdebug("OK, shared memory is ready to be used"); return 0; } /* send data via shm */ int imview_px_shm_sendata(char *in_data, /* the raw data */ wsize_t len) /* amount of data to be sent */ { int total, this_one; int tbs; total = 0; tbs = len; LIARdebug("Sending data over shared memory"); do { /* attempt to write (should block if not OK) */ if (sem_wait(imview_px_sem[SEM_WRITE]) != 0) { imexception("imview_px_shm_sendata, sem_wait failed on WRITE: %s\n", strerror(errno)); return(1); } this_one = mymin((SHM_SIZE-sizeof(int)), tbs); tbs -= this_one; memcpy(posix_shm_data, &this_one, sizeof(int)); memcpy(posix_shm_data+sizeof(int), in_data+total, this_one); /* OK, now imview can read this data */ if (sem_post(imview_px_sem[SEM_READ]) != 0) { imexception("imview_ipc_shm_sendata, sem_post failed on READ: %s\n", strerror(errno)); return(1); } total += this_one; } while (tbs > 0); LIARdebug("Finished sending %d bytes", total); return total; } int imview_px_ipc_wind_down(void) { int i, l; char tmppathbuf[ANSWER_MAX_SIZE]; /* detach from all semaphores */ l = strlen(px_templ_name); for (i = 0 ; i < 3 ; ++i) { if (sem_close(imview_px_sem[i]) != 0) imexception("Ooops: sem_close[%s] failed\n", px_resource_name[i]); /* nothing else we can do really */ strcpy(tmppathbuf, px_templ_name); strncat(tmppathbuf, px_resource_name[i], ANSWER_MAX_SIZE-l); if (sem_unlink(tmppathbuf) != 0) imexception("Ooops: sem_unlink[%s] failed\n", tmppathbuf); /* same here */ } /* detach from the memory segment */ if (posix_shm_data != NULL) munmap(posix_shm_data, SHM_SIZE); strcpy(tmppathbuf, px_templ_name); strncat(tmppathbuf, STR_SHM, ANSWER_MAX_SIZE-l); if (shm_unlink(tmppathbuf) != 0) { imexception("Ooops: shm_unlink[%s] failed\n", tmppathbuf); /* same here */ } free(px_templ_name); px_templ_name = NULL; return 0; } #else /* stubs */ int imview_px_ipc_setup(const char *sync_filename) { imexception("imview_px_ipc_setup should not have been called, this is just a stub.\n"); return 1; } int imview_px_shm_sendata(char *in_data, /* the raw data */ wsize_t len) /* amount of data to be sent */ { imexception("imview_px_shm_sendata should not have been called, this is just a stub.\n"); return -1; } int imview_px_ipc_wind_down(void) { imexception("imview_px_ipc_wind_down should not have been called, this is just a stub.\n"); return 1; } #endif void imview_init_conn_array(void) { if (!conn_inited) { memset(conn_array, 0, sizeof(connection) * MAX_CONN_ARRAY); conn_inited = 1; } return; } int imview_fill_conn_array(int fd, const char *hostname, /* can be NULL */ ipctype use_shm, const char *sync_filename, /* can be NULL */ short port) { int i; for (i = 0 ; i < MAX_CONN_ARRAY ; i++) { if (!conn_array[i].opened) break; } if (i >= MAX_CONN_ARRAY) return -1; /* no structure left! */ conn_array[i].opened = 1; conn_array[i].fd = fd; if (hostname != NULL) conn_array[i].hostname = strdup(hostname); else conn_array[i].hostname = NULL; conn_array[i].use_shm = use_shm; if (sync_filename != NULL) conn_array[i].sync_filename = strdup(sync_filename); else conn_array[i].sync_filename = NULL; conn_array[i].port = port; return i; } void imview_release_conn_array(int i) { if (i >= 0) { if (conn_array[i].hostname != NULL) free(conn_array[i].hostname); if (conn_array[i].sync_filename != NULL) free(conn_array[i].sync_filename); conn_array[i].opened = 0; } return; } int imviewlogin(const char *user, /* user name (default NULL: current user) */ const char *hn, /* hostname (default localhost if NULL) */ int port, /* connection port (suitable default if 0) */ int *conn_id) /* return a index in the conn_array */ { /** log to an imview server RETURN VALUE: int O if success Positive value if login is not achieved DESCRIPTION: This function sets up a TCP connection between the caller and a running imview image display server. Set up and login require a hostname, a port number and a user name. Sensible default are used if these arguments are all 0 or NULL. The returned value is an error code, but the conn_id argument is essential for sending further commands to the server and for eventually logging out. HISTORY: Written by Hugues Talbot 5 Apr 2000 TESTS: Lots and many. REFERENCES: KEYWORDS: **/ char username[40], *u, *hostname; char login_command[50],login_result[50], sync_filename[50]; char FnName[512]; char *login_answer; /* result of the login command */ int nbscanned; int fd; ipctype use_shm; sprintf(FnName,"imview_login(%s,%s,%d)", user, hn, port); if ((hn == 0) || (hn[0] == '\0')) hostname = DEFAULTHOST; else hostname = (char *)hn; if (!force_socket && (strcmp(hostname, "localhost") == 0)) { use_shm = use_shm_default; } else { use_shm = SHM_NONE; } /* radical solution for now if sysv IPC are not available */ #if !defined(HAVE_SYSV_IPC) && !defined(HAVE_POSIX_IPC) use_shm = SHM_NONE; #endif /* get the user name */ username[0] = '\0'; /* empty user field */ if ((user == NULL) || (user[0] == '\0')) { if ((u = getenv(USRID)) != NULL) { strcpy(username, u); } } else { strcpy(username, user); } if (username[0] == '\0') { imexception("%s: no user name specified and no USER environment variable\n"); return 5; } LIARdebug("Step 1: open socket"); if (port == 0) { port = DEFAULTPORT; } fd = imview_open_connection(hostname, port); if (fd < 0) { imexception("%s: cannot open connection, %s\n", FnName, strerror(errno)); return 6; } sprintf(login_command, "user %s", username); strcat(login_command, EOC); /* send the login command */ login_answer = imview_command(fd, login_command); if (login_answer == NULL) { imexception("%s: login failed, NULL response\n", FnName); imview_close_connection(fd); return 7; } /* analyse the result */ LIARdebug("Login command result: %s", login_answer); nbscanned = sscanf(login_answer, "Welcome, %s %s", login_result, sync_filename); if ((nbscanned != 2) || (strcmp(login_result, username) != 0)) { imexception("%s: login failed, incorrect user name or unexpected response from server\n", FnName); imview_close_connection(fd); return 8; } if (strncmp(sync_filename, "no_shm", 6) == 0) { /* NO shared memory! */ use_shm = SHM_NONE; } /* if we are here, we can fill a new connection structure */ imview_init_conn_array(); /* safe to call all the time */ *conn_id = imview_fill_conn_array(fd, hostname, use_shm, sync_filename, port); return 0; } /* CAUTION: this function will only work for command that return something */ /* on the other hand, the something can be as long as desired, assuming the connection is fast enough (otherwise lengthen the TIMEOUT parameters, keeping in mind that you will wait at least as long at the end) The response comes in a static buffer. It will be overwritten next time this function is called! Hugues Talbot 14 Jul 2000 */ char *imviewsendcommand(const char *cmd, int conn_id) { return unlimited_imview_general_command(conn_array[conn_id].fd, cmd, 1, 0, TIMEOUT_USEC); } int imviewputoverlay(IMAGE *I, /* the overlay we want to apply on the current image */ const char *name, /* name of the overlay */ int conn_id) /* current connection */ { char newName[ANSWER_MAX_SIZE]; strcpy(newName, OVERLAY_MARKER); strcat(newName, name); /* relay the call */ return imviewputimage(I, newName, conn_id); } int imviewputimage(IMAGE *I, /* the image we want to display */ const char *name, /* imview descriptor (name by which the file is known) */ int conn_id) /* ID of the connection */ { /** Sends an image to an imview server after a communication has been established. RETURN VALUE: int Error code = 0 if everything went all right. DESCRIPTION: This functions takes an arbitrary image and uploads it for display to a running imview server. It is assumed that a communication has been established using the imview_login() function, within the same process, and that therefore the connection ID is known. See the implementation of imviewput for an example of using this function. NOTE: At the moment only single and multispectral images can be uploaded. Arbitrary multi component images (with different components having different size, pixel type, etc) are not uploaded in their entirety: only the first component will be uploaded in this fashion. This is due to an incompatibility with the internal Imview format. HISTORY: Written by Hugues Talbot 5 Apr 2000 TESTS: REFERENCES: KEYWORDS: SEE ALSO: imview_login imviewput **/ int res; /* result of the call of this function */ int c, nbc, nx, ny, nz, ox, oy, oz; const char *imgt, *pixt; /* named version of these parameters */ int nb_da; /* nb of bytes received at the delayed answer */ short binport; /* the binary data port */ unsigned magic_number; /* necessary for socket binary data send */ char magic[HEADER_ID_SIZE]; int bfd; char FnName[100]; /* for debugging message */ char final_name[ANSWER_MAX_SIZE]; char subcommand[ANSWER_MAX_SIZE], *cmdres; char put_command[8*ANSWER_MAX_SIZE]; char delayed_answer[ANSWER_MAX_SIZE]; void *buff; /* arbitrary component data buffer */ wsize_t buflen, rec, tbs = 0; pixtype imp; struct timeval start_prog, start_put, start_upload, end_upload, end_prog; struct timezone dummy; double time0, time1, time2, time3, time4; double dt0, dt1, dt2, dt3, dt4, dt5; res = 0; gettimeofday(&start_prog, &dummy); sprintf(FnName,"imviewput(%p,%s,%d)", I, name, conn_id); if (!I || !name) { imexception("%s: requires an image and a name\n", FnName); return 1; } LIARdebug("Basic checks on the image"); /* Make sure we are saving a valid image */ if (imgetimgtype(I) == IM_BADIMAGE) { imexception("%s: bad image\n", FnName); return 2; } /* get the image basic information */ nbc = imgetnumcomp(I); nx = imgetnx(I, 0); ny = imgetny(I, 0); nz = imgetnz(I, 0); ox = imgetfirstx(I, 0); oy = imgetfirsty(I, 0); oz = imgetfirstz(I, 0); imp = imgetpixtype(I, 0); imgt = imgetimgtypestr(I); pixt = imgetpixtypestr(I,0); /* some people don't set IM_MULTI correctly */ if (imgetimgtype(I) == IM_MULTI) { if (nbc > 1) { /* check whether the image is a true multicomponent image */ for (c = 1 ; c < nbc ; c ++) { if ( (imgetnx(I,c) != nx) || (imgetny(I,c) != ny) || (imgetnz(I,c) != nz) || (imgetfirstx(I,c) != ox) || (imgetfirsty(I,c) != oy) || (imgetfirstz(I,c) != oz) || (imgetpixtype(I, c) != imp)) { if (c > 2) { imexception( "%s: warning, cannot cope with true multi-component images yet.\n" " Only the first %d components will be sent\n", FnName, c+1); nbc = c+1; break; } else { imexception( "%s: warning, cannot cope with true multi-component images yet.\n" " Only the first component will be sent\n", FnName); nbc = 1; break; } } } if (c >= nbc) imexception("%s: warning, IM_MULTI should be reserved for true multi-component images\n", FnName); } else imexception("%s: warning, IM_MULTI should be reserved for images with more than one component\n", FnName); } /* 4D images not yet supported either */ if (imgetnt(I,0) != 1) { imexception("%s: imview can't cope with 4D images yet\n", FnName); return 4; } LIARdebug("Sending Put command"); final_name[0] = '"'; strncpy(final_name+1, name, ANSWER_MAX_SIZE-100); strcat(final_name, " \""); /* to identify the data coming from the client */ sprintf(put_command, "%s %s %d ", putcmd[conn_array[conn_id].use_shm], final_name, 1); /* for the time being we only support SPECTRUM-type image (all nx, etc the same) */ sprintf(subcommand,"%d %d %d %d %d %d %s %s %d ", nx, ny, nz, ox, oy, oz, imgt, pixt, nbc); strcat(put_command, subcommand); strcat(put_command, EOC); /* end of command */ LIARdebug("Command: %s\n", put_command); /* send the actual command */ LIARdebug("Shared memory type: %s", putcmd[conn_array[conn_id].use_shm] ); if (conn_array[conn_id].use_shm == SHM_SYSV) { /* using Shared Memory */ gettimeofday(&start_put, &dummy); if ((imview_command_noanswer(conn_array[conn_id].fd, put_command) != NULL) && (imview_sysv_ipc_setup(conn_array[conn_id].sync_filename) == 0)) { gettimeofday(&start_upload, &dummy); for (c = 0 ; c < nbc ; c++) { buff = imgetbuff(I, c); buflen = imgetnx(I,c) * imgetny(I,c) * imgetnz(I,c) * imgetnt(I,c); tbs = buflen * imgetpixsize(I,c); rec = imview_sysv_shm_sendata(buff, tbs); if (rec != tbs ) { imexception("Incomplete transfer, sent: %d, wanted to send: %d\n", rec, tbs); res = 7; break; } } gettimeofday(&end_upload, &dummy); /* release access to shared memory */ imview_sysv_ipc_wind_down(); nb_da=imview_get_delayed_response(conn_array[conn_id].fd, delayed_answer); /* I don't know that this is necessary */ if (nb_da < 0) imexception("Transfer probably failed\n"); else LIARdebug("Transfer response: %s", delayed_answer); } else { imexception("SYSV IPC setup failed, closing connection\n"); imview_release_conn_array(conn_id); res = 9; } } else if (conn_array[conn_id].use_shm == SHM_POSIX) { /* using POSIX IPC */ char *ppath_answer = NULL; gettimeofday(&start_put, &dummy); /* find the path to the resources */ ppath_answer = imview_command(conn_array[conn_id].fd, "ppath" EOC); sscanf(ppath_answer,"%s ", ipc_base_path); LIARdebug("ipc_base_path = (%s)", ipc_base_path); if ((imview_command_noanswer(conn_array[conn_id].fd, put_command) != NULL) && (imview_px_ipc_setup(ipc_base_path) == 0)) { gettimeofday(&start_upload, &dummy); for (c = 0 ; c < nbc ; c++) { buff = imgetbuff(I, c); buflen = imgetnx(I,c) * imgetny(I,c) * imgetnz(I,c) * imgetnt(I,c); tbs = buflen * imgetpixsize(I,c); rec = imview_px_shm_sendata(buff, tbs); if (rec != tbs ) { imexception("Incomplete transfer, sent: %d, wanted to send: %d\n", rec, tbs); res = 7; break; } } gettimeofday(&end_upload, &dummy); /* release access to shared memory */ imview_px_ipc_wind_down(); nb_da=imview_get_delayed_response(conn_array[conn_id].fd, delayed_answer); /* I don't know that this is necessary */ if (nb_da < 0) imexception("Transfer probably failed\n"); else LIARdebug("Transfer response: %s", delayed_answer); } else { imexception("POSIX IPC setup failed, closing connection\n"); imview_release_conn_array(conn_id); res = 9; } } else { /* upload via the TCP/IP connection */ gettimeofday(&start_put, &dummy); cmdres = imview_command(conn_array[conn_id].fd, put_command); if (cmdres == NULL) { imexception("imview_put: sent command didn't work\n"); /* imview_close_connection(conn_array[conn_id].fd); */ imview_release_conn_array(conn_id); return 8; } LIARdebug("Got result: %s", cmdres); /* check the result. It should contain a port number and a magic number */ sscanf(cmdres, "%hd %u", &binport, &magic_number); /* match a shord and an unsigned */ memset(magic, 0, HEADER_ID_SIZE); memcpy(magic, &magic_number, sizeof(unsigned int)); /* the rest of the header is padded with 0s */ if (binport > 0 && magic > 0) { /* step 3: everything is peachy, send the binary data now */ LIARdebug("OK, sending binary data now"); /* 3a: open binary port connection (same host) */ if ((bfd = imview_open_binconn(conn_array[conn_id].hostname, binport)) > 0) { gettimeofday(&start_upload, &dummy); /* 3b: send back the magic number */ if (imview_send_data(bfd, (char *)(&magic), HEADER_ID_SIZE, 0) == HEADER_ID_SIZE) { /* 3c: send each buffer in turn */ for (c = 0 ; c < nbc ; c++) { LIARdebug("Sending buffer #%d", c); buff = imgetbuff(I, c); buflen = imgetnx(I,c) * imgetny(I,c) * imgetnz(I,c) * imgetnt(I,c); tbs = buflen * imgetpixsize(I,c); rec = imview_send_data(bfd, (char *)buff, tbs, (c == (nbc-1))); /* check for end of transmission */ if (rec != tbs ) { imexception("Incomplete transfer, sent: %d, wanted to send: %d\n", rec, tbs); res = 7; break; } } gettimeofday(&end_upload, &dummy); /* close the binary connection */ LIARdebug("Closing binary connection"); imview_close_binconn(bfd); } } } } gettimeofday(&end_prog,&dummy); time0 = start_prog.tv_sec + start_prog.tv_usec/1e6; time1 = start_put.tv_sec + start_put.tv_usec/1e6; dt0 = time1 - time0; time2 = start_upload.tv_sec + start_upload.tv_usec/1e6; dt1 = time2 - time1; time3 = end_upload.tv_sec + end_upload.tv_usec/1e6; dt2 = time3 - time2; time4 = end_prog.tv_sec + end_prog.tv_usec/1e6; dt3 = time4-time3; dt4 = time3-time1; dt5 = time4-time0; LIARdebug("\n" "Timings: start to put : %6.4f sec\n" " put to beginning of upload : %6.4f sec\n" " begining of upload to end : %6.4f sec\n" " close conn to exit : %6.4f sec\n" "------------------------------------- \n" " put to close conn : %6.4f sec\n" " start to exit : %6.4f sec\n", dt0, dt1, dt2, dt3, dt4, dt5); if ((dt1>0) && (dt2> 0) && (dt4 > 0) && (dt5 > 0)) LIARdebug("\n" "Throughput: upload only : %10.3f kB/s\n" " steady state : %10.3f kB/s\n" " whole process : %10.3f kB/s\n", (tbs*nbc)/(dt2*1024), (tbs*nbc)/(dt4*1024), (tbs*nbc)/(dt5*1024)); return res; } void imviewlogout(int conn_id) /* ID of the connection */ { /** terminates a connection to an existing imview server RETURN VALUE: void DESCRIPTION: This function logs the user out of an existing imview connection. It is essential to do this in order not to run out of connections. HISTORY: Written by Hugues Talbot 5 Apr 2000 TESTS: REFERENCES: KEYWORDS: **/ /* close the connection */ imview_close_connection(conn_array[conn_id].fd); imview_release_conn_array(conn_id); return; } int imviewput(IMAGE *I, /* input image */ const char *name, /* identifier */ const char *user, /* optional user name (NULL default: current user) */ const char *hostname, /* hostname (default localhost if NULL) */ short port) /* connection port (suitable default if 0) */ { /** Puts an image to the imview server for display RETURN VALUE: 0 if success. Error code > 0 if not. DESCRIPTION: This function puts an arbitrary image to imview. It uses a TCP/IP protocol to connect and upload to an existing imview server. NOTE: The upload will be known to imview through its name. If two uploads are made with the same name, the later one to complete will overwrite the earlier one. Uploads with different names are retained (of course they can be deleted manually by the imview user). HISTORY: Written by Hugues Talbot 9 Mar 2000 TESTS: REFERENCES: KEYWORDS: display, socket, tcp/ip. **/ int cmdres; /* what various command return */ int conn_id; /* connection ID */ char FnName[512]; /* Function name (used all the time) */ sprintf(FnName,"imviewput(%s,%s,%d)", name, hostname, port); /* Step 1: establish connextion and log in */ cmdres = imviewlogin(user, hostname, port, &conn_id); if (cmdres != 0) { imexception("%s: login failed\n", FnName); return 1; } /* Step 2: put command */ cmdres = imviewputimage(I, name, conn_id); if (cmdres != 0) imexception("%s: put command failed\n", FnName); /* don't return, we need to close the connection */ /* Step 3: close connection */ LIARdebug("Closing command connection"); imviewlogout(conn_id); return 0; } int imviewput2(IMAGE *I, /* input image */ const char *name, /* identifier */ const char *user, /* optional user name (NULL default: current user) */ const char *hostname, /* hostname (default localhost if NULL) */ short port) /* connection port (suitable default if 0) */ { /** Puts an image to the imview server for display RETURN VALUE: 0 if success. Error code > 0 if not. DESCRIPTION: This function puts an arbitrary image to imview. It uses a TCP/IP protocol to connect and upload to an existing imview server. NOTE: The upload will be known to imview through its name. If two uploads are made with the same name, the later one to complete will overwrite the earlier one. Uploads with different names are retained (of course they can be deleted manually by the imview user). HISTORY: Written by Hugues Talbot 9 Mar 2000 TESTS: REFERENCES: KEYWORDS: display, socket, tcp/ip. **/ void *buff; wsize_t buflen, rec, tbs = 0; int c, fd, bfd, res; char FnName[100]; short binport; unsigned magic_number; char magic[HEADER_ID_SIZE]; int nbc; char final_name[ANSWER_MAX_SIZE]; char put_command[8*ANSWER_MAX_SIZE]; char subcommand[ANSWER_MAX_SIZE], *cmdres; char username[40], *u; char login_command[50], login_result[50], sync_filename[50]; char delayed_answer[ANSWER_MAX_SIZE]; int nbscanned; ipctype use_shm; int nb_da; int nx, ny, nz, ox, oy, oz; pixtype imp; const char *imgt, *pixt; struct timeval start_prog, start_opensocket, start_login; struct timeval start_put, start_upload, end_upload, before_close, end_prog; struct timezone dummy; double time0, time1, time2, time3, time4, time5, time6, time7; double dt0, dt1, dt2, dt3, dt4, dt5, dt6, dt7, dt8; gettimeofday(&start_prog, &dummy); sprintf(FnName,"imviewput2(%s,%s,%d)", name, hostname, port); res = 0; /* all peachy */ if (!I || !name) { imexception("%s: requires an image and a name\n", FnName); return 1; } /* NOTES: ** The server decides on the integer identifier ** names decide on the removal policy */ /* Make sure we are saving a valid image */ if (imgetimgtype(I) == IM_BADIMAGE) { imexception("%s: bad image\n", FnName); return 2; } nbc = imgetnumcomp(I); /* some people don't set IM_MULTI correctly */ if (imgetimgtype(I) == IM_MULTI) { if (nbc > 1) { /* check whether the image is a true multicomponent image */ nx = imgetnx(I, 0); ny = imgetny(I, 0); nz = imgetnz(I, 0); ox = imgetfirstx(I, 0); oy = imgetfirsty(I, 0); oz = imgetfirstz(I, 0); imp = imgetpixtype(I, 0); for (c = 1 ; c < nbc ; c ++) { if ( (imgetnx(I,c) != nx) || (imgetny(I,c) != ny) || (imgetnz(I,c) != nz) || (imgetfirstx(I,c) != ox) || (imgetfirsty(I,c) != oy) || (imgetfirstz(I,c) != oz) || (imgetpixtype(I, c) != imp)) { if (c > 2) { imexception( "%s: warning, cannot cope with true multi-component images yet.\n" " Only the first %d components will be sent\n", c+1); nbc = c+1; break; } else { imexception( "%s: warning, cannot cope with true multi-component images yet.\n" " Only the first component will be sent\n"); nbc = 1; break; } } } if (c>=nbc) imexception("%s: warning, IM_MULTI should be reserved for true multi-component images\n"); } else imexception("%s: warning, IM_MULTI should be reserved for images with more than one component\n"); } /* 4D images not yet supported either */ if (imgetnt(I,0) != 1) { imexception("%s: imview can't cope with 4D images yet\n", FnName); return 4; } /* get the user name */ username[0] = '\0'; /* empty user field */ if ((user == NULL) || (user[0] == '\0')) { if ((u = getenv(USRID)) != NULL) { strcpy(username, u); } } else { strcpy(username, user); } if (username[0] == '\0') { imexception("%s: no user name specified and no USER environment variable\n"); return 5; } gettimeofday(&start_opensocket, &dummy); LIARdebug("Step 1: open socket"); /* step 1: open a socket to the imview command server */ if (port == 0) { port = DEFAULTPORT; } if ((hostname == 0) || (hostname[0] == '\0')) hostname = DEFAULTHOST; if (!force_socket && (strcmp(hostname, "localhost") == 0)) { use_shm = use_shm_default; } else { use_shm = SHM_NONE; } /* radical solution for now */ #if !defined(HAVE_SYSV_IPC) && !defined(HAVE_POSIX_IPC) use_shm = SHM_NONE; #endif fd = imview_open_connection(hostname, port); if (fd < 0) { imexception("%s: cannot open connection, %s\n", FnName, strerror(errno)); return 6; } gettimeofday(&start_login, &dummy); LIARdebug("Step 2: log in"); /* step 2: log in */ sprintf(login_command, "user %s", username); strcat(login_command, EOC); /* flush the input from any previous answer. They would confuse the issue */ /* imview_flush_input(fd); */ cmdres = imview_command(fd, login_command); if (cmdres == NULL) { imexception("%s: login command didn't work\n", FnName); imview_close_connection(fd); return 7; } LIARdebug("Login command result: %s", cmdres); nbscanned = sscanf(cmdres, "Welcome, %s %s", login_result, sync_filename); if ((nbscanned != 2) || (strcmp(login_result, username) != 0)) { imexception("%s: login failed\n", FnName); imview_close_connection(fd); return 8; } /* step 2: send a PUT command */ gettimeofday(&start_put, &dummy); LIARdebug("Sending Put command"); final_name[0] = '"'; strncpy(final_name+1, name, ANSWER_MAX_SIZE-100); strcat(final_name, " \""); /* to identify the data coming from the client */ sprintf(put_command, "%s %s %d ", putcmd[use_shm], final_name, 1); /* for the time being we only support SPECTRUM-type image (all nx, etc the same) */ c = 0; nx = imgetnx(I,c); ny = imgetny(I,c); nz = imgetnz(I,c); ox = imgetfirstx(I,c); oy = imgetfirsty(I,c); oz = imgetfirstz(I,c); imgt = imgetimgtypestr(I); pixt = imgetpixtypestr(I,c); sprintf(subcommand,"%d %d %d %d %d %d %s %s %d ", nx, ny, nz, ox, oy, oz, imgt, pixt, nbc); strcat(put_command, subcommand); strcat(put_command, EOC); /* end of command */ /* flush the input from any previous answer. They would confuse the issue */ /* imview_flush_input(fd); no need I think*/ /* send the actual command */ if (use_shm == SHM_SYSV) { imview_command_noanswer(fd, put_command); if (imview_sysv_ipc_setup(sync_filename) == 0) { gettimeofday(&start_upload, &dummy); for (c = 0 ; c < nbc ; c++) { buff = imgetbuff(I, c); buflen = imgetnx(I,c) * imgetny(I,c) * imgetnz(I,c) * imgetnt(I,c); tbs = buflen * imgetpixsize(I,c); rec = imview_sysv_shm_sendata(buff, tbs); if (rec != tbs ) { imexception("Incomplete transfer, sent: %d, wanted to send: %d\n", rec, tbs); res = 7; break; } } gettimeofday(&end_upload, &dummy); /* release access to shared memory */ imview_sysv_ipc_wind_down(); nb_da=imview_get_delayed_response(fd, delayed_answer); /* I don't know that this is necessary */ if (nb_da < 0) imexception("Transfer probably failed\n"); else LIARdebug("Transfer response: %s", delayed_answer); } else { imexception("SYSV IPC setup failed, closing connection\n"); } } else if (use_shm == SHM_POSIX) { char *ppath_answer = imview_command(fd, "ppath" EOC); /* find the path to the resources */ sscanf(ppath_answer, "%s ", ipc_base_path); LIARdebug("ipc_base_path = (%s)", ipc_base_path); imview_command_noanswer(fd, put_command); if (imview_px_ipc_setup(ipc_base_path) == 0) { gettimeofday(&start_upload, &dummy); for (c = 0 ; c < nbc ; c++) { buff = imgetbuff(I, c); buflen = imgetnx(I,c) * imgetny(I,c) * imgetnz(I,c) * imgetnt(I,c); tbs = buflen * imgetpixsize(I,c); rec = imview_px_shm_sendata(buff, tbs); if (rec != tbs ) { imexception("Incomplete transfer, sent: %d, wanted to send: %d\n", rec, tbs); res = 7; break; } } gettimeofday(&end_upload, &dummy); /* release access to shared memory */ imview_px_ipc_wind_down(); nb_da=imview_get_delayed_response(fd, delayed_answer); /* I don't know that this is necessary */ if (nb_da < 0) imexception("Transfer probably failed\n"); else LIARdebug("Transfer response: %s", delayed_answer); } else { imexception("POSIX IPC setup failed, closing connection\n"); } } else { cmdres = imview_command(fd, put_command); if (cmdres == NULL) { imexception("%s: sent command didn't work\n", FnName); imview_close_connection(fd); return 8; } LIARdebug("Got result: %s", cmdres); /* check the result. It should contain a port number and a magic number */ sscanf(cmdres, "%hd %u", &binport, &magic_number); /* match a shord and an unsigned */ memset(magic, 0, HEADER_ID_SIZE); memcpy(magic, &magic_number, sizeof(unsigned int)); /* the rest of the header is padded with 0s */ if (binport > 0 && magic > 0) { /* step 3: everything is peachy, send the binary data now */ LIARdebug("OK, sending binary data now"); /* 3a: open binary port connection (same host) */ if ((bfd = imview_open_binconn(hostname, binport)) > 0) { /* 3b: send back the magic number */ gettimeofday(&start_upload, &dummy); if (imview_send_data(bfd, (char *)(&magic), HEADER_ID_SIZE, 0) == HEADER_ID_SIZE) { /* 3c: send each buffer in turn */ for (c = 0 ; c < nbc ; c++) { LIARdebug("Sending buffer #%d", c); buff = imgetbuff(I, c); buflen = imgetnx(I,c) * imgetny(I,c) * imgetnz(I,c) * imgetnt(I,c); tbs = buflen * imgetpixsize(I,c); rec = imview_send_data(bfd, (char *)buff, tbs, (c == (nbc-1))); /* check for end of transmission */ if (rec != tbs ) { imexception("Incomplete transfer, sent: %d, wanted to send: %d\n", rec, tbs); res = 7; break; } } gettimeofday(&end_upload, &dummy); /* close the binary connection */ LIARdebug("Closing binary connection"); imview_close_binconn(bfd); } } } } gettimeofday(&before_close,&dummy); /* close connection gracefully */ LIARdebug("Closing command connection"); imview_close_connection(fd); gettimeofday(&end_prog,&dummy); /* compute timings */ time0 = start_prog.tv_sec + start_prog.tv_usec/1e6; time1 = start_opensocket.tv_sec + start_opensocket.tv_usec/1e6; dt0 = time1 - time0; time2 = start_login.tv_sec + start_login.tv_usec/1e6; dt1 = time2 - time1; time3 = start_put.tv_sec + start_put.tv_usec/1e6; dt2 = time3 - time2; time4 = start_upload.tv_sec + start_upload.tv_usec/1e6; dt3 = time4 - time3; time5 = end_upload.tv_sec + end_upload.tv_usec/1e6; dt4 = time5 - time4; time6 = before_close.tv_sec + before_close.tv_usec/1e6; dt5 = time6-time5; time7 = end_prog.tv_sec + end_prog.tv_usec/1e6; dt6 = time7-time6; dt7 = time6-time3; dt8 = time7-time0; LIARdebug("\n" "Timings: start to opening of socket : %6.4f sec\n" " opening of socket to login : %6.4f sec\n" " login to put : %6.4f sec\n" " put to beginning of upload : %6.4f sec\n" " begining of upload to end : %6.4f sec\n" " end of upload to close conn : %6.4f sec\n" " close conn to exit : %6.4f sec\n" "------------------------------------- \n" " put to close conn : %6.4f sec\n" " start to exit : %6.4f sec\n", dt0, dt1, dt2, dt3, dt4, dt5, dt6, dt7, dt8); if ((dt2> 0) && (dt1 > 0)) LIARdebug("\n" "Throughput: upload only : %10.3f kB/s\n" " steady state : %10.3f kB/s\n" " whole process : %10.3f kB/s\n", (tbs*nbc)/(dt4*1024), (tbs*nbc)/(dt7*1024), (tbs*nbc)/(dt8*1024)); return res; } imview-1.1.9c/client/imclient.h0000644000076500007650000000146207653236536017250 0ustar talbottalbot00000000000000/********************************************************** imclient.h ----------- **********************************************************/ #ifndef IMCLIENT_H #define IMCLIENT_H #include "liarwrap.h" /* need definition of IMAGE */ typedef enum {SHM_NONE = 0, SHM_POSIX, SHM_SYSV} ipctype; /* prototypes from imclient.c - connection with imview server */ int imviewput(IMAGE *I, const char *name, const char *user, const char *hostname, short port); void imview_force_socket(void); int imviewlogin(const char *user, const char *hn, int port, int *conn_id); char *imviewsendcommand(const char *cmd, int conn_id); int imviewputimage(IMAGE *I, const char *name, int conn_id); void imview_set_transfer_method(const ipctype method); void imviewlogout(int conn_id); #endif imview-1.1.9c/client/liarp.h0000644000076500007650000000046607653236536016556 0ustar talbottalbot00000000000000/*------------------------------------------------------------------------ * * Prototypes for the minimal version of the * Library of Image Analysis Routines * * Hugues Talbot 4 Jan 2001 * *-----------------------------------------------------------------------*/ int LIARdebug(char *fmt, ...); imview-1.1.9c/client/liarwrap.c0000644000076500007650000000626707653236537017271 0ustar talbottalbot00000000000000/*------------------------------------------------------------------------ * * minimal C wrappers for LIAR * * Hugues Talbot 4 Jan 2001 * *-----------------------------------------------------------------------*/ #include #include #include #include "liarwrap.h" char *imgtypestr_[] = { "IM_SINGLE", "IM_RGB", "IM_SPECTRUM", "IM_MULTI", "IM_BADIMAGE", "IM_UNSPEC", "IM_ERROR" }; char *pixtypestr_[] = { "IM_BINARY", "IM_INT1", "IM_UINT1", "IM_INT2", "IM_UINT2", "IM_INT4", "IM_UINT4", "IM_INT8", "IM_UINT8", "IM_FLOAT", "IM_DOUBLE", }; int pixsize_[] = { sizeof(char), /* IM_BINARY */ sizeof(char), /* IM_INT1 */ sizeof(char), /* IM_UINT1 */ sizeof(short), /* IM_INT2 */ sizeof(short), /* IM_UINT2 */ sizeof(int), /* IM_INT4 */ sizeof(int), /* IM_UINT4 */ 8, /* IM_INT8 */ 8, /* IM_UINT8 */ sizeof(float), /* IM_FLOAT */ sizeof(double) /* IM_DOUBLE */ }; static int debugIsOn = 0; IMAGE *imloadtiff(const char *path) { int start[3], end[3]; int pi, sf, spp, bps; unsigned short *colourmap[3] = {NULL, NULL, NULL}; long ncolours; void *inbuf; int result,i; pixtype pt; imgtype it; IMAGE *outimage; result = load_tiff(path, 0, start, end, &pi, &sf, &spp, &bps, colourmap, &ncolours, &inbuf); if (result != 0) return NULL; outimage = (IMAGE *)calloc(1,sizeof(IMAGE)); imsetfirstx(outimage,0,start[0]); imsetfirsty(outimage,0,start[1]); imsetfirstz(outimage,0,start[2]); imsetfirstt(outimage,0, 0); imsetnx(outimage, 0, end[0]-start[0]+1); imsetny(outimage, 0, end[1]-start[1]+1); imsetnz(outimage, 0, end[2]-start[2]+1); imsetnt(outimage, 0, 1); /* one time slice */ imsetnumcomp(outimage, spp); getTiffType(pi,sf,spp,bps, &pt, &it); imsetpixtype(outimage,0,pt); imsetimgtype(outimage, it); outimage->buff = inbuf; /* it works in this case. to be avoided */ return outimage; } int LIARdebug(const char * msg,...) { char strarg[BUFSIZE]; int ret = 0; va_list args; if (debugIsOn) { im_va_start(args,msg); snprintf(strarg, BUFSIZE, DEBUGPROMPT "%s\n", msg); //ret = vfprintf(stderr,strarg,args); ret = vprintf(strarg, args); va_end(args); } return ret; } void LIAREnableDebug(void) { debugIsOn = 1; } int LIARerror(const char *msg, ...) { char strarg[BUFSIZE]; int ret = 0; va_list args; im_va_start(args,msg); snprintf(strarg, BUFSIZE, ERRORPROMPT "%s", msg); ret = vfprintf(stderr, strarg, args); va_end(args); } int imexception(const char *msg, ...) { char strarg[BUFSIZE]; int ret = 0; va_list args; im_va_start(args,msg); snprintf(strarg, BUFSIZE, EXCEPTPROMPT "%s", msg); ret = vfprintf(stderr, strarg, args); va_end(args); exit(1); } #include "../io/loadtiff-code.h" imview-1.1.9c/client/liarwrap.h0000644000076500007650000000506007653236537017264 0ustar talbottalbot00000000000000/*------------------------------------------------------------------------ * * Prototypes for the minimal version of the C Wrappers for * Library of Image Analysis Routines * * Hugues Talbot 4 Jan 2001 * *-----------------------------------------------------------------------*/ #ifndef LIARWRAP_H #define LIARWRAP_H typedef enum { IM_SINGLE = 0, /* only one component */ IM_RGB = 1, /* exactly 3 components */ IM_SPECTRUM = 2, /* any number of components */ IM_MULTI = 3, /* those as well */ IM_BADIMAGE = 4, IM_UNSPEC = 5, IM_ERROR = 6 } imgtype; typedef enum { IM_BINARY = 0, IM_INT1 = 1, IM_UINT1 = 2, IM_INT2 = 3, IM_UINT2 = 4, IM_INT4 = 5, IM_UINT4 = 6, IM_INT8 = 7, IM_UINT8 = 8, IM_FLOAT = 9, IM_DOUBLE = 10 } pixtype; typedef struct image_ { int ox; /* X offset */ int oy; /* Y offset */ int oz; /* Z offset */ int ot; /* T offset */ int nx; /* X dimension */ int ny; /* Y dimension */ int nz; /* Z dimension */ int nt; /* T dimension */ int nc; /* nb of components */ imgtype it; pixtype pt; void **buff; /* data buffers */ } IMAGE; typedef unsigned int wsize_t; /* macros */ #define BUFSIZE 1024 #define DEBUGPROMPT "DEBUG> " #define ERRORPROMPT "**ERROR**> " #define EXCEPTPROMPT "**EXCEPTION**> " /* get */ #define imgetfirstx(i,c) (*i).ox #define imgetfirsty(i,c) (*i).oy #define imgetfirstz(i,c) (*i).oz #define imgetnx(i,c) (*i).nx #define imgetny(i,c) (*i).ny #define imgetnz(i,c) (*i).nz #define imgetnt(i,c) (*i).nt #define imgetnumcomp(i) (*i).nc #define imgetpixtype(i,c) (*i).pt #define imgetimgtype(i) (*i).it #define imgetpixsize(i,c) pixsize_[(*i).pt] #define imgetimgtypestr(i) imgtypestr_[(*i).it] #define imgetpixtypestr(i,c) pixtypestr_[(*i).pt] #define imgetbuff(i, c) (*i).buff[(c)] /* set */ #define imsetfirstx(i,c,v) (*i).ox = (v) #define imsetfirsty(i,c,v) (*i).oy = (v) #define imsetfirstz(i,c,v) (*i).oz = (v) #define imsetfirstt(i,c,v) (*i).ot = (v) #define imsetnx(i,c,v) (*i).nx = (v) #define imsetny(i,c,v) (*i).ny = (v) #define imsetnz(i,c,v) (*i).nz = (v) #define imsetnt(i,c,v) (*i).nt = (v) #define imsetnumcomp(i,v) (*i).nc = (v) #define imsetpixtype(i,c,v) (*i).pt = (v) #define imsetimgtype(i,v) (*i).it = (v) #define imsetbuff(i,c,v) (i).buff[(c)] = (v) /* others */ #define im_va_start va_start /* variables */ extern char *imgtypestr_[]; extern char *pixtypestr_[]; extern int pixsize_[]; /* prototypes */ IMAGE *imloadtiff(const char *path); #endif imview-1.1.9c/client/Makefile0000644000076500007650000000105507653236532016725 0ustar talbottalbot00000000000000# # Simple makefile for demo client code # CC=gcc CFLAGS = -g -DHAVE_POSIX_IPC -DHAVE_SYSV_IPC LDFLAGS = -ltiff -lm -lrt SOURCES = democlient.c imclient.c liarwrap.c OBJECTS = ${SOURCES:.c=.o} TARGET = democlient ifeq ($(MYZDIR), Solaris) CFLAGS += -DPOSIX_IPC_PREFIX='"/"' LDFLAGS += -lsocket -lnsl endif .c.o: ${CC} ${CFLAGS} -c $< ${TARGET}: ${OBJECTS} ${CC} ${CFLAGS} -o $@ ${OBJECTS} ${LDFLAGS} depend: ${SOURCES} ${CC} ${CFLAGS} -M $^ > makedepend clean: -rm ${OBJECTS} ${TARGET} makedepend: touch makedepend include makedepend imview-1.1.9c/client/startim.c0000644000076500007650000000246307653236537017125 0ustar talbottalbot00000000000000/*------------------------------------------------------------------------ * * This simple client program starts up an imview, where the portfile * is in fact a named pipe. This is trickier than with a file but it * works better if you want to start several imviews, as it forces * a measure of synchronization. * * Hugues Talbot 14 Mar 2001 * *-----------------------------------------------------------------------*/ #include #include #include #include #define PROG "startim" #define PIPESTR "/tmp/toto" #define IMVIEWCMD "imview -server -fork -portfile " PIPESTR #define FAIL do {perror(PROG); unlink(PIPESTR); exit(1);} while (0) int main() { char *execstring = IMVIEWCMD; char buffer[5]; int portnum, filenum, res; unlink(PIPESTR); /* might fail, don't care */ res = mkfifo(PIPESTR,S_IRUSR|S_IWUSR); if (res != 0) FAIL; /* open the pipe for reading, notice the NO DELAY */ filenum = open(PIPESTR, O_RDONLY | O_NDELAY, 0); if (filenum < 0) FAIL; /* then exec imview */ printf("Imview away...\n"); system(execstring); /* then read the pipe */ memset(buffer, '\0', 5); if (read(filenum, buffer, 4) <= 0) FAIL; printf("port number is %s\n", buffer); close(filenum); unlink(PIPESTR); return 0; } imview-1.1.9c/config.guess0000755000076500007650000012075107660203535016327 0ustar talbottalbot00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003 Free Software Foundation, Inc. timestamp='2003-01-30' # This file 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 program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; arc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; macppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvmeppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; pmax:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mipseb-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sun3:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; wgrisc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:MicroBSD:*:*) echo ${UNAME_MACHINE}-unknown-microbsd${UNAME_RELEASE} exit 0 ;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; DRS?6000:UNIX_SV:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7 && exit 0 ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c \ && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && exit 0 echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then # avoid double evaluation of $set_cc_for_build test -n "$CC_FOR_BUILD" || eval $set_cc_for_build if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; *:UNICOS/mp:*:*) echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) # Determine whether the default compiler uses glibc. eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #if __GLIBC__ >= 2 LIBC=gnu #else LIBC= #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; x86:Interix*:3*) echo i586-pc-interix3 exit 0 ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips64 #undef mips64el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mips64el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips64 #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit 0 ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit 0 ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit 0 ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit 0 ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit 0 ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #ifdef __INTEL_COMPILER LIBC=gnu #else LIBC=gnuaout #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit 0 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit 0 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit 0 ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit 0 ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; i*86:*:5:[78]*) case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit 0 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit 0 ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) case `uname -p` in *86) UNAME_PROCESSOR=i686 ;; powerpc) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit 0 ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: imview-1.1.9c/config.sub0000755000076500007650000007214007660203535015770 0ustar talbottalbot00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003 Free Software Foundation, Inc. timestamp='2003-01-28' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file 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 program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k \ | m32r | m68000 | m68k | m88k | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64vr | mips64vrel \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | msp430 \ | ns16k | ns32k \ | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* \ | clipper-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* \ | m32r-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64vr-* | mips64vrel-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | msp430-* \ | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* | tic30-* | tic4x-* | tic54x-* | tic80-* | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ | xtensa-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; mmix*) basic_machine=mmix-knuth os=-mmixware ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nv1) basic_machine=nv1-cray os=-unicosmp ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; or32 | or32-*) basic_machine=or32-unknown os=-coff ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2) basic_machine=i686-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic4x | c4x*) basic_machine=tic4x-unknown os=-coff ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sh64) basic_machine=sh64-unknown ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -microbsd*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: imview-1.1.9c/configure0000755000076500007650000122625310756342571015727 0ustar talbottalbot00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59. # # Copyright (C) 2003 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # Work around bugs in pre-3.0 UWIN ksh. $as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` exec 6>&1 # # Initializations. # ac_default_prefix=/usr/local ac_config_libobj_dir=. cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. # This variable seems obsolete. It should probably be removed, and # only ac_max_sed_lines should be used. : ${ac_max_here_lines=38} # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= ac_unique_file="io/cpostscript.cxx" # Factoring default headers for most tests. ac_includes_default="\ #include #if HAVE_SYS_TYPES_H # include #endif #if HAVE_SYS_STAT_H # include #endif #if STDC_HEADERS # include # include #else # if HAVE_STDLIB_H # include # endif #endif #if HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif #if HAVE_STRINGS_H # include #endif #if HAVE_INTTYPES_H # include #else # if HAVE_STDINT_H # include # endif #endif #if HAVE_UNISTD_H # include #endif" ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os MAJOR_VERSION MINOR_VERSION MICRO_VERSION BRANCH_TAG have_fltk_config FLTK_CONFIG CP MV EEXT CXX CXXFLAGS LDFLAGS CPPFLAGS ac_ct_CXX EXEEXT OBJEXT CC CFLAGS ac_ct_CC INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA RANLIB ac_ct_RANLIB SET_MAKE CPP EGREP X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS XLIBS LIBXTRA MATHLIB FLUID FLTKLIB FLTKEXTRA THREADLIB POSIX_IPC_LIB HAVE_MAGICK_CONFIG JPEGLIB TIFFLIB PNGLIB IMLIBS LIBCOMMAND MAKEDEPEND LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package| sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/-/_/g'` eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` eval "$ac_envvar='$ac_optarg'" export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute paths. for ac_var in exec_prefix prefix do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* | NONE | '' ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # Be sure to have absolute paths. for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ localstatedir libdir includedir oldincludedir infodir mandir do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_confdir=`(dirname "$0") 2>/dev/null || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 { (exit 1); exit 1; }; } else { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi fi (cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 { (exit 1); exit 1; }; } srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` ac_env_build_alias_set=${build_alias+set} ac_env_build_alias_value=$build_alias ac_cv_env_build_alias_set=${build_alias+set} ac_cv_env_build_alias_value=$build_alias ac_env_host_alias_set=${host_alias+set} ac_env_host_alias_value=$host_alias ac_cv_env_host_alias_set=${host_alias+set} ac_cv_env_host_alias_value=$host_alias ac_env_target_alias_set=${target_alias+set} ac_env_target_alias_value=$target_alias ac_cv_env_target_alias_set=${target_alias+set} ac_cv_env_target_alias_value=$target_alias ac_env_CXX_set=${CXX+set} ac_env_CXX_value=$CXX ac_cv_env_CXX_set=${CXX+set} ac_cv_env_CXX_value=$CXX ac_env_CXXFLAGS_set=${CXXFLAGS+set} ac_env_CXXFLAGS_value=$CXXFLAGS ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set} ac_cv_env_CXXFLAGS_value=$CXXFLAGS ac_env_LDFLAGS_set=${LDFLAGS+set} ac_env_LDFLAGS_value=$LDFLAGS ac_cv_env_LDFLAGS_set=${LDFLAGS+set} ac_cv_env_LDFLAGS_value=$LDFLAGS ac_env_CPPFLAGS_set=${CPPFLAGS+set} ac_env_CPPFLAGS_value=$CPPFLAGS ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} ac_cv_env_CPPFLAGS_value=$CPPFLAGS ac_env_CC_set=${CC+set} ac_env_CC_value=$CC ac_cv_env_CC_set=${CC+set} ac_cv_env_CC_value=$CC ac_env_CFLAGS_set=${CFLAGS+set} ac_env_CFLAGS_value=$CFLAGS ac_cv_env_CFLAGS_set=${CFLAGS+set} ac_cv_env_CFLAGS_value=$CFLAGS ac_env_CPP_set=${CPP+set} ac_env_CPP_value=$CPP ac_cv_env_CPP_set=${CPP+set} ac_cv_env_CPP_value=$CPP # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] _ACEOF cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --infodir=DIR info documentation [PREFIX/info] --mandir=DIR man documentation [PREFIX/man] _ACEOF cat <<\_ACEOF X features: --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] --target=TARGET configure for building compilers for TARGET [HOST] _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-prof enable prof source profiling support default=disable --enable-gprof enable gprof source profiling support default=disable --enable-gcov enable gcov source profiling support default=disable --enable-dblbuf enable use of double-buffered windows default=disable --enable-debug turn on debugging default=disable Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-fltk-dir=DIR location of the FLTK distribution directory to use. --without-jpeg disable native JPEG support default=enable --without-tiff disable native TIFF support default=enable --without-magick disable ImageMagick support default=enable --without-pink disable PINK support default=enable --without-native-chooser disable experimental native chooser default=enable --without-server disable image server default=with --without-sysv-ipc disable Unix SYSV shared memory support default=with --without-posix-ipc disable Unix POSIX shared memory support default=with --with-x use the X Window System Some influential environment variables: CXX C++ compiler command CXXFLAGS C++ compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CC C compiler command CFLAGS C compiler flags CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. _ACEOF fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d $ac_dir || continue ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Do not use `cd foo && pwd` to compute absolute paths, because # the directories may not exist. case `pwd` in .) ac_abs_builddir="$ac_dir";; *) case "$ac_dir" in .) ac_abs_builddir=`pwd`;; [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; *) ac_abs_builddir=`pwd`/"$ac_dir";; esac;; esac case $ac_abs_builddir in .) ac_abs_top_builddir=${ac_top_builddir}.;; *) case ${ac_top_builddir}. in .) ac_abs_top_builddir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; esac;; esac case $ac_abs_builddir in .) ac_abs_srcdir=$ac_srcdir;; *) case $ac_srcdir in .) ac_abs_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; esac;; esac case $ac_abs_builddir in .) ac_abs_top_srcdir=$ac_top_srcdir;; *) case $ac_top_srcdir in .) ac_abs_top_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; esac;; esac cd $ac_dir # Check for guested configure; otherwise get Cygnus style configure. if test -f $ac_srcdir/configure.gnu; then echo $SHELL $ac_srcdir/configure.gnu --help=recursive elif test -f $ac_srcdir/configure; then echo $SHELL $ac_srcdir/configure --help=recursive elif test -f $ac_srcdir/configure.ac || test -f $ac_srcdir/configure.in; then echo $ac_configure --help else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi cd $ac_popdir done fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF Copyright (C) 2003 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit 0 fi exec 5>config.log cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ _ACEOF { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` hostinfo = `(hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_sep= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" # Get rid of the leading space. ac_sep=" " ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Be sure not to use single quotes in there, as some shells, # such as our DU 5.0 friend, will then `close' the trap. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, { (set) 2>&1 | case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in *ac_space=\ *) sed -n \ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" ;; *) sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=$`echo $ac_var` echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------- ## ## Output files. ## ## ------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=$`echo $ac_var` echo "$ac_var='"'"'$ac_val'"'"'" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo sed "/^$/d" confdefs.h | sort echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 rm -f core *.core && rm -rf conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo >confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" eval ac_new_val="\$ac_env_${ac_var}_value" case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f $ac_dir/shtool; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} { (exit 1); exit 1; }; } fi ac_config_guess="$SHELL $ac_aux_dir/config.guess" ac_config_sub="$SHELL $ac_aux_dir/config.sub" ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. # Make sure we can run config.sub. $ac_config_sub sun4 >/dev/null 2>&1 || { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 echo "$as_me: error: cannot run $ac_config_sub" >&2;} { (exit 1); exit 1; }; } echo "$as_me:$LINENO: checking build system type" >&5 echo $ECHO_N "checking build system type... $ECHO_C" >&6 if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_build_alias=$build_alias test -z "$ac_cv_build_alias" && ac_cv_build_alias=`$ac_config_guess` test -z "$ac_cv_build_alias" && { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: result: $ac_cv_build" >&5 echo "${ECHO_T}$ac_cv_build" >&6 build=$ac_cv_build build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$as_me:$LINENO: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6 if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_host_alias=$host_alias test -z "$ac_cv_host_alias" && ac_cv_host_alias=$ac_cv_build_alias ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: result: $ac_cv_host" >&5 echo "${ECHO_T}$ac_cv_host" >&6 host=$ac_cv_host host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$as_me:$LINENO: checking target system type" >&5 echo $ECHO_N "checking target system type... $ECHO_C" >&6 if test "${ac_cv_target+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_target_alias=$target_alias test "x$ac_cv_target_alias" = "x" && ac_cv_target_alias=$ac_cv_host_alias ac_cv_target=`$ac_config_sub $ac_cv_target_alias` || { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: result: $ac_cv_target" >&5 echo "${ECHO_T}$ac_cv_target" >&6 target=$ac_cv_target target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` # The aliases save the names the user supplied, while $host etc. # will get canonicalized. test -n "$target_alias" && test "$program_prefix$program_suffix$program_transform_name" = \ NONENONEs,x,x, && program_prefix=${target_alias}- # generate configure header ac_config_headers="$ac_config_headers imcfg.h" # the name config.h is used everywhere these days # Set version MAJOR_VERSION=1 MINOR_VERSION=1 MICRO_VERSION=9 # ball is now rolling echo "configuring Imview $MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION" # Branch tag BRANCH_TAG=rel-1-1-0 echo "Branch $BRANCH_TAG" # start of the real thing # we need the version number, actually cat >>confdefs.h <<_ACEOF #define IMVIEW_MAJOR $MAJOR_VERSION _ACEOF cat >>confdefs.h <<_ACEOF #define IMVIEW_MINOR $MINOR_VERSION _ACEOF cat >>confdefs.h <<_ACEOF #define IMVIEW_MICRO $MICRO_VERSION _ACEOF # # we need the default prefix! # test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' #dnl Use C++ as the test language. # AC_LANG_CPLUSPLUS # does not seem to work... #AC_ARG_VAR ($CC," C compiler of choice") #AC_ARG_VAR ($CXX, "C++ compiler of choice") # location of FLTK library # Check whether --with-fltk-dir or --without-fltk-dir was given. if test "${with_fltk_dir+set}" = set; then withval="$with_fltk_dir" fltk_dist=$withval else fltk_dist="" fi; # Enable prof-based profiling support # Check whether --enable-prof or --disable-prof was given. if test "${enable_prof+set}" = set; then enableval="$enable_prof" with_prof=$enableval else with_prof='no' fi; # Enable gprof-based profiling support # Check whether --enable-gprof or --disable-gprof was given. if test "${enable_gprof+set}" = set; then enableval="$enable_gprof" with_gprof=$enableval else with_gprof='no' fi; # Enable gcov-based profiling support # Check whether --enable-gcov or --disable-gcov was given. if test "${enable_gcov+set}" = set; then enableval="$enable_gcov" with_gcov=$enableval else with_gcov='no' fi; with_profiling='no' if test "$with_prof" = 'yes' || test "$with_gprof" = 'yes' || test "$with_gcov" = 'yes' then with_profiling='yes' fi # Enable use of double-buffering windows. Doesn't work everywhere yet # Check whether --enable-dblbuf or --disable-dblbuf was given. if test "${enable_dblbuf+set}" = set; then enableval="$enable_dblbuf" with_dblbuf=$enableval else with_dblbuf='no' fi; # diverse optional libraries # Check whether --with-jpeg or --without-jpeg was given. if test "${with_jpeg+set}" = set; then withval="$with_jpeg" with_jpeg=$withval else with_jpeg='yes' fi; # Check whether --with-tiff or --without-tiff was given. if test "${with_tiff+set}" = set; then withval="$with_tiff" with_tiff=$withval else with_tiff='yes' fi; # Check whether --with-magick or --without-magick was given. if test "${with_magick+set}" = set; then withval="$with_magick" with_magick=$withval else with_magick='yes' fi; # Check whether --with-pink or --without-pink was given. if test "${with_pink+set}" = set; then withval="$with_pink" with_pink=$withval else with_pink='yes' fi; # the native chooser is MUCH nicer # Check whether --with-native-chooser or --without-native-chooser was given. if test "${with_native_chooser+set}" = set; then withval="$with_native_chooser" with_native_chooser=$withval else with_native_chooser='yes' fi; DEBUGFLAG="" PICFLAG=0 CFLAGS="${CFLAGS:=}" CXXFLAGS="${CXXFLAGS:=}" # Check whether --enable-debug or --disable-debug was given. if test "${enable_debug+set}" = set; then enableval="$enable_debug" \ with_debug=$enableval else with_debug='no' fi; if test "$with_debug" != "no" then # [if eval "test x$enable_debug = xyes"; then DEBUGFLAG="-g " ; fi]) DEBUGFLAG="-g " fi # Enable support for image server # Check whether --with-server or --without-server was given. if test "${with_server+set}" = set; then withval="$with_server" with_server=$withval else with_server='yes' fi; # enable support for SYSV type shared memory (not shared library!) # Check whether --with-sysv-ipc or --without-sysv-ipc was given. if test "${with_sysv_ipc+set}" = set; then withval="$with_sysv_ipc" with_sysv_ipc=$withval else with_sysv_ipc='yes' fi; # enable support for POSIX type shared memory (not shared library!) # Check whether --with-posix-ipc or --without-posix-ipc was given. if test "${with_posix_ipc+set}" = set; then withval="$with_posix_ipc" with_posix_ipc=$withval else with_posix_ipc='yes' fi; # if server is disabled, so is SYSV and POSIX if test "$with_server" != "yes" ; then with_sysv_ipc="no" with_posix_ipc="no" fi save_prof=$with_prof save_gprof=$with_gprof save_gcov=$with_gcov save_jpeg=$with_jpeg save_tiff=$with_tiff save_magick=$with_magick save_pink=$with_pink save_native_chooser=$with_native_chooser save_debug=$with_debug save_server=$with_server save_sysv_ipc=$with_sysv_ipc save_posix_ipc=$with_posix_ipc save_dblbuf=$with_dblbuf # Evaluate shell variable equivalents to Makefile directory variables eval "eval BIN_DIR=$bindir" eval "eval DATA_DIR=$datadir" eval "eval INCLUDE_DIR=$includedir" eval "eval LIB_DIR=$libdir" srcdirfull=`cd $srcdir && pwd` # so that we also look where the software will be installed (the `local' /usr/local...) LDFLAGS="$LDFLAGS -L$LIB_DIR" CPPFLAGS="$CPPFLAGS -I. " # by default we build for Unix and we need X. have_x="yes" have_carbon="no" # Carbon environment have_wingdi="no" # Windows GDI exec_extension="" # Unix executable are not known by their extention # use the host type LIBXTRA="" # trying for a `standard' echo ECHO=echo # other standard commands CP=/bin/cp MV=/bin/mv #needed to work around a bug in mingw START="" # Extract the first word of "fltk-config", so it can be a program name with args. set dummy fltk-config; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_have_fltk_config+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$have_fltk_config"; then ac_cv_prog_have_fltk_config="$have_fltk_config" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_dummy="${fltk_dist}:$PATH" for as_dir in $as_dummy do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_have_fltk_config=""yes"" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done test -z "$ac_cv_prog_have_fltk_config" && ac_cv_prog_have_fltk_config=""no"" fi fi have_fltk_config=$ac_cv_prog_have_fltk_config if test -n "$have_fltk_config"; then echo "$as_me:$LINENO: result: $have_fltk_config" >&5 echo "${ECHO_T}$have_fltk_config" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi if test "$have_fltk_config" != "yes" then echo "*** Fltk-config was not found!" echo "*** You need to upgrade FLTK to version 1.1.x, exiting" exit 1 fi if test "$fltk_dist" != "" then my_fltk_config=${fltk_dist}/fltk-config fltk_config_name=`$my_fltk_config --libs` # that's pre-installation, no good fltk_cfg_nm=`echo $fltk_config_name | sed 's%.*/lib\(fltk.*\).a%\1%'` # short name still OK fltk_config_name=${fltk_dist}/lib/lib${fltk_cfg_nm}.a fltk_images_name=${fltk_dist}/lib/lib${fltk_cfg_nm}_images.a fltk_include_flags=`$my_fltk_config --use-images --cxxflags` LDFLAGS="-L${fltk_dist}/lib $LDFLAGS" CPPFLAGS="-I${fltk_dist} $fltk_include_flags $CPPFLAGS" FLUID=${START}${fltk_dist}/fluid/fluid FLTKLIB=" $fltk_images_name $fltk_config_name" fltklib=fltk # one more hack for the road... This is needed to get the `framework` information on macos LDFLAGS="$LDFLAGS `$my_fltk_config --ldflags`" else my_fltk_config=fltk-config fltk_config_name=`$my_fltk_config --libs` # long path fltk_cfg_nm=`echo $fltk_config_name | sed 's%.*/lib\(fltk.*\).a%\1%'` # short name fltk_images_name=`$my_fltk_config --libs | sed 's/\(.*fltk\)\(\.a$\)/\1_images.a/'` fltk_include_flags=`$my_fltk_config --use-images --cxxflags` FLUID=${START}fluid LDFLAGS="$LDFLAGS `$my_fltk_config --use-images --ldstaticflags`" Cppflags="$CPPFLAGS $fltk_include_flags" FLTKLIB="`$my_fltk_config --use-images --ldstaticflags`" fltklib=$fltk_cfg_name fi fltk_x11_ldflags=`$my_fltk_config --ldflags | grep '\-lX11'` if test "$fltk_x11_ldflags" != "" ; then fltk_uses_x11=yes else fltk_uses_x11=no fi FLTK_CONFIG=$my_fltk_config case $target in *linux*) # our favourite platform :-) CPPFLAGS="-DLinux $CPPFLAGS" ;; *dec-osf*) # Compaq Tru64, aka DEC Unix, aka OSF1 CPPFLAGS="-DOSF1 $CPPFLAGS" ;; *sun-solaris2*) # Sun Solaris. Broken X headers are no fun CPPFLAGS="-DSolaris -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ $CPPFLAGS" # Sun POSIX IPC does not allow paths under /tmp cat >>confdefs.h <<\_ACEOF #define POSIX_IPC_PREFIX "/" _ACEOF # Solaris /usr/bin/echo does not understand `-n' ECHO=/usr/ucb/echo ;; *pc-mingw32*) # MINGW32. Nothing special, but no X! have_x="no" have_wingdi="yes" exec_extension=".exe" # Windows executable are `.exe' files. CPPFLAGS="$CPPFLAGS -O2" # my compiler doesn't produce correct executable unless optimizing! WINTHREAD="pthreadGC" # use the pthread-win32 without structured exceptions. START="/bin/start " # to be able non-mingw GUI applications like fluid, NOTE: space is important LDFLAGS="$LDFLAGS -mwindows -lole32 -luuid -lcomctl32 -lwsock32 -lsupc++" ;; *i686-pc-cygwin) # MINGW32. Nothing special, but no X! have_x="no" have_wingdi="yes" exec_extension=".exe" # Windows executable are `.exe' files. CPPFLAGS="$CPPFLAGS -O2 -mwin32" # my compiler doesn't produce correct executable unless optimizing! WINTHREAD="pthread" ;; *darwin*) # Mac OS/X echo "*** Oooh, MacOS/X" if test "$fltk_uses_x11" = "no" ; then echo "*** Using Carbon too" have_x="no" # use Carbon instead have_carbon="yes" CPPFLAGS="-DMACOSX_CARBON $CPPFLAGS" else echo "*** Still using X11" fi # assume presence of fink # not sure this is necessary, as we now use fltk-config CPPFLAGS="-DDARWIN -O2 -I/sw/include $CPPFLAGS" LDFLAGS="$LDFLAGS -L/sw/lib" if test "$with_magick" = "yes" ; then echo "Silencing magick warnings at link time" LDFLAGS="$LDFLAGS -Xlinker -multiply_defined -Xlinker suppress" echo "*** You might see a lot of warnings at link time if your version" echo "*** of ImageMagick embeds symbols from various other standard libraries" echo "*** such as libjpeg or libz. This is pretty harmless." fi CP=/Developer/Tools/CpMac MV=/Developer/Tools/MvMac ;; *) echo "*** A platform I haven't tried! Some definitions might be lacking" echo "*** Please contribute your changes if any required." echo "*** mailto: Hugues.Talbot@cmis.CSIRO.AU" ;; esac EEXT=$exec_extension ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -n "$ac_tool_prefix"; then for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then echo "$as_me:$LINENO: result: $CXX" >&5 echo "${ECHO_T}$CXX" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 echo "${ECHO_T}$ac_ct_CXX" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_CXX" && break done test -n "$ac_ct_CXX" || ac_ct_CXX="g++" CXX=$ac_ct_CXX fi # Provide some information about the compiler. echo "$as_me:$LINENO:" \ "checking for C++ compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. echo "$as_me:$LINENO: checking for C++ compiler default output file name" >&5 echo $ECHO_N "checking for C++ compiler default output file name... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Find the output, starting from the most likely. This scheme is # not robust to junk in `.', hence go to wildcards (a.*) only as a last # resort. # Be careful to initialize this variable, since it used to be cached. # Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. ac_cv_exeext= # b.out is created by i960 compilers. for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; conftest.$ac_ext ) # This is the source file. ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` # FIXME: I believe we export ac_cv_exeext for Libtool, # but it would be cool to find out if it's true. Does anybody # maintain Libtool? --akim. export ac_cv_exeext break;; * ) break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C++ compiler cannot create executables See \`config.log' for more details." >&5 echo "$as_me: error: C++ compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6 # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether the C++ compiler works" >&5 echo $ECHO_N "checking whether the C++ compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 echo "$as_me: error: cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` export ac_cv_exeext break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6 rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6 if test "${ac_cv_cxx_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6 GXX=`test $ac_compiler_gnu = yes && echo yes` ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS CXXFLAGS="-g" echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cxx_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cxx_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_prog_cxx_g=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6 if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi for ac_declaration in \ '' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration #include int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 continue fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done rm -f conftest* if test -n "$ac_declaration"; then echo '#ifdef __cplusplus' >>confdefs.h echo $ac_declaration >>confdefs.h echo '#endif' >>confdefs.h fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_CC" && break done CC=$ac_ct_CC fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 (eval $ac_compiler -V &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS CFLAGS="-g" echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_prog_cc_g=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 if test "${ac_cv_prog_cc_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_stdc=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std1 is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std1. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX 10.20 and later -Ae # HP-UX older versions -Aa -D_HPUX_SOURCE # SVR4 -Xc -D__EXTENSIONS__ for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_stdc=$ac_arg break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext done rm -f conftest.$ac_ext conftest.$ac_objext CC=$ac_save_CC fi case "x$ac_cv_prog_cc_stdc" in x|xno) echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6 ;; *) echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 CC="$CC $ac_cv_prog_cc_stdc" ;; esac # Some people use a C++ compiler to compile C. Since we use `exit', # in C++ we need to declare it. In case someone uses the same compiler # for both compiling C and C++ we need to have the C++ compiler decide # the declaration of exit, since it's the most demanding environment. cat >conftest.$ac_ext <<_ACEOF #ifndef __cplusplus choke me #endif _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then for ac_declaration in \ '' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration #include int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 continue fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_declaration int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext done rm -f conftest* if test -n "$ac_declaration"; then echo '#ifdef __cplusplus' >>confdefs.h echo $ac_declaration >>confdefs.h echo '#endif' >>confdefs.h fi else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi done done ;; esac done fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL=$ac_install_sh fi fi echo "$as_me:$LINENO: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then echo "$as_me:$LINENO: result: $RANLIB" >&5 echo "${ECHO_T}$RANLIB" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 echo "${ECHO_T}$ac_ct_RANLIB" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi RANLIB=$ac_ct_RANLIB else RANLIB="$ac_cv_prog_RANLIB" fi if test "$RANLIB" != ":"; then LIBCOMMAND="ar cr" else LIBCOMMAND="ar crs" fi echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'` if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.make <<\_ACEOF all: @echo 'ac_maketemp="$(MAKE)"' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` if test -n "$ac_maketemp"; then eval ac_cv_prog_make_${ac_make}_set=yes else eval ac_cv_prog_make_${ac_make}_set=no fi rm -f conftest.make fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 SET_MAKE= else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 SET_MAKE="MAKE=${MAKE-make}" fi echo "$as_me:$LINENO: checking whether the compiler supports member templates" >&5 echo $ECHO_N "checking whether the compiler supports member templates... $ECHO_C" >&6 if test "${ac_cv_cxx_member_templates+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ template class A { public: template A operator=(const A& z) { return A(); } }; int main () { A x; A y; x = y; return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_cxx_member_templates=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_cxx_member_templates=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_cxx_member_templates" >&5 echo "${ECHO_T}$ac_cv_cxx_member_templates" >&6 if test "$ac_cv_cxx_member_templates" = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_MEMBER_TEMPLATES _ACEOF fi echo "$as_me:$LINENO: checking whether the compiler supports use of the template keyword as a qualifier" >&5 echo $ECHO_N "checking whether the compiler supports use of the template keyword as a qualifier... $ECHO_C" >&6 if test "${ac_cv_cxx_template_keyword_qualifier+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ class A { public : A() {}; template static T convert() { return T(); } }; int main () { double z = A::template convert(); return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_cxx_template_keyword_qualifier=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_cxx_template_keyword_qualifier=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_cxx_template_keyword_qualifier" >&5 echo "${ECHO_T}$ac_cv_cxx_template_keyword_qualifier" >&6 if test "$ac_cv_cxx_template_keyword_qualifier" = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_TEMPLATE_KEYWORD_QUALIFIER _ACEOF fi echo "$as_me:$LINENO: checking whether the compiler supports templates as template arguments" >&5 echo $ECHO_N "checking whether the compiler supports templates as template arguments... $ECHO_C" >&6 if test "${ac_cv_cxx_templates_as_template_arguments+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ template class allocator { public : allocator() {}; }; template class T_alloc> class A { public : A() {} private : T_alloc alloc_; }; int main () { A x; return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_cxx_templates_as_template_arguments=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_cxx_templates_as_template_arguments=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_cxx_templates_as_template_arguments" >&5 echo "${ECHO_T}$ac_cv_cxx_templates_as_template_arguments" >&6 if test "$ac_cv_cxx_templates_as_template_arguments" = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_TEMPLATES_AS_TEMPLATE_ARGUMENTS _ACEOF fi echo "$as_me:$LINENO: checking whether the compiler supports default template parameters" >&5 echo $ECHO_N "checking whether the compiler supports default template parameters... $ECHO_C" >&6 if test "${ac_cv_cxx_default_template_parameters+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ template class A {public: int f() {return 0;}}; int main () { A a; return a.f(); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_cxx_default_template_parameters=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_cxx_default_template_parameters=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_cxx_default_template_parameters" >&5 echo "${ECHO_T}$ac_cv_cxx_default_template_parameters" >&6 if test "$ac_cv_cxx_default_template_parameters" = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_DEFAULT_TEMPLATE_PARAMETERS _ACEOF fi echo "$as_me:$LINENO: checking whether the compiler supports standard char traits" >&5 echo $ECHO_N "checking whether the compiler supports standard char traits... $ECHO_C" >&6 if test "${ac_cv_cxx_standard_char_traits+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include template > class A {public: charT f() {return 'c';}}; int main () { A a; return a.f(); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_cxx_standard_char_traits=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_cxx_standard_char_traits=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_cxx_standard_char_traits" >&5 echo "${ECHO_T}$ac_cv_cxx_standard_char_traits" >&6 if test "$ac_cv_cxx_standard_char_traits" = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_STANDARD_CHAR_TRAITS _ACEOF fi echo "$as_me:$LINENO: checking whether the compiler accepts array type casts in templates" >&5 echo $ECHO_N "checking whether the compiler accepts array type casts in templates... $ECHO_C" >&6 if test "${ac_cv_cxx_template_cast_array+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ typedef unsigned char uchar; template void testfeeble0(void *p, T dummy) { uchar (*q)[256] = (uchar (*)[256]) p;} int main () { uchar a[3][256], d; testfeeble0(a,d); return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_cxx_template_cast_array=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_cxx_template_cast_array=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_cxx_template_cast_array" >&5 echo "${ECHO_T}$ac_cv_cxx_template_cast_array" >&6 if test "$ac_cv_cxx_template_cast_array" = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_TEMPLATE_CAST_ARRAY _ACEOF fi ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include <$ac_hdr> int main () { if ((DIR *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 _ACEOF ac_header_dirent=$ac_hdr; break fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then echo "$as_me:$LINENO: checking for library containing opendir" >&5 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 if test "${ac_cv_search_opendir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS ac_cv_search_opendir=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char opendir (); int main () { opendir (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_search_opendir="none required" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_search_opendir" = no; then for ac_lib in dir; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char opendir (); int main () { opendir (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_search_opendir="-l$ac_lib" break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext done fi LIBS=$ac_func_search_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 echo "${ECHO_T}$ac_cv_search_opendir" >&6 if test "$ac_cv_search_opendir" != no; then test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" fi else echo "$as_me:$LINENO: checking for library containing opendir" >&5 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6 if test "${ac_cv_search_opendir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS ac_cv_search_opendir=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char opendir (); int main () { opendir (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_search_opendir="none required" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_search_opendir" = no; then for ac_lib in x; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char opendir (); int main () { opendir (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_search_opendir="-l$ac_lib" break else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext done fi LIBS=$ac_func_search_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 echo "${ECHO_T}$ac_cv_search_opendir" >&6 if test "$ac_cv_search_opendir" != no; then test "$ac_cv_search_opendir" = "none required" || LIBS="$ac_cv_search_opendir $LIBS" fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6 ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu echo "$as_me:$LINENO: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6 if test "${ac_cv_prog_egrep+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | (grep -E '(a|b)') >/dev/null 2>&1 then ac_cv_prog_egrep='grep -E' else ac_cv_prog_egrep='egrep' fi fi echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 echo "${ECHO_T}$ac_cv_prog_egrep" >&6 EGREP=$ac_cv_prog_egrep echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done if test "${ac_cv_header_sys_select_h+set}" = set; then echo "$as_me:$LINENO: checking for sys/select.h" >&5 echo $ECHO_N "checking for sys/select.h... $ECHO_C" >&6 if test "${ac_cv_header_sys_select_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: $ac_cv_header_sys_select_h" >&5 echo "${ECHO_T}$ac_cv_header_sys_select_h" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking sys/select.h usability" >&5 echo $ECHO_N "checking sys/select.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking sys/select.h presence" >&5 echo $ECHO_N "checking sys/select.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: sys/select.h: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: sys/select.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: sys/select.h: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: sys/select.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: sys/select.h: present but cannot be compiled" >&5 echo "$as_me: WARNING: sys/select.h: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: sys/select.h: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: sys/select.h: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: sys/select.h: see the Autoconf documentation" >&5 echo "$as_me: WARNING: sys/select.h: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: sys/select.h: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: sys/select.h: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: sys/select.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: sys/select.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: sys/select.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: sys/select.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------------------ ## ## Report this to the AC_PACKAGE_NAME lists. ## ## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for sys/select.h" >&5 echo $ECHO_N "checking for sys/select.h... $ECHO_C" >&6 if test "${ac_cv_header_sys_select_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_sys_select_h=$ac_header_preproc fi echo "$as_me:$LINENO: result: $ac_cv_header_sys_select_h" >&5 echo "${ECHO_T}$ac_cv_header_sys_select_h" >&6 fi if test "${ac_cv_header_winsock_h+set}" = set; then echo "$as_me:$LINENO: checking for winsock.h" >&5 echo $ECHO_N "checking for winsock.h... $ECHO_C" >&6 if test "${ac_cv_header_winsock_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: $ac_cv_header_winsock_h" >&5 echo "${ECHO_T}$ac_cv_header_winsock_h" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking winsock.h usability" >&5 echo $ECHO_N "checking winsock.h usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking winsock.h presence" >&5 echo $ECHO_N "checking winsock.h presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: winsock.h: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: winsock.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: winsock.h: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: winsock.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: winsock.h: present but cannot be compiled" >&5 echo "$as_me: WARNING: winsock.h: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: winsock.h: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: winsock.h: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: winsock.h: see the Autoconf documentation" >&5 echo "$as_me: WARNING: winsock.h: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: winsock.h: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: winsock.h: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: winsock.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: winsock.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: winsock.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: winsock.h: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------------------ ## ## Report this to the AC_PACKAGE_NAME lists. ## ## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for winsock.h" >&5 echo $ECHO_N "checking for winsock.h... $ECHO_C" >&6 if test "${ac_cv_header_winsock_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_winsock_h=$ac_header_preproc fi echo "$as_me:$LINENO: result: $ac_cv_header_winsock_h" >&5 echo "${ECHO_T}$ac_cv_header_winsock_h" >&6 fi echo "$as_me:$LINENO: checking whether accept uses socklen_t" >&5 echo $ECHO_N "checking whether accept uses socklen_t... $ECHO_C" >&6 if test "${ac_cv_accept_uses_socklen_t_init+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { accept (1, NULL, (socklen_t*)NULL); return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_accept_uses_socklen_t_init=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 acc_cv_accept_uses_socklen_t_init=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_accept_uses_socklen_t_init" >&5 echo "${ECHO_T}$ac_cv_accept_uses_socklen_t_init" >&6 if test "$ac_cv_accept_uses_socklen_t_init" = yes ; then cat >>confdefs.h <<\_ACEOF #define ACCEPT_USES_SOCKLEN_T _ACEOF fi echo "$as_me:$LINENO: checking for scandir" >&5 echo $ECHO_N "checking for scandir... $ECHO_C" >&6 if test "${ac_cv_func_scandir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define scandir to an innocuous variant, in case declares scandir. For example, HP-UX 11i declares gettimeofday. */ #define scandir innocuous_scandir /* System header to define __stub macros and hopefully few prototypes, which can conflict with char scandir (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef scandir /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char scandir (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_scandir) || defined (__stub___scandir) choke me #else char (*f) () = scandir; #endif #ifdef __cplusplus } #endif int main () { return f != scandir; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_scandir=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_scandir=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_scandir" >&5 echo "${ECHO_T}$ac_cv_func_scandir" >&6 if test $ac_cv_func_scandir = yes; then if test "$uname" = "SunOS"; then echo Not using Solaris scandir BSD emulation function. else cat >>confdefs.h <<\_ACEOF #define HAVE_SCANDIR 1 _ACEOF fi fi echo "$as_me:$LINENO: checking for vsnprintf" >&5 echo $ECHO_N "checking for vsnprintf... $ECHO_C" >&6 if test "${ac_cv_func_vsnprintf+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define vsnprintf to an innocuous variant, in case declares vsnprintf. For example, HP-UX 11i declares gettimeofday. */ #define vsnprintf innocuous_vsnprintf /* System header to define __stub macros and hopefully few prototypes, which can conflict with char vsnprintf (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef vsnprintf /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char vsnprintf (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_vsnprintf) || defined (__stub___vsnprintf) choke me #else char (*f) () = vsnprintf; #endif #ifdef __cplusplus } #endif int main () { return f != vsnprintf; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_vsnprintf=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_vsnprintf=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_vsnprintf" >&5 echo "${ECHO_T}$ac_cv_func_vsnprintf" >&6 if test $ac_cv_func_vsnprintf = yes; then if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then echo Not using built-in vsnprintf function because you are running HP-UX 10.20. else cat >>confdefs.h <<\_ACEOF #define HAVE_VSNPRINTF 1 _ACEOF fi fi echo "$as_me:$LINENO: checking for snprintf" >&5 echo $ECHO_N "checking for snprintf... $ECHO_C" >&6 if test "${ac_cv_func_snprintf+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define snprintf to an innocuous variant, in case declares snprintf. For example, HP-UX 11i declares gettimeofday. */ #define snprintf innocuous_snprintf /* System header to define __stub macros and hopefully few prototypes, which can conflict with char snprintf (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef snprintf /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char snprintf (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_snprintf) || defined (__stub___snprintf) choke me #else char (*f) () = snprintf; #endif #ifdef __cplusplus } #endif int main () { return f != snprintf; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_snprintf=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_snprintf=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_snprintf" >&5 echo "${ECHO_T}$ac_cv_func_snprintf" >&6 if test $ac_cv_func_snprintf = yes; then if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then echo Not using built-in snprintf function because you are running HP-UX 10.20. else cat >>confdefs.h <<\_ACEOF #define HAVE_SNPRINTF 1 _ACEOF fi fi for ac_func in vsprintf do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else char (*f) () = $ac_func; #endif #ifdef __cplusplus } #endif int main () { return f != $ac_func; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in usleep nanosleep do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else char (*f) () = $ac_func; #endif #ifdef __cplusplus } #endif int main () { return f != $ac_func; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done if test "$have_x" = "yes" ; then # Check for X echo "$as_me:$LINENO: checking for X" >&5 echo $ECHO_N "checking for X... $ECHO_C" >&6 # Check whether --with-x or --without-x was given. if test "${with_x+set}" = set; then withval="$with_x" fi; # $have_x is `yes', `no', `disabled', or empty when we do not yet know. if test "x$with_x" = xno; then # The user explicitly disabled X. have_x=disabled else if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then # Both variables are already set. have_x=yes else if test "${ac_cv_have_x+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # One or both of the vars are not set, and there is no cached value. ac_x_includes=no ac_x_libraries=no rm -fr conftest.dir if mkdir conftest.dir; then cd conftest.dir # Make sure to not put "make" in the Imakefile rules, since we grep it out. cat >Imakefile <<'_ACEOF' acfindx: @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' _ACEOF if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. for ac_extension in a so sl; do if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && test -f $ac_im_libdir/libX11.$ac_extension; then ac_im_usrlibdir=$ac_im_libdir; break fi done # Screen out bogus values from the imake configuration. They are # bogus both because they are the default anyway, and because # using them would break gcc on systems where it needs fixed includes. case $ac_im_incroot in /usr/include) ;; *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;; esac case $ac_im_usrlibdir in /usr/lib | /lib) ;; *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;; esac fi cd .. rm -fr conftest.dir fi # Standard set of common directories for X headers. # Check X11 before X11Rn because it is often a symlink to the current release. ac_x_header_dirs=' /usr/X11/include /usr/X11R6/include /usr/X11R5/include /usr/X11R4/include /usr/include/X11 /usr/include/X11R6 /usr/include/X11R5 /usr/include/X11R4 /usr/local/X11/include /usr/local/X11R6/include /usr/local/X11R5/include /usr/local/X11R4/include /usr/local/include/X11 /usr/local/include/X11R6 /usr/local/include/X11R5 /usr/local/include/X11R4 /usr/X386/include /usr/x386/include /usr/XFree86/include/X11 /usr/include /usr/local/include /usr/unsupported/include /usr/athena/include /usr/local/x11r5/include /usr/lpp/Xamples/include /usr/openwin/include /usr/openwin/share/include' if test "$ac_x_includes" = no; then # Guess where to find include files, by looking for Intrinsic.h. # First, try using that file with no special directory specified. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # We can compile using X headers with no special include directory. ac_x_includes= else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do if test -r "$ac_dir/X11/Intrinsic.h"; then ac_x_includes=$ac_dir break fi done fi rm -f conftest.err conftest.$ac_ext fi # $ac_x_includes = no if test "$ac_x_libraries" = no; then # Check for the libraries. # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS LIBS="-lXt $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { XtMalloc (0) ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then LIBS=$ac_save_LIBS # We can link X programs with no special library path. ac_x_libraries= else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 LIBS=$ac_save_LIBS for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` do # Don't even attempt the hair of trying to link an X program! for ac_extension in a so sl; do if test -r $ac_dir/libXt.$ac_extension; then ac_x_libraries=$ac_dir break 2 fi done done fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi # $ac_x_libraries = no if test "$ac_x_includes" = no || test "$ac_x_libraries" = no; then # Didn't find X anywhere. Cache the known absence of X. ac_cv_have_x="have_x=no" else # Record where we found X for the cache. ac_cv_have_x="have_x=yes \ ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" fi fi fi eval "$ac_cv_have_x" fi # $with_x != no if test "$have_x" != yes; then echo "$as_me:$LINENO: result: $have_x" >&5 echo "${ECHO_T}$have_x" >&6 no_x=yes else # If each of the values was on the command line, it overrides each guess. test "x$x_includes" = xNONE && x_includes=$ac_x_includes test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries # Update the cache value to reflect the command line values. ac_cv_have_x="have_x=yes \ ac_x_includes=$x_includes ac_x_libraries=$x_libraries" echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5 echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6 fi if test "$no_x" = yes; then # Not all programs may use this symbol, but it does not hurt to define it. cat >>confdefs.h <<\_ACEOF #define X_DISPLAY_MISSING 1 _ACEOF X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= else if test -n "$x_includes"; then X_CFLAGS="$X_CFLAGS -I$x_includes" fi # It would also be nice to do this for all -L options, not just this one. if test -n "$x_libraries"; then X_LIBS="$X_LIBS -L$x_libraries" # For Solaris; some versions of Sun CC require a space after -R and # others require no space. Words are not sufficient . . . . case `(uname -sr) 2>/dev/null` in "SunOS 5"*) echo "$as_me:$LINENO: checking whether -R must be followed by a space" >&5 echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6 ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_R_nospace=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_R_nospace=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test $ac_R_nospace = yes; then echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 X_LIBS="$X_LIBS -R$x_libraries" else LIBS="$ac_xsave_LIBS -R $x_libraries" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_R_space=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_R_space=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test $ac_R_space = yes; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 X_LIBS="$X_LIBS -R $x_libraries" else echo "$as_me:$LINENO: result: neither works" >&5 echo "${ECHO_T}neither works" >&6 fi fi LIBS=$ac_xsave_LIBS esac fi # Check for system-dependent libraries X programs must link with. # Do this before checking for the system-independent R6 libraries # (-lICE), since we may need -lsocket or whatever for X linking. if test "$ISC" = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" else # Martyn Johnson says this is needed for Ultrix, if the X # libraries were built with DECnet support. And Karl Berry says # the Alpha needs dnet_stub (dnet does not exist). ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char XOpenDisplay (); int main () { XOpenDisplay (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet" >&5 echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6 if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldnet $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char dnet_ntoa (); int main () { dnet_ntoa (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dnet_dnet_ntoa=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dnet_dnet_ntoa=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6 if test $ac_cv_lib_dnet_dnet_ntoa = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet_stub" >&5 echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6 if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldnet_stub $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char dnet_ntoa (); int main () { dnet_ntoa (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dnet_stub_dnet_ntoa=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dnet_stub_dnet_ntoa=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6 if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" fi fi fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$ac_xsave_LIBS" # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, # to get the SysV transport functions. # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4) # needs -lnsl. # The nsl library prevents programs from opening the X display # on Irix 5.2, according to T.E. Dickey. # The functions gethostbyname, getservbyname, and inet_addr are # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. echo "$as_me:$LINENO: checking for gethostbyname" >&5 echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6 if test "${ac_cv_func_gethostbyname+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define gethostbyname to an innocuous variant, in case declares gethostbyname. For example, HP-UX 11i declares gettimeofday. */ #define gethostbyname innocuous_gethostbyname /* System header to define __stub macros and hopefully few prototypes, which can conflict with char gethostbyname (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef gethostbyname /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gethostbyname (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_gethostbyname) || defined (__stub___gethostbyname) choke me #else char (*f) () = gethostbyname; #endif #ifdef __cplusplus } #endif int main () { return f != gethostbyname; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_gethostbyname=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_gethostbyname=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname" >&5 echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6 if test $ac_cv_func_gethostbyname = no; then echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5 echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6 if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gethostbyname (); int main () { gethostbyname (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_nsl_gethostbyname=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_nsl_gethostbyname=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5 echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6 if test $ac_cv_lib_nsl_gethostbyname = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" fi if test $ac_cv_lib_nsl_gethostbyname = no; then echo "$as_me:$LINENO: checking for gethostbyname in -lbsd" >&5 echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6 if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lbsd $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gethostbyname (); int main () { gethostbyname (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_bsd_gethostbyname=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_bsd_gethostbyname=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_bsd_gethostbyname" >&5 echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6 if test $ac_cv_lib_bsd_gethostbyname = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" fi fi fi # lieder@skyler.mavd.honeywell.com says without -lsocket, # socket/setsockopt and other routines are undefined under SCO ODT # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary # on later versions), says Simon Leinen: it contains gethostby* # variants that don't use the name server (or something). -lsocket # must be given before -lnsl if both are needed. We assume that # if connect needs -lnsl, so does gethostbyname. echo "$as_me:$LINENO: checking for connect" >&5 echo $ECHO_N "checking for connect... $ECHO_C" >&6 if test "${ac_cv_func_connect+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define connect to an innocuous variant, in case declares connect. For example, HP-UX 11i declares gettimeofday. */ #define connect innocuous_connect /* System header to define __stub macros and hopefully few prototypes, which can conflict with char connect (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef connect /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char connect (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_connect) || defined (__stub___connect) choke me #else char (*f) () = connect; #endif #ifdef __cplusplus } #endif int main () { return f != connect; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_connect=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_connect=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_connect" >&5 echo "${ECHO_T}$ac_cv_func_connect" >&6 if test $ac_cv_func_connect = no; then echo "$as_me:$LINENO: checking for connect in -lsocket" >&5 echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6 if test "${ac_cv_lib_socket_connect+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $X_EXTRA_LIBS $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char connect (); int main () { connect (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_socket_connect=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_socket_connect=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_socket_connect" >&5 echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6 if test $ac_cv_lib_socket_connect = yes; then X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" fi fi # Guillermo Gomez says -lposix is necessary on A/UX. echo "$as_me:$LINENO: checking for remove" >&5 echo $ECHO_N "checking for remove... $ECHO_C" >&6 if test "${ac_cv_func_remove+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define remove to an innocuous variant, in case declares remove. For example, HP-UX 11i declares gettimeofday. */ #define remove innocuous_remove /* System header to define __stub macros and hopefully few prototypes, which can conflict with char remove (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef remove /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char remove (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_remove) || defined (__stub___remove) choke me #else char (*f) () = remove; #endif #ifdef __cplusplus } #endif int main () { return f != remove; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_remove=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_remove=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_remove" >&5 echo "${ECHO_T}$ac_cv_func_remove" >&6 if test $ac_cv_func_remove = no; then echo "$as_me:$LINENO: checking for remove in -lposix" >&5 echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6 if test "${ac_cv_lib_posix_remove+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lposix $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char remove (); int main () { remove (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_posix_remove=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_posix_remove=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_posix_remove" >&5 echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6 if test $ac_cv_lib_posix_remove = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" fi fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. echo "$as_me:$LINENO: checking for shmat" >&5 echo $ECHO_N "checking for shmat... $ECHO_C" >&6 if test "${ac_cv_func_shmat+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define shmat to an innocuous variant, in case declares shmat. For example, HP-UX 11i declares gettimeofday. */ #define shmat innocuous_shmat /* System header to define __stub macros and hopefully few prototypes, which can conflict with char shmat (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef shmat /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char shmat (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_shmat) || defined (__stub___shmat) choke me #else char (*f) () = shmat; #endif #ifdef __cplusplus } #endif int main () { return f != shmat; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_shmat=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_shmat=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_shmat" >&5 echo "${ECHO_T}$ac_cv_func_shmat" >&6 if test $ac_cv_func_shmat = no; then echo "$as_me:$LINENO: checking for shmat in -lipc" >&5 echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6 if test "${ac_cv_lib_ipc_shmat+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lipc $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char shmat (); int main () { shmat (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_ipc_shmat=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_ipc_shmat=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_ipc_shmat" >&5 echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6 if test $ac_cv_lib_ipc_shmat = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" fi fi fi # Check for libraries that X11R6 Xt/Xaw programs need. ac_save_LDFLAGS=$LDFLAGS test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries" # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to # check for ICE first), but we must link in the order -lSM -lICE or # we get undefined symbols. So assume we have SM if we have ICE. # These have to be linked with before -lX11, unlike the other # libraries we check for below, so use a different variable. # John Interrante, Karl Berry echo "$as_me:$LINENO: checking for IceConnectionNumber in -lICE" >&5 echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6 if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lICE $X_EXTRA_LIBS $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char IceConnectionNumber (); int main () { IceConnectionNumber (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_ICE_IceConnectionNumber=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_ICE_IceConnectionNumber=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6 if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" fi LDFLAGS=$ac_save_LDFLAGS fi echo "Ignoring libraries \"$X_PRE_LIBS\" requested by configure." if test "$with_magick" != "no" ; then # this seems to be sufficient somehow # as Magick will include the right libraries and flags already XLIBS="-lX11 -lXext" else # I'm not sure how reliable this is... XLIBS="$X_LIBS -lX11 -lXext" fi # LIBS="$LIBS$X_LIBS" CFLAGS="$CFLAGS $X_CFLAGS" CPPFLAGS="$CPPFLAGS $X_CFLAGS" # check for some incorrect X11 headers echo "$as_me:$LINENO: checking whether the compiler needs -fpermissive to compile the X11 headers" >&5 echo $ECHO_N "checking whether the compiler needs -fpermissive to compile the X11 headers... $ECHO_C" >&6 if test "${ac_cv_cxx_needs_permissive+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_cxx_needs_permissive=no else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_cxx_needs_permissive=yes fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_cxx_needs_permissive" >&5 echo "${ECHO_T}$ac_cv_cxx_needs_permissive" >&6 if test "$ac_cv_cxx_needs_permissive" = yes ; then if test -n "$GXX" ; then CPPFLAGS="-fpermissive $CPPFLAGS" else echo "*** Compiler is not GCC, cannot fix that problem" fi fi # check for Xinerama echo "$as_me:$LINENO: checking check for the xinerama extension" >&5 echo $ECHO_N "checking check for the xinerama extension... $ECHO_C" >&6 if test "${ac_x11_has_xinerama+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { (void) XineramaIsActive(0); return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_x11_has_xinerama=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_x11_has_xinerama=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_x11_has_xinerama" >&5 echo "${ECHO_T}$ac_x11_has_xinerama" >&6 if test "$ac_x11_has_xinerama" = yes ; then XINERAMA="-lXinerama" cat >>confdefs.h <<\_ACEOF #define HAVE_XINERAMA _ACEOF else XINERAMA="" fi XLIBS="$XLIBS $XINERAMA" fi MAKEDEPEND="\$(CXX) -M" if test -n "$GXX"; then echo "$as_me:$LINENO: checking whether gcc bitches when told to look inside INCLUDE_DIR" >&5 echo $ECHO_N "checking whether gcc bitches when told to look inside INCLUDE_DIR... $ECHO_C" >&6 if test "${ac_cv_gcc_complains_about_system_headers+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CPPSAVE=$CPPFLAGS CPPFLAGS="$CPPFLAGS -I$INCLUDE_DIR -Werror" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { printf("hello world\n"); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_gcc_complains_about_system_headers=no else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_gcc_complains_about_system_headers=yes fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CPPFLAGS=$CPPSAVE fi echo "$as_me:$LINENO: result: $ac_cv_gcc_complains_about_system_headers" >&5 echo "${ECHO_T}$ac_cv_gcc_complains_about_system_headers" >&6 if test "$ac_cv_gcc_complains_about_system_headers" = no ; then CPPFLAGS="$CPPFLAGS -I$INCLUDE_DIR" else CPPFLAGS="$CPPFLAGS -isystem $INCLUDE_DIR" fi # this will add -I$INCLUDE_DIR if the compiler does not complain about it. echo "$as_me:$LINENO: checking whether gcc bitches when including some deprecated headers" >&5 echo $ECHO_N "checking whether gcc bitches when including some deprecated headers... $ECHO_C" >&6 if test "${ac_cv_gcc_complains_about_deprecated_headers+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu CPPSAVE=$CPPFLAGS CPPFLAGS="$CPPFLAGS -I$INCLUDE_DIR -Werror" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { std::cout << "Hello world\n"; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_gcc_complains_about_deprecated_headers=no else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_gcc_complains_about_deprecated_headers=yes fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CPPFLAGS=$CPPSAVE fi echo "$as_me:$LINENO: result: $ac_cv_gcc_complains_about_deprecated_headers" >&5 echo "${ECHO_T}$ac_cv_gcc_complains_about_deprecated_headers" >&6 if test "$ac_cv_gcc_complains_about_deprecated_headers" = yes ; then CXXFLAGS="$CXXFLAGS -Wno-deprecated" fi # this will test if -Wno-deprecated is necessary CFLAGS="-Wall $CFLAGS" # GNU C++ is sometimes missing bits of the STL echo "$as_me:$LINENO: checking whether the C++ library knows about string streams" >&5 echo $ECHO_N "checking whether the C++ library knows about string streams... $ECHO_C" >&6 if test "${ac_cv_cxx_has_strstream+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_cxx_has_strstream=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_cxx_has_strstream=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_cxx_has_strstream" >&5 echo "${ECHO_T}$ac_cv_cxx_has_strstream" >&6 if test "$ac_cv_cxx_has_strstream" = no ; then CXXFLAGS="-I$srcdirfull/stl/sstream $CXXFLAGS" fi # other bits for g++ CXXFLAGS="-Wall -Wno-return-type -Wno-unknown-pragmas $CXXFLAGS" if test -z "$DEBUGFLAG"; then CFLAGS="-O2 $CFLAGS" CXXFLAGS="-O2 $CXXFLAGS" else CFLAGS="$DEBUGFLAG $CFLAGS" CXXFLAGS="$DEBUGFLAG $CXXFLAGS" fi else case `(uname) 2>/dev/null` in IRIX*) # Running some flavor of IRIX; see which version and # set things up according... if test "$uversion" -ge 62; then # We are running IRIX 6.2 or higher; uncomment the following # lines if you don't have IDO 7.2 or higher: # # CXX="CC -n32" # CC="cc -n32" # LD="ld -n32" # MAKEDEPEND="CC -M" echo "FOR BEST RESULTS BEFORE COMPILING: setenv SGI_ABI -n32" # -woff 3322 is necessary due to errors in Xlib headers on IRIX CFLAGS="-fullwarn $CFLAGS" CXXFLAGS="-fullwarn -woff 1685,3322 $CXXFLAGS" else CXXFLAGS="+w +pp $CXXFLAGS" fi if test -z "$DEBUGFLAG"; then CFLAGS="-O2 $CFLAGS" CXXFLAGS="-O2 $CXXFLAGS" fi ;; HP-UX*) # Running HP-UX; these options should work for the HP compilers. if test -z "$DEBUGFLAG"; then CFLAGS="+O2 $CFLAGS" CXXFLAGS="+O2 +W336,501,736,740,749,829 $CXXFLAGS" fi ;; SunOS*) # Solaris if test -z "$DEBUGFLAG"; then CFLAGS="-O" CXXFLAGS="-O" fi ;; OSF*) # DEC Unix (Compaq silly tru64) if test -z "$DEBUGFLAG"; then CFLAGS="-O2 -Olimit 2000 $CFLAGS" CXXFLAGS="-ttimestamp -O2 -Olimit 2000 $CXXFLAGS" else CFLAGS="$DEBUGFLAG $CFLAGS" CXXFLAGS="$DEBUGFLAG $CXXFLAGS" fi CFLAGS="$CFLAGS -I${prefix}/include" CXXFLAGS="$CXXFLAGS -I${prefix}/include" LIBCOMMAND="/usr/bin/ar cr" # make sure we use the system's archiver. GNU's not compatible with cxx # we need the IOStream library, and we enable ALL the compiler messages CXXFLAGS="-w1 -D__USE_STD_IOSTREAM $CXXFLAGS" # the CXX compiler requires this when using automated template # instantiation. LIBXTRA="cxx_repository/*.o" ;; Linux*) # test for the Intel compiler if test "$CXX" = "icc" ; then if test -z "$DEBUGFLAG"; then CFLAGS="-O2 -w1" CXXFLAGS="-O2" fi else echo "+++ Unknown compiler, using safe optimization flags" if test -z "$DEBUGFLAG"; then CFLAGS="-O" CXXFLAGS="-O" fi fi ;; Darwin*) # Mac OS/X, where cc is really gcc # assume presence of fink ;; *) # Running some other operating system; inform the user they # should contribute the necessary options to fltk-bugs@easysw.com... echo "+++ Untried platform" echo "+++ Building Imview with default compiler flags; contact" echo "+++ hut66au at gmail dot com with uname and compiler options needed" echo "+++ for your platform, or set the CFLAGS and CXXFLAGS options" echo "+++ before running configure." ;; esac fi # # Find math library # MATHLIB='' echo "$as_me:$LINENO: checking for sqrt in -lm" >&5 echo $ECHO_N "checking for sqrt in -lm... $ECHO_C" >&6 if test "${ac_cv_lib_m_sqrt+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char sqrt (); int main () { sqrt (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_m_sqrt=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_m_sqrt=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_m_sqrt" >&5 echo "${ECHO_T}$ac_cv_lib_m_sqrt" >&6 if test $ac_cv_lib_m_sqrt = yes; then MATHLIB=" -lm" fi LIBS="$LIBS $MATHLIB" # -lm is needed almost everywhere #AC_CHECK_LIB(GL, main) $ECHO -n "Checking for fltk version: " majorver=`(${FLUID} -o /tmp/toto -c /dev/null ; grep 'version' /tmp/toto | awk '{printf("%.0f\n", $NF)}' )` minorver=`( grep 'version' /tmp/toto | awk '{printf("%0.f\n", ($NF-int($NF)) * 100)}' )` patchver=`( grep 'version' /tmp/toto | awk '{printf("%0.f\n", 100*((($NF-int($NF))*100)-int(($NF-int($NF))*100)))}' )` rm /tmp/toto # clean up if test $majorver -eq 1 -a $minorver -ge 1 then echo "... OK" else echo "" echo "*** Please select FLTK version 1.1.x" echo "*** NOTE that FLTK 2.0 or greater is not supported yet..." echo "*** FLTK 1.0.x is only supported by imview-1.0.x or lesser" exit 1 fi fltk_alt_suff=`echo $CXX | sed 's%/%_%g'` echo "Alternative libfltk name: " libfltk_${fltk_alt_suff}.a echo "Configured libfltk name: " $fltk_config_name xtra_cflags=`$my_fltk_config --cflags` xtra_ldflags=`$my_fltk_config --ldflags` if test "$have_wingdi" = 'yes' ; then echo "Building for the Windows GDI" CPPFLAGS="$CPPFLAGS ${xtra_cflags}" XLIBS="$XLIBS ${xtra_ldflags}" fi if test "$have_macos" = 'yes' ; then echo "Building for MacOS Carbon environment" XLIBS="$XLIBS -framework Carbon -framework ApplicationServices" fi need_Xft=`$my_fltk_config --ldflags | grep Xft` echo -n "Testing if $fltklib needs True Type rendering" if test "$need_Xft" != "" then echo "... Yes" FLTKEXTRA="$FLTKEXTRA -lXft" else echo "... No" fi THREADLIB='' if test "$with_server" != 'no' then # Unix if test "$have_x" != "no" -o "$have_carbon" != "no" ; then echo "Testing for Unix threads" echo "Standard Pthreads:" echo "$as_me:$LINENO: checking for pthread_attr_init in -lpthread" >&5 echo $ECHO_N "checking for pthread_attr_init in -lpthread... $ECHO_C" >&6 if test "${ac_cv_lib_pthread_pthread_attr_init+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char pthread_attr_init (); int main () { pthread_attr_init (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_pthread_pthread_attr_init=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_pthread_pthread_attr_init=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_pthread_attr_init" >&5 echo "${ECHO_T}$ac_cv_lib_pthread_pthread_attr_init" >&6 if test $ac_cv_lib_pthread_pthread_attr_init = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_PTHREADS 1 _ACEOF THREADLIB="-lpthread" THREADDEF="-D_REENTRANT" else echo "Old DEC threads:" echo "$as_me:$LINENO: checking for pthread_attr_create in -lpthreads" >&5 echo $ECHO_N "checking for pthread_attr_create in -lpthreads... $ECHO_C" >&6 if test "${ac_cv_lib_pthreads_pthread_attr_create+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthreads $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char pthread_attr_create (); int main () { pthread_attr_create (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_pthreads_pthread_attr_create=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_pthreads_pthread_attr_create=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_pthreads_pthread_attr_create" >&5 echo "${ECHO_T}$ac_cv_lib_pthreads_pthread_attr_create" >&6 if test $ac_cv_lib_pthreads_pthread_attr_create = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_DECTHREADS 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define HAVE_PTHREADS 1 _ACEOF THREADLIB="-lpthreads" else with_server="no"; echo "*** The server would not be able to run" fi fi else # for Windows we use a compatibility library, slightly different name echo "Testing for windows compatible pthreads" as_ac_Lib=`echo "ac_cv_lib_${WINTHREAD}''_pthread_attr_init" | $as_tr_sh` echo "$as_me:$LINENO: checking for pthread_attr_init in -l${WINTHREAD}" >&5 echo $ECHO_N "checking for pthread_attr_init in -l${WINTHREAD}... $ECHO_C" >&6 if eval "test \"\${$as_ac_Lib+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-l${WINTHREAD} $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char pthread_attr_init (); int main () { pthread_attr_init (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_Lib=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Lib=no" fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Lib'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Lib'}'`" >&6 if test `eval echo '${'$as_ac_Lib'}'` = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_PTHREADS 1 _ACEOF THREADLIB="-l${WINTHREAD}" THREADDEF="" else with_server="no"; echo "*** The server would not be able to run" fi fi # LIBS="$THREADLIB $LIBS" CPPFLAGS="$THREADDEF $CPPFLAGS" fi if test "$with_sysv_ipc" != "no" then echo "$as_me:$LINENO: checking for ftok" >&5 echo $ECHO_N "checking for ftok... $ECHO_C" >&6 if test "${ac_cv_func_ftok+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define ftok to an innocuous variant, in case declares ftok. For example, HP-UX 11i declares gettimeofday. */ #define ftok innocuous_ftok /* System header to define __stub macros and hopefully few prototypes, which can conflict with char ftok (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef ftok /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char ftok (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_ftok) || defined (__stub___ftok) choke me #else char (*f) () = ftok; #endif #ifdef __cplusplus } #endif int main () { return f != ftok; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_ftok=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_ftok=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_ftok" >&5 echo "${ECHO_T}$ac_cv_func_ftok" >&6 if test $ac_cv_func_ftok = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_SYSV_IPC 1 _ACEOF else with_sysv_ipc='no' fi CPPFLAGS="$SYSVDEF $CPPFLAGS" fi if test "$with_posix_ipc" != "no" then POSIX_IPC_LIB='' echo "$as_me:$LINENO: checking for shm_open in -lrt" >&5 echo $ECHO_N "checking for shm_open in -lrt... $ECHO_C" >&6 if test "${ac_cv_lib_rt_shm_open+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lrt $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char shm_open (); int main () { shm_open (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_rt_shm_open=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_rt_shm_open=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_rt_shm_open" >&5 echo "${ECHO_T}$ac_cv_lib_rt_shm_open" >&6 if test $ac_cv_lib_rt_shm_open = yes; then SAVELIBS=$LIBS LIBS="$LIBS -lrt" $ECHO -n "checking if the POSIX semaphores actually work... " if test "$cross_compiling" = yes; then echo "no (cross-compiling)" POSIX_IPC_LIB="" with_posix_ipc=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include #include #include #ifdef Solaris #define TESTPATH "/px_ipc_test" #else #define TESTPATH "/tmp/px_ipc_test" #endif int main() { sem_t *sem; int err; fputs("testpath = " TESTPATH, stderr); sem=sem_open(TESTPATH, O_RDWR | O_CREAT, 0600,0); if (sem == SEM_FAILED) { perror("semtest, sem_open failed:"); exit(1); } if ((err = sem_close(sem)) != 0) { perror("semtest, sem_close failed:"); return(err); } if ((err = sem_unlink(TESTPATH)) != 0) { perror("semtest, sem_unlink failed:"); } return(err); } _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then echo "yes" cat >>confdefs.h <<\_ACEOF #define HAVE_POSIX_IPC 1 _ACEOF POSIX_IPC_LIB="-lrt" else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) echo "no" POSIX_IPC_LIB="" with_posix_ipc=no fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi LIBS=$SAVELIBS else with_posix_ipc=no fi fi if test "$with_magick" != "no" then MAGICKLIB='' # check if we can find the configuration utility # Extract the first word of "Magick-config", so it can be a program name with args. set dummy Magick-config; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_HAVE_MAGICK_CONFIG+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$HAVE_MAGICK_CONFIG"; then ac_cv_prog_HAVE_MAGICK_CONFIG="$HAVE_MAGICK_CONFIG" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_HAVE_MAGICK_CONFIG=""yes"" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done test -z "$ac_cv_prog_HAVE_MAGICK_CONFIG" && ac_cv_prog_HAVE_MAGICK_CONFIG=""no"" fi fi HAVE_MAGICK_CONFIG=$ac_cv_prog_HAVE_MAGICK_CONFIG if test -n "$HAVE_MAGICK_CONFIG"; then echo "$as_me:$LINENO: result: $HAVE_MAGICK_CONFIG" >&5 echo "${ECHO_T}$HAVE_MAGICK_CONFIG" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi if test "$HAVE_MAGICK_CONFIG" != "no" then # verify that Magick associated libraries are not incompatible if test "$have_x" != "yes" -a "`Magick-config --libs | grep X11`" != "" ; then # conflict echo "Magick library conflicts with requested absence of X11 library usage" with_magick=no else # this might turn really ugly CPPFLAGS="$CPPFLAGS "`Magick-config --cppflags` LDFLAGS="$LDFLAGS "`Magick-config --ldflags` IMLIBS="$IMLIBS "`Magick-config --libs` # we are not finished: we must check we have the correct version echo "$as_me:$LINENO: checking for DispatchImage in -lMagick" >&5 echo $ECHO_N "checking for DispatchImage in -lMagick... $ECHO_C" >&6 if test "${ac_cv_lib_Magick_DispatchImage+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lMagick $IMLIBS $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char DispatchImage (); int main () { DispatchImage (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_Magick_DispatchImage=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_Magick_DispatchImage=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_Magick_DispatchImage" >&5 echo "${ECHO_T}$ac_cv_lib_Magick_DispatchImage" >&6 if test $ac_cv_lib_Magick_DispatchImage = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_MAGICK 1 _ACEOF MAGICKLIB=" -lMagick" else MAGICKLIB="" fi if test "$MAGICKLIB" != " -lMagick" ; then echo "Magick library found, but version is incorrect, we need version 5.x ; 6.x is not supported at this stage." with_magick="no" else # check if ImageMagick uses the new exception structure echo "$as_me:$LINENO: checking whether ImageMagick uses the new exception structure" >&5 echo $ECHO_N "checking whether ImageMagick uses the new exception structure... $ECHO_C" >&6 if test "${ac_cv_magick_reason+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { ExceptionInfo exception; MagickWarning(exception.severity,exception.reason,exception.description); return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_magick_reason=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_magick_reason=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_magick_reason" >&5 echo "${ECHO_T}$ac_cv_magick_reason" >&6 if test "$ac_cv_magick_reason" = yes ; then cat >>confdefs.h <<\_ACEOF #define MAGICK_USES_REASON _ACEOF fi # check if ImageMagick uses InitMagick now echo "$as_me:$LINENO: checking whether ImageMagick uses InitializeMagick" >&5 echo $ECHO_N "checking whether ImageMagick uses InitializeMagick... $ECHO_C" >&6 if test "${ac_cv_magick_init+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { InitializeMagick(NULL); return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_magick_init=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_magick_init=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_magick_init" >&5 echo "${ECHO_T}$ac_cv_magick_init" >&6 if test "$ac_cv_magick_init" = yes ; then cat >>confdefs.h <<\_ACEOF #define MAGICK_USES_INIT _ACEOF fi # check if some extra arguments are required echo "$as_me:$LINENO: checking whether ImageMagick passes around an extra exception reference all over the place" >&5 echo $ECHO_N "checking whether ImageMagick passes around an extra exception reference all over the place... $ECHO_C" >&6 if test "${ac_cv_magick_needs_more_exception+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=cc ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { ExceptionInfo exception; Image *image; IsGrayImage(image, &exception); return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_magick_needs_more_exception=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_magick_needs_more_exception=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_magick_needs_more_exception" >&5 echo "${ECHO_T}$ac_cv_magick_needs_more_exception" >&6 if test "$ac_cv_magick_needs_more_exception" = yes ; then cat >>confdefs.h <<\_ACEOF #define MAGICK_NEEDS_MORE_EXCEPTION _ACEOF fi fi fi else echo "*** Magick-config not found in path!" with_magick="no" fi fi # ZLIB is not an option, required by some libraries ZLIB="" echo "$as_me:$LINENO: checking for gzopen in -lz" >&5 echo $ECHO_N "checking for gzopen in -lz... $ECHO_C" >&6 if test "${ac_cv_lib_z_gzopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lz $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gzopen (); int main () { gzopen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_z_gzopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_z_gzopen=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzopen" >&5 echo "${ECHO_T}$ac_cv_lib_z_gzopen" >&6 if test $ac_cv_lib_z_gzopen = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_LIBZ 1 _ACEOF ZLIB=" -lz" fi if test "$ZLIB" == "" then ## second chance echo "$as_me:$LINENO: checking for gzopen in -lfltk_z" >&5 echo $ECHO_N "checking for gzopen in -lfltk_z... $ECHO_C" >&6 if test "${ac_cv_lib_fltk_z_gzopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lfltk_z $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gzopen (); int main () { gzopen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_fltk_z_gzopen=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_fltk_z_gzopen=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_fltk_z_gzopen" >&5 echo "${ECHO_T}$ac_cv_lib_fltk_z_gzopen" >&6 if test $ac_cv_lib_fltk_z_gzopen = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_LIBZ 1 _ACEOF ZLIB=" -lfltk_z" fi fi if test "$with_jpeg" != "no" then JPEGLIB='' if test "$fltk_image_name" != "" then echo "$as_me:$LINENO: checking for jpeg_write_raw_data in -ljpeg" >&5 echo $ECHO_N "checking for jpeg_write_raw_data in -ljpeg... $ECHO_C" >&6 if test "${ac_cv_lib_jpeg_jpeg_write_raw_data+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ljpeg $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char jpeg_write_raw_data (); int main () { jpeg_write_raw_data (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_jpeg_jpeg_write_raw_data=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_jpeg_jpeg_write_raw_data=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_jpeg_jpeg_write_raw_data" >&5 echo "${ECHO_T}$ac_cv_lib_jpeg_jpeg_write_raw_data" >&6 if test $ac_cv_lib_jpeg_jpeg_write_raw_data = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_JPEG 1 _ACEOF JPEGLIB=" -ljpeg" else with_jpeg=no fi else # jpeg is normally compiled with the images libs echo "$as_me:$LINENO: checking for jpeg_write_raw_data in -lfltk_jpeg" >&5 echo $ECHO_N "checking for jpeg_write_raw_data in -lfltk_jpeg... $ECHO_C" >&6 if test "${ac_cv_lib_fltk_jpeg_jpeg_write_raw_data+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lfltk_jpeg $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char jpeg_write_raw_data (); int main () { jpeg_write_raw_data (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_fltk_jpeg_jpeg_write_raw_data=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_fltk_jpeg_jpeg_write_raw_data=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_fltk_jpeg_jpeg_write_raw_data" >&5 echo "${ECHO_T}$ac_cv_lib_fltk_jpeg_jpeg_write_raw_data" >&6 if test $ac_cv_lib_fltk_jpeg_jpeg_write_raw_data = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_JPEG 1 _ACEOF JPEGLIB=" -lfltk_jpeg" else echo "$as_me:$LINENO: checking for jpeg_write_raw_data in -ljpeg" >&5 echo $ECHO_N "checking for jpeg_write_raw_data in -ljpeg... $ECHO_C" >&6 if test "${ac_cv_lib_jpeg_jpeg_write_raw_data+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ljpeg $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char jpeg_write_raw_data (); int main () { jpeg_write_raw_data (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_jpeg_jpeg_write_raw_data=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_jpeg_jpeg_write_raw_data=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_jpeg_jpeg_write_raw_data" >&5 echo "${ECHO_T}$ac_cv_lib_jpeg_jpeg_write_raw_data" >&6 if test $ac_cv_lib_jpeg_jpeg_write_raw_data = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_JPEG 1 _ACEOF JPEGLIB=" -ljpeg" else with_jpeg=no fi fi fi fi if test "$with_tiff" != "no" then TIFFLIB='' echo "$as_me:$LINENO: checking for TIFFClose in -ltiff" >&5 echo $ECHO_N "checking for TIFFClose in -ltiff... $ECHO_C" >&6 if test "${ac_cv_lib_tiff_TIFFClose+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ltiff ${JPEGLIB} ${ZLIB} $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char TIFFClose (); int main () { TIFFClose (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_tiff_TIFFClose=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_tiff_TIFFClose=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_tiff_TIFFClose" >&5 echo "${ECHO_T}$ac_cv_lib_tiff_TIFFClose" >&6 if test $ac_cv_lib_tiff_TIFFClose = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_TIFF 1 _ACEOF TIFFLIB=" -ltiff" else with_tiff=no fi fi if test "$with_pink" != "no" then cat >>confdefs.h <<\_ACEOF #define HAVE_PINK_PGM_EXTENSIONS 1 _ACEOF fi if test "$with_native_chooser" != "no" then if test "${ac_cv_header_FL_Fl_Native_File_Chooser_H+set}" = set; then echo "$as_me:$LINENO: checking for FL/Fl_Native_File_Chooser.H" >&5 echo $ECHO_N "checking for FL/Fl_Native_File_Chooser.H... $ECHO_C" >&6 if test "${ac_cv_header_FL_Fl_Native_File_Chooser_H+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: $ac_cv_header_FL_Fl_Native_File_Chooser_H" >&5 echo "${ECHO_T}$ac_cv_header_FL_Fl_Native_File_Chooser_H" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking FL/Fl_Native_File_Chooser.H usability" >&5 echo $ECHO_N "checking FL/Fl_Native_File_Chooser.H usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking FL/Fl_Native_File_Chooser.H presence" >&5 echo $ECHO_N "checking FL/Fl_Native_File_Chooser.H presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: FL/Fl_Native_File_Chooser.H: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: FL/Fl_Native_File_Chooser.H: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: FL/Fl_Native_File_Chooser.H: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: FL/Fl_Native_File_Chooser.H: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: FL/Fl_Native_File_Chooser.H: present but cannot be compiled" >&5 echo "$as_me: WARNING: FL/Fl_Native_File_Chooser.H: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: FL/Fl_Native_File_Chooser.H: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: FL/Fl_Native_File_Chooser.H: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: FL/Fl_Native_File_Chooser.H: see the Autoconf documentation" >&5 echo "$as_me: WARNING: FL/Fl_Native_File_Chooser.H: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: FL/Fl_Native_File_Chooser.H: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: FL/Fl_Native_File_Chooser.H: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: FL/Fl_Native_File_Chooser.H: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: FL/Fl_Native_File_Chooser.H: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: FL/Fl_Native_File_Chooser.H: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: FL/Fl_Native_File_Chooser.H: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------------------ ## ## Report this to the AC_PACKAGE_NAME lists. ## ## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for FL/Fl_Native_File_Chooser.H" >&5 echo $ECHO_N "checking for FL/Fl_Native_File_Chooser.H... $ECHO_C" >&6 if test "${ac_cv_header_FL_Fl_Native_File_Chooser_H+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_FL_Fl_Native_File_Chooser_H=$ac_header_preproc fi echo "$as_me:$LINENO: result: $ac_cv_header_FL_Fl_Native_File_Chooser_H" >&5 echo "${ECHO_T}$ac_cv_header_FL_Fl_Native_File_Chooser_H" >&6 fi if test $ac_cv_header_FL_Fl_Native_File_Chooser_H = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_NATIVE_CHOOSER 1 _ACEOF fi fi # check for libpng as well, this is not a choice at this point, # it may be required by libfltk_image.a PNGLIB='' if test "$ZLIB" != "" then echo "$as_me:$LINENO: checking for png_read_rows in -lpng" >&5 echo $ECHO_N "checking for png_read_rows in -lpng... $ECHO_C" >&6 if test "${ac_cv_lib_png_png_read_rows+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpng ${ZLIB} $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char png_read_rows (); int main () { png_read_rows (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_png_png_read_rows=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_png_png_read_rows=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_png_png_read_rows" >&5 echo "${ECHO_T}$ac_cv_lib_png_png_read_rows" >&6 if test $ac_cv_lib_png_png_read_rows = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_PNG 1 _ACEOF PNGLIB=" -lpng" fi if test "$PNGLIB" == "" then ## second chance echo "$as_me:$LINENO: checking for png_read_rows in -lflt_png" >&5 echo $ECHO_N "checking for png_read_rows in -lflt_png... $ECHO_C" >&6 if test "${ac_cv_lib_flt_png_png_read_rows+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lflt_png ${ZLIB} $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char png_read_rows (); int main () { png_read_rows (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_flt_png_png_read_rows=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_flt_png_png_read_rows=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_flt_png_png_read_rows" >&5 echo "${ECHO_T}$ac_cv_lib_flt_png_png_read_rows" >&6 if test $ac_cv_lib_flt_png_png_read_rows = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_PNG 1 _ACEOF PNGLIB=" -lfltk_png" fi fi fi IMLIBS="$IMLIBS $TIFFLIB $JPEGLIB $PNGLIB $ZLIB" eval PrefPath="${DATA_DIR}/Imview/" cat >>confdefs.h <<_ACEOF #define PrefPath "$PrefPath" _ACEOF # optional #dnl Replace `main' with a function in -lefence: #AC_CHECK_LIB(efence, main) #AC_CHECK_LIB(gdi32, main) #AC_CHECK_LIB(gen, main) #AC_CHECK_LIB(nsl, main) #AC_CHECK_LIB(pthread32, main) #AC_CHECK_LIB(socket, main) #AC_CHECK_LIB(user32, main) #AC_CHECK_LIB(wsock32, main) # Add '-p' if prof source profiling support enabled if test "$with_prof" = 'yes' then CFLAGS="-p $CFLAGS" LDFLAGS="-p $LDFLAGS" fi # Add '-pg' if gprof source profiling support enabled if test "$with_gprof" = 'yes' then CFLAGS="-pg $CFLAGS" LDFLAGS="-pg $LDFLAGS" fi # Add '-ftest-coverage -fprofile-arcs' if gcov source profiling support enabled # This is a gcc-specific feature if test "$with_gcov" = 'yes' then CFLAGS="-ftest-coverage -fprofile-arcs $CFLAGS" LDFLAGS="-ftest-coverage -fprofile-arcs $LDFLAGS" fi # use double-buffering? if test "$with_dblbuf" = 'yes' then cat >>confdefs.h <<\_ACEOF #define IMVIEW_USES_DBLBUF 1 _ACEOF fi #dnl For these we go back to using the C language, as c++ 2.95 has become way too picky #dnl #AC_LANG_C #AC_C_INLINE this is creating more problem than it is solving echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi for ac_header in fcntl.h limits.h malloc.h sys/time.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6 # Is the header present? echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag ac_cpp_err=$ac_cpp_err$ac_c_werror_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6 # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ( cat <<\_ASBOX ## ------------------------------------------ ## ## Report this to the AC_PACKAGE_NAME lists. ## ## ------------------------------------------ ## _ASBOX ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 if test "${ac_cv_c_const+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset x; /* SunOS 4.1.1 cc rejects this. */ char const *const *ccp; char **p; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; ccp = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++ccp; p = (char**) ccp; ccp = (char const *const *) p; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; } #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_c_const=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_const=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 echo "${ECHO_T}$ac_cv_c_const" >&6 if test $ac_cv_c_const = no; then cat >>confdefs.h <<\_ACEOF #define const _ACEOF fi echo "$as_me:$LINENO: checking for size_t" >&5 echo $ECHO_N "checking for size_t... $ECHO_C" >&6 if test "${ac_cv_type_size_t+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { if ((size_t *) 0) return 0; if (sizeof (size_t)) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_size_t=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_size_t=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 echo "${ECHO_T}$ac_cv_type_size_t" >&6 if test $ac_cv_type_size_t = yes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned _ACEOF fi echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6 if test "${ac_cv_header_time+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_header_time=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_time=no fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 echo "${ECHO_T}$ac_cv_header_time" >&6 if test $ac_cv_header_time = yes; then cat >>confdefs.h <<\_ACEOF #define TIME_WITH_SYS_TIME 1 _ACEOF fi echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5 echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6 if test "${ac_cv_struct_tm+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { struct tm *tp; tp->tm_sec; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_struct_tm=time.h else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_struct_tm=sys/time.h fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5 echo "${ECHO_T}$ac_cv_struct_tm" >&6 if test $ac_cv_struct_tm = sys/time.h; then cat >>confdefs.h <<\_ACEOF #define TM_IN_SYS_TIME 1 _ACEOF fi #AC_FUNC_SETVBUF_REVERSED echo "$as_me:$LINENO: checking return type of signal handlers" >&5 echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6 if test "${ac_cv_type_signal+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #ifdef signal # undef signal #endif #ifdef __cplusplus extern "C" void (*signal (int, void (*)(int)))(int); #else void (*signal ()) (); #endif int main () { int i; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_type_signal=void else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_signal=int fi rm -f conftest.err conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 echo "${ECHO_T}$ac_cv_type_signal" >&6 cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF for ac_func in vprintf do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else char (*f) () = $ac_func; #endif #ifdef __cplusplus } #endif int main () { return f != $ac_func; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF echo "$as_me:$LINENO: checking for _doprnt" >&5 echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6 if test "${ac_cv_func__doprnt+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define _doprnt to an innocuous variant, in case declares _doprnt. For example, HP-UX 11i declares gettimeofday. */ #define _doprnt innocuous__doprnt /* System header to define __stub macros and hopefully few prototypes, which can conflict with char _doprnt (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef _doprnt /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char _doprnt (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub__doprnt) || defined (__stub____doprnt) choke me #else char (*f) () = _doprnt; #endif #ifdef __cplusplus } #endif int main () { return f != _doprnt; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func__doprnt=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func__doprnt=no fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 echo "${ECHO_T}$ac_cv_func__doprnt" >&6 if test $ac_cv_func__doprnt = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_DOPRNT 1 _ACEOF fi fi done for ac_func in select socket do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else char (*f) () = $ac_func; #endif #ifdef __cplusplus } #endif int main () { return f != $ac_func; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in getcwd strdup strerror strstr strtol uname do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" { #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else char (*f) () = $ac_func; #endif #ifdef __cplusplus } #endif int main () { return f != $ac_func; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done ac_config_files="$ac_config_files fluid/Makefile server/Makefile io/Makefile Makefile imview.list" ac_config_commands="$ac_config_commands default" test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/; s/:*\${srcdir}:*/:/; s/:*@srcdir@:*/:/; s/^\([^=]*=[ ]*\):*/\1/; s/:*$//; s/^[^=]*=[ ]*$//; }' fi DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_i=`echo "$ac_i" | sed 's/\$U\././;s/\.o$//;s/\.obj$//'` # 2. Add them. ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi DUALCASE=1; export DUALCASE # for MKS sh # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # Work around bugs in pre-3.0 UWIN ksh. $as_unset ENV MAIL MAILPATH PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH exec 6>&1 # Open the log real soon, to keep \$[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. Logging --version etc. is OK. exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX } >&5 cat >&5 <<_CSEOF This file was extended by $as_me, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ _CSEOF echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 echo >&5 _ACEOF # Files that config.status was made for. if test -n "$ac_config_files"; then echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS fi if test -n "$ac_config_headers"; then echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS fi if test -n "$ac_config_links"; then echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS fi if test -n "$ac_config_commands"; then echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS fi cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2003 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." srcdir=$srcdir INSTALL="$INSTALL" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "x$1" : 'x\([^=]*\)='` ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` ac_shift=: ;; -*) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; *) # This is not an option, so the user has probably given explicit # arguments. ac_option=$1 ac_need_defaults=false;; esac case $ac_option in # Handling of the options. _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --vers* | -V ) echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header { { echo "$as_me:$LINENO: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_config_target in $ac_config_targets do case "$ac_config_target" in # Handling of arguments. "fluid/Makefile" ) CONFIG_FILES="$CONFIG_FILES fluid/Makefile" ;; "server/Makefile" ) CONFIG_FILES="$CONFIG_FILES server/Makefile" ;; "io/Makefile" ) CONFIG_FILES="$CONFIG_FILES io/Makefile" ;; "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "imview.list" ) CONFIG_FILES="$CONFIG_FILES imview.list" ;; "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; "imcfg.h" ) CONFIG_HEADERS="$CONFIG_HEADERS imcfg.h" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason to put it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Create a temporary directory, and hook for its removal unless debugging. $debug || { trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./confstat$$-$RANDOM (umask 077 && mkdir $tmp) } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # # CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "\$CONFIG_FILES"; then # Protect against being on the right side of a sed subst in config.status. sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF s,@SHELL@,$SHELL,;t t s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t s,@exec_prefix@,$exec_prefix,;t t s,@prefix@,$prefix,;t t s,@program_transform_name@,$program_transform_name,;t t s,@bindir@,$bindir,;t t s,@sbindir@,$sbindir,;t t s,@libexecdir@,$libexecdir,;t t s,@datadir@,$datadir,;t t s,@sysconfdir@,$sysconfdir,;t t s,@sharedstatedir@,$sharedstatedir,;t t s,@localstatedir@,$localstatedir,;t t s,@libdir@,$libdir,;t t s,@includedir@,$includedir,;t t s,@oldincludedir@,$oldincludedir,;t t s,@infodir@,$infodir,;t t s,@mandir@,$mandir,;t t s,@build_alias@,$build_alias,;t t s,@host_alias@,$host_alias,;t t s,@target_alias@,$target_alias,;t t s,@DEFS@,$DEFS,;t t s,@ECHO_C@,$ECHO_C,;t t s,@ECHO_N@,$ECHO_N,;t t s,@ECHO_T@,$ECHO_T,;t t s,@LIBS@,$LIBS,;t t s,@build@,$build,;t t s,@build_cpu@,$build_cpu,;t t s,@build_vendor@,$build_vendor,;t t s,@build_os@,$build_os,;t t s,@host@,$host,;t t s,@host_cpu@,$host_cpu,;t t s,@host_vendor@,$host_vendor,;t t s,@host_os@,$host_os,;t t s,@target@,$target,;t t s,@target_cpu@,$target_cpu,;t t s,@target_vendor@,$target_vendor,;t t s,@target_os@,$target_os,;t t s,@MAJOR_VERSION@,$MAJOR_VERSION,;t t s,@MINOR_VERSION@,$MINOR_VERSION,;t t s,@MICRO_VERSION@,$MICRO_VERSION,;t t s,@BRANCH_TAG@,$BRANCH_TAG,;t t s,@have_fltk_config@,$have_fltk_config,;t t s,@FLTK_CONFIG@,$FLTK_CONFIG,;t t s,@CP@,$CP,;t t s,@MV@,$MV,;t t s,@EEXT@,$EEXT,;t t s,@CXX@,$CXX,;t t s,@CXXFLAGS@,$CXXFLAGS,;t t s,@LDFLAGS@,$LDFLAGS,;t t s,@CPPFLAGS@,$CPPFLAGS,;t t s,@ac_ct_CXX@,$ac_ct_CXX,;t t s,@EXEEXT@,$EXEEXT,;t t s,@OBJEXT@,$OBJEXT,;t t s,@CC@,$CC,;t t s,@CFLAGS@,$CFLAGS,;t t s,@ac_ct_CC@,$ac_ct_CC,;t t s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t s,@INSTALL_DATA@,$INSTALL_DATA,;t t s,@RANLIB@,$RANLIB,;t t s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t s,@SET_MAKE@,$SET_MAKE,;t t s,@CPP@,$CPP,;t t s,@EGREP@,$EGREP,;t t s,@X_CFLAGS@,$X_CFLAGS,;t t s,@X_PRE_LIBS@,$X_PRE_LIBS,;t t s,@X_LIBS@,$X_LIBS,;t t s,@X_EXTRA_LIBS@,$X_EXTRA_LIBS,;t t s,@XLIBS@,$XLIBS,;t t s,@LIBXTRA@,$LIBXTRA,;t t s,@MATHLIB@,$MATHLIB,;t t s,@FLUID@,$FLUID,;t t s,@FLTKLIB@,$FLTKLIB,;t t s,@FLTKEXTRA@,$FLTKEXTRA,;t t s,@THREADLIB@,$THREADLIB,;t t s,@POSIX_IPC_LIB@,$POSIX_IPC_LIB,;t t s,@HAVE_MAGICK_CONFIG@,$HAVE_MAGICK_CONFIG,;t t s,@JPEGLIB@,$JPEGLIB,;t t s,@TIFFLIB@,$TIFFLIB,;t t s,@PNGLIB@,$PNGLIB,;t t s,@IMLIBS@,$IMLIBS,;t t s,@LIBCOMMAND@,$LIBCOMMAND,;t t s,@MAKEDEPEND@,$MAKEDEPEND,;t t s,@LIBOBJS@,$LIBOBJS,;t t s,@LTLIBOBJS@,$LTLIBOBJS,;t t CEOF _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_lines=48 ac_sed_frag=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_lines # Line after last line for current file. ac_more_lines=: ac_sed_cmds= while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag else sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag fi if test ! -s $tmp/subs.frag; then ac_more_lines=false else # The purpose of the label and of the branching condition is to # speed up the sed processing (if there are no `@' at all, there # is no need to browse any of the substitutions). # These are the two extra sed commands mentioned above. (echo ':t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" else ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" fi ac_sed_frag=`expr $ac_sed_frag + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_lines` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi fi # test -n "$CONFIG_FILES" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { if $as_mkdir_p; then mkdir -p "$ac_dir" else as_dir="$ac_dir" as_dirs= while test ! -d "$as_dir"; do as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` done test ! -n "$as_dirs" || mkdir $as_dirs fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Do not use `cd foo && pwd` to compute absolute paths, because # the directories may not exist. case `pwd` in .) ac_abs_builddir="$ac_dir";; *) case "$ac_dir" in .) ac_abs_builddir=`pwd`;; [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; *) ac_abs_builddir=`pwd`/"$ac_dir";; esac;; esac case $ac_abs_builddir in .) ac_abs_top_builddir=${ac_top_builddir}.;; *) case ${ac_top_builddir}. in .) ac_abs_top_builddir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; esac;; esac case $ac_abs_builddir in .) ac_abs_srcdir=$ac_srcdir;; *) case $ac_srcdir in .) ac_abs_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; esac;; esac case $ac_abs_builddir in .) ac_abs_top_srcdir=$ac_top_srcdir;; *) case $ac_top_srcdir in .) ac_abs_top_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; esac;; esac case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac if test x"$ac_file" != x-; then { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ if test x"$ac_file" = x-; then configure_input= else configure_input="$ac_file. " fi configure_input=$configure_input"Generated from `echo $ac_file_in | sed 's,.*/,,'` by configure." # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo "$f";; *) # Relative if test -f "$f"; then # Build tree echo "$f" elif test -f "$srcdir/$f"; then # Source tree echo "$srcdir/$f" else # /dev/null tree { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s,@configure_input@,$configure_input,;t t s,@srcdir@,$ac_srcdir,;t t s,@abs_srcdir@,$ac_abs_srcdir,;t t s,@top_srcdir@,$ac_top_srcdir,;t t s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t s,@builddir@,$ac_builddir,;t t s,@abs_builddir@,$ac_abs_builddir,;t t s,@top_builddir@,$ac_top_builddir,;t t s,@abs_top_builddir@,$ac_abs_top_builddir,;t t s,@INSTALL@,$ac_INSTALL,;t t " $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out rm -f $tmp/stdin if test x"$ac_file" != x-; then mv $tmp/out $ac_file else cat $tmp/out rm -f $tmp/out fi done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # # CONFIG_HEADER section. # # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='[ ].*$,\1#\2' ac_dC=' ' ac_dD=',;t' # ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='$,\1#\2define\3' ac_uC=' ' ac_uD=',;t' for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } # Do quote $f, to prevent DOS paths from being IFS'd. echo "$f";; *) # Relative if test -f "$f"; then # Build tree echo "$f" elif test -f "$srcdir/$f"; then # Source tree echo "$srcdir/$f" else # /dev/null tree { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } # Remove the trailing spaces. sed 's/[ ]*$//' $ac_file_inputs >$tmp/in _ACEOF # Transform confdefs.h into two sed scripts, `conftest.defines' and # `conftest.undefs', that substitutes the proper values into # config.h.in to produce config.h. The first handles `#define' # templates, and the second `#undef' templates. # And first: Protect against being on the right side of a sed subst in # config.status. Protect against being in an unquoted here document # in config.status. rm -f conftest.defines conftest.undefs # Using a here document instead of a string reduces the quoting nightmare. # Putting comments in sed scripts is not portable. # # `end' is used to avoid that the second main sed command (meant for # 0-ary CPP macros) applies to n-ary macro definitions. # See the Autoconf documentation for `clear'. cat >confdef2sed.sed <<\_ACEOF s/[\\&,]/\\&/g s,[\\$`],\\&,g t clear : clear s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp t end s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp : end _ACEOF # If some macros were called several times there might be several times # the same #defines, which is useless. Nevertheless, we may not want to # sort them, since we want the *last* AC-DEFINE to be honored. uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs rm -f confdef2sed.sed # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >>conftest.undefs <<\_ACEOF s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, _ACEOF # Break up conftest.defines because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS echo ' :' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.defines >/dev/null do # Write a limited-size here document to $tmp/defines.sed. echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#define' lines. echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/defines.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines echo ' fi # grep' >>$CONFIG_STATUS echo >>$CONFIG_STATUS # Break up conftest.undefs because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #undef templates' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.undefs >/dev/null do # Write a limited-size here document to $tmp/undefs.sed. echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#undef' echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/undefs.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail rm -f conftest.undefs mv conftest.tail conftest.undefs done rm -f conftest.undefs cat >>$CONFIG_STATUS <<\_ACEOF # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ if test x"$ac_file" = x-; then echo "/* Generated by configure. */" >$tmp/config.h else echo "/* $ac_file. Generated by configure. */" >$tmp/config.h fi cat $tmp/in >>$tmp/config.h rm -f $tmp/in if test x"$ac_file" != x-; then if diff $ac_file $tmp/config.h >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { if $as_mkdir_p; then mkdir -p "$ac_dir" else as_dir="$ac_dir" as_dirs= while test ! -d "$as_dir"; do as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` done test ! -n "$as_dirs" || mkdir $as_dirs fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } rm -f $ac_file mv $tmp/config.h $ac_file fi else cat $tmp/config.h rm -f $tmp/config.h fi done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # # CONFIG_COMMANDS section. # for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue ac_dest=`echo "$ac_file" | sed 's,:.*,,'` ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_dir=`(dirname "$ac_dest") 2>/dev/null || $as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_dest" : 'X\(//\)[^/]' \| \ X"$ac_dest" : 'X\(//\)$' \| \ X"$ac_dest" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_dest" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { if $as_mkdir_p; then mkdir -p "$ac_dir" else as_dir="$ac_dir" as_dirs= while test ! -d "$as_dir"; do as_dirs="$as_dir $as_dirs" as_dir=`(dirname "$as_dir") 2>/dev/null || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` done test ! -n "$as_dirs" || mkdir $as_dirs fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Do not use `cd foo && pwd` to compute absolute paths, because # the directories may not exist. case `pwd` in .) ac_abs_builddir="$ac_dir";; *) case "$ac_dir" in .) ac_abs_builddir=`pwd`;; [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";; *) ac_abs_builddir=`pwd`/"$ac_dir";; esac;; esac case $ac_abs_builddir in .) ac_abs_top_builddir=${ac_top_builddir}.;; *) case ${ac_top_builddir}. in .) ac_abs_top_builddir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;; *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;; esac;; esac case $ac_abs_builddir in .) ac_abs_srcdir=$ac_srcdir;; *) case $ac_srcdir in .) ac_abs_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;; *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;; esac;; esac case $ac_abs_builddir in .) ac_abs_top_srcdir=$ac_top_srcdir;; *) case $ac_top_srcdir in .) ac_abs_top_srcdir=$ac_abs_builddir;; [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;; *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;; esac;; esac { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 echo "$as_me: executing $ac_dest commands" >&6;} case $ac_dest in default ) echo timestamp > stamp-h ;; esac done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi echo "" echo "Imview is configured as follows. Please verify that this" echo "configuration matches your expectations." echo "" echo "Host system type : $host" echo "Target system : $target" echo "" echo "Option Configure option Configured value" echo "----------------------------------------------------------" echo "System --with-server=$save_server $with_server" echo " --with-sysv-ipc=$save_sysv_ipc $with_sysv_ipc" echo " --with-posix-ipc=$save_posix_ipc $with_posix_ipc" echo "----------------------------------------------------------" echo "Compiling options --with-prof=$save_prof $with_prof" echo " --with-gprof=$save_gprof $with_gprof" echo " --with-gcov=$save_gcov $with_gcov" echo " --enable-debug=$save_debug $with_debug" echo "------------------------------------------------------------" echo "JPEG --with-jpeg=$save_jpeg $with_jpeg" echo "TIFF --with-tiff=$save_tiff $with_tiff" echo "MAGICK --with-magick=$save_magick $with_magick" echo "PINK --with-pink=$save_pink $with_pink" echo "Native Chooser --with-native-chooser=$save_native_chooser $with_native_chooser" echo "" if test "$save_server" != "$with_server" ; then echo "** Warning: Imview cannot be configured with the default server option" fi if test "$save_sysv_ipc" != "$with_sysv_ipc" ; then echo "** Warning: Imview cannot be configured with the default SYSV IPC option" fi if test "$save_posix_ipc" != "$with_posix_ipc" ; then echo "** Warning: Imview cannot be configured with the default POSIX IPC option" if test "$with_sysv_ipc" = "yes" ; then echo "** Warning: But you will be fine with the SYSV IPC, no worries." echo "" fi fi if test "$save_jpeg" != "$with_jpeg" ; then echo "** Warning: Imview cannot be configured with the desired JPEG option" fi if test "$save_tiff" != "$with_tiff" ; then echo "** Warning: Imview cannot be configured with the desired TIFF option" fi if test "$save_magick" != "$with_magick" ; then echo "** Warning: Imview cannot be configured with the desired Magick option" fi if test "$ac_cv_cxx_standard_char_traits" = "no" \ -o "$ac_cv_cxx_default_template_parameters" = "no" \ -o "$ac_cv_cxx_templates_as_template_arguments" = "no" ; then echo "** Warning: Your C++ compiler is not ISO compliant enough," echo "** Warning: this configuration is unsupported." echo "** Warning: See prerequisites in INSTALL file" fi if test "$have_x" = "yes" then echo "" echo "X configuration" echo " X_CFLAGS = $X_CFLAGS" echo " X_PRE_LIBS = $X_PRE_LIBS" echo " X_LIBS = $X_LIBS" echo " X_EXTRA_LIBS = $X_EXTRA_LIBS" fi if test "$have_wingdi" = 'yes' then echo "" echo "GDI configuration" echo " " fi if test "$have_carbon" = 'yes' then echo "" echo "MacOS Carbon configuration" echo " " fi echo "" echo "Final Compilation Flags:" echo " CC = $CC" echo " CXX = $CXX" echo " CFLAGS = $CFLAGS" echo " CXXFLAGS = $CXXFLAGS" echo " CPPFLAGS = $CPPFLAGS" echo " LDFLAGS = $LDFLAGS" echo " LIBRARIES = $FLTKLIB $FLTKEXTRA $IMLIBS $XLIBS $X_EXTRA_LIBS $THREADLIB $POSIX_IPC_LIB $MATHLIB" #echo " LIBS = $LIBS" if test "$ac_cv_cxx_needs_permissive" = 'yes' ; then echo "" echo "**** Warning ***" echo "** Your X11 headers are not compatible with ANSI C++" echo "** Imview should still compile, but you are going to see " echo "** a **LOT** of compilation warnings. The best way to" echo "** avoid this problem is to upgrade your X11 headers to" echo "** a more recent version, or to downgrade your compiler" echo "** to a more lenient one. If your X11 headers are under" echo "** /usr/include/X11, you can also try to upgrade your gcc" echo "** to version 2.95.3 or later" echo "****************" fi echo "" imview-1.1.9c/configure.in0000644000076500007650000007562210745372613016330 0ustar talbottalbot00000000000000dnl dnl dnl Configure file for Imview 1.1.x dnl dnl Imview is hard to configure because is uses a lot of advanced features dnl such as TCP/IP sockets, shared memory & semaphores (sysv and/or posix) dnl threading and a gui system. Moreover it is portable to Win32 in spite dnl of all that, and I need it available on Linux, Solaris, Tru64 and win2k dnl at the very least, and across a relatively wide variety of C++ compilers, dnl a language that keeps evolving. On top of that I like to support cross-compiling dnl of the win32 version from Linux/Unix, for efficiency reasons. In other words dnl this configure.in file is a nightmare. You have been warned! dnl dnl Here are a few gotchas: dnl dnl LIBS is not used at compilation time, only at configure time. dnl all the various optional LIBS are substituted in the makefile in dnl increments (MATHLIB, IMGLIB, etc). dnl dnl Disabling caching dnl I'll want to re-enable it once it all works... (i.e: never Hugues Talbot 8 May 2003) define([AC_CACHE_LOAD], )dnl define([AC_CACHE_SAVE], )dnl dnl Process this file with autoconf to produce a configure script. dnl Any file will do, this is to check that the srcdir is correct AC_INIT(io/cpostscript.cxx) AC_CANONICAL_SYSTEM # generate configure header AC_CONFIG_HEADER(imcfg.h) # the name config.h is used everywhere these days # Set version MAJOR_VERSION=1 MINOR_VERSION=1 MICRO_VERSION=9 # ball is now rolling echo "configuring Imview $MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION" AC_SUBST(MAJOR_VERSION)dnl AC_SUBST(MINOR_VERSION)dnl AC_SUBST(MICRO_VERSION)dnl # Branch tag BRANCH_TAG=rel-1-1-0 echo "Branch $BRANCH_TAG" AC_SUBST(BRANCH_TAG) # start of the real thing # we need the version number, actually AC_DEFINE_UNQUOTED(IMVIEW_MAJOR, $MAJOR_VERSION) AC_DEFINE_UNQUOTED(IMVIEW_MINOR, $MINOR_VERSION) AC_DEFINE_UNQUOTED(IMVIEW_MICRO, $MICRO_VERSION) # # we need the default prefix! # test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' dnl This stuff is hand-generated dnl And heavily pinched from FLTK's autoconf stuff dnl BEGIN Hugues' block #dnl Use C++ as the test language. # AC_LANG_CPLUSPLUS # does not seem to work... #AC_ARG_VAR ($CC," C compiler of choice") #AC_ARG_VAR ($CXX, "C++ compiler of choice") # location of FLTK library AC_ARG_WITH(fltk-dir, [ --with-fltk-dir=[DIR] location of the FLTK distribution directory to use.], [fltk_dist=$withval], [fltk_dist=""]) # Enable prof-based profiling support AC_ARG_ENABLE(prof, [ --enable-prof enable prof source profiling support [default=disable]], [with_prof=$enableval], [with_prof='no']) # Enable gprof-based profiling support AC_ARG_ENABLE(gprof, [ --enable-gprof enable gprof source profiling support [default=disable]], [with_gprof=$enableval], [with_gprof='no']) # Enable gcov-based profiling support AC_ARG_ENABLE(gcov, [ --enable-gcov enable gcov source profiling support [default=disable]], [with_gcov=$enableval], [with_gcov='no']) with_profiling='no' if test "$with_prof" = 'yes' || test "$with_gprof" = 'yes' || test "$with_gcov" = 'yes' then with_profiling='yes' fi # Enable use of double-buffering windows. Doesn't work everywhere yet AC_ARG_ENABLE(dblbuf, [ --enable-dblbuf enable use of double-buffered windows [default=disable]], [with_dblbuf=$enableval], [with_dblbuf='no']) # diverse optional libraries AC_ARG_WITH(jpeg, [ --without-jpeg disable native JPEG support [default=enable]], [with_jpeg=$withval], [with_jpeg='yes']) AC_ARG_WITH(tiff, [ --without-tiff disable native TIFF support [default=enable]], [with_tiff=$withval], [with_tiff='yes']) AC_ARG_WITH(magick, [ --without-magick disable ImageMagick support [default=enable]], [with_magick=$withval], [with_magick='yes']) AC_ARG_WITH(pink, [ --without-pink disable PINK support [default=enable]], [with_pink=$withval], [with_pink='yes']) # the native chooser is MUCH nicer AC_ARG_WITH(native-chooser, [ --without-native-chooser disable experimental native chooser [default=enable]], [with_native_chooser=$withval], [with_native_chooser='yes']) dnl# Clear debugging flags and only enable debugging if the user asks for dnl# it. DEBUGFLAG="" PICFLAG=0 CFLAGS="${CFLAGS:=}" CXXFLAGS="${CXXFLAGS:=}" AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging [default=disable]], \ [with_debug=$enableval], [with_debug='no']) if test "$with_debug" != "no" then # [if eval "test x$enable_debug = xyes"; then DEBUGFLAG="-g " ; fi]) DEBUGFLAG="-g " fi # Enable support for image server AC_ARG_WITH(server, [ --without-server disable image server [default=with]], [with_server=$withval], [with_server='yes']) # enable support for SYSV type shared memory (not shared library!) AC_ARG_WITH(sysv-ipc, [ --without-sysv-ipc disable Unix SYSV shared memory support [default=with]], [with_sysv_ipc=$withval], [with_sysv_ipc='yes']) # enable support for POSIX type shared memory (not shared library!) AC_ARG_WITH(posix-ipc, [ --without-posix-ipc disable Unix POSIX shared memory support [default=with]], [with_posix_ipc=$withval], [with_posix_ipc='yes']) # if server is disabled, so is SYSV and POSIX if test "$with_server" != "yes" ; then with_sysv_ipc="no" with_posix_ipc="no" fi dnl# save the user-definable options, so that the user can check at the end dnl# if they worked! save_prof=$with_prof save_gprof=$with_gprof save_gcov=$with_gcov save_jpeg=$with_jpeg save_tiff=$with_tiff save_magick=$with_magick save_pink=$with_pink save_native_chooser=$with_native_chooser save_debug=$with_debug save_server=$with_server save_sysv_ipc=$with_sysv_ipc save_posix_ipc=$with_posix_ipc save_dblbuf=$with_dblbuf # Evaluate shell variable equivalents to Makefile directory variables eval "eval BIN_DIR=$bindir" eval "eval DATA_DIR=$datadir" eval "eval INCLUDE_DIR=$includedir" eval "eval LIB_DIR=$libdir" srcdirfull=`cd $srcdir && pwd` # so that we also look where the software will be installed (the `local' /usr/local...) LDFLAGS="$LDFLAGS -L$LIB_DIR" CPPFLAGS="$CPPFLAGS -I. " # by default we build for Unix and we need X. have_x="yes" have_carbon="no" # Carbon environment have_wingdi="no" # Windows GDI exec_extension="" # Unix executable are not known by their extention # use the host type LIBXTRA="" # trying for a `standard' echo ECHO=echo # other standard commands CP=/bin/cp MV=/bin/mv #needed to work around a bug in mingw START="" dnl Check for presence of FLTK helper application AC_CHECK_PROG(have_fltk_config, fltk-config, "yes", "no",${fltk_dist}:$PATH) if test "$have_fltk_config" != "yes" then echo "*** Fltk-config was not found!" echo "*** You need to upgrade FLTK to version 1.1.x, exiting" exit 1 fi dnl Find location of FLTK libs & include files, etc if test "$fltk_dist" != "" then dnl User gave location of library to use my_fltk_config=${fltk_dist}/fltk-config fltk_config_name=`$my_fltk_config --libs` # that's pre-installation, no good fltk_cfg_nm=`echo $fltk_config_name | sed 's%.*/lib\(fltk.*\).a%\1%'` # short name still OK fltk_config_name=${fltk_dist}/lib/lib${fltk_cfg_nm}.a fltk_images_name=${fltk_dist}/lib/lib${fltk_cfg_nm}_images.a dnl Extra include flags fltk_include_flags=`$my_fltk_config --use-images --cxxflags` LDFLAGS="-L${fltk_dist}/lib $LDFLAGS" CPPFLAGS="-I${fltk_dist} $fltk_include_flags $CPPFLAGS" FLUID=${START}${fltk_dist}/fluid/fluid dnl no check for library, we trust what the user gave us FLTKLIB=" $fltk_images_name $fltk_config_name" fltklib=fltk # one more hack for the road... This is needed to get the `framework` information on macos LDFLAGS="$LDFLAGS `$my_fltk_config --ldflags`" else dnl Must find out where FLTK is, if present dnl Since we know that we have fltk-config, use it for flags... my_fltk_config=fltk-config fltk_config_name=`$my_fltk_config --libs` # long path fltk_cfg_nm=`echo $fltk_config_name | sed 's%.*/lib\(fltk.*\).a%\1%'` # short name fltk_images_name=`$my_fltk_config --libs | sed 's/\(.*fltk\)\(\.a$\)/\1_images.a/'` dnl extra include flags fltk_include_flags=`$my_fltk_config --use-images --cxxflags` FLUID=${START}fluid dnl Include extra library (FLTK-1.1.x) for handling various image formats. LDFLAGS="$LDFLAGS `$my_fltk_config --use-images --ldstaticflags`" Cppflags="$CPPFLAGS $fltk_include_flags" FLTKLIB="`$my_fltk_config --use-images --ldstaticflags`" fltklib=$fltk_cfg_name fi dnl Are we using X? fltk_x11_ldflags=`$my_fltk_config --ldflags | grep '\-lX11'` if test "$fltk_x11_ldflags" != "" ; then fltk_uses_x11=yes else fltk_uses_x11=no fi FLTK_CONFIG=$my_fltk_config AC_SUBST(FLTK_CONFIG) case $target in *linux*) # our favourite platform :-) CPPFLAGS="-DLinux $CPPFLAGS" ;; *dec-osf*) # Compaq Tru64, aka DEC Unix, aka OSF1 CPPFLAGS="-DOSF1 $CPPFLAGS" ;; *sun-solaris2*) # Sun Solaris. Broken X headers are no fun CPPFLAGS="-DSolaris -D_XOPEN_SOURCE=500 -D__EXTENSIONS__ $CPPFLAGS" # Sun POSIX IPC does not allow paths under /tmp AC_DEFINE(POSIX_IPC_PREFIX, "/") # Solaris /usr/bin/echo does not understand `-n' ECHO=/usr/ucb/echo ;; *pc-mingw32*) # MINGW32. Nothing special, but no X! have_x="no" have_wingdi="yes" exec_extension=".exe" # Windows executable are `.exe' files. CPPFLAGS="$CPPFLAGS -O2" # my compiler doesn't produce correct executable unless optimizing! WINTHREAD="pthreadGC" # use the pthread-win32 without structured exceptions. START="/bin/start " # to be able non-mingw GUI applications like fluid, NOTE: space is important LDFLAGS="$LDFLAGS -mwindows -lole32 -luuid -lcomctl32 -lwsock32 -lsupc++" ;; *i686-pc-cygwin) # MINGW32. Nothing special, but no X! have_x="no" have_wingdi="yes" exec_extension=".exe" # Windows executable are `.exe' files. CPPFLAGS="$CPPFLAGS -O2 -mwin32" # my compiler doesn't produce correct executable unless optimizing! WINTHREAD="pthread" ;; *darwin*) # Mac OS/X echo "*** Oooh, MacOS/X" if test "$fltk_uses_x11" = "no" ; then echo "*** Using Carbon too" have_x="no" # use Carbon instead have_carbon="yes" CPPFLAGS="-DMACOSX_CARBON $CPPFLAGS" else echo "*** Still using X11" fi # assume presence of fink # not sure this is necessary, as we now use fltk-config CPPFLAGS="-DDARWIN -O2 -I/sw/include $CPPFLAGS" LDFLAGS="$LDFLAGS -L/sw/lib" if test "$with_magick" = "yes" ; then echo "Silencing magick warnings at link time" LDFLAGS="$LDFLAGS -Xlinker -multiply_defined -Xlinker suppress" echo "*** You might see a lot of warnings at link time if your version" echo "*** of ImageMagick embeds symbols from various other standard libraries" echo "*** such as libjpeg or libz. This is pretty harmless." fi CP=/Developer/Tools/CpMac MV=/Developer/Tools/MvMac ;; *) echo "*** A platform I haven't tried! Some definitions might be lacking" echo "*** Please contribute your changes if any required." echo "*** mailto: Hugues.Talbot@cmis.CSIRO.AU" ;; esac AC_SUBST(CP) AC_SUBST(MV) EEXT=$exec_extension AC_SUBST(EEXT) dnl Checks for programs. AC_PROG_CXX AC_PROG_CC AC_PROG_INSTALL AC_PROG_RANLIB if test "$RANLIB" != ":"; then LIBCOMMAND="ar cr" else LIBCOMMAND="ar crs" fi AC_PROG_MAKE_SET dnl Find out compiler quirks dnl http://research.cys.de/autoconf-archive AC_CXX_MEMBER_TEMPLATES AC_CXX_TEMPLATE_KEYWORD_QUALIFIER AC_CXX_TEMPLATES_AS_TEMPLATE_ARGUMENTS AC_CXX_DEFAULT_TEMPLATE_PARAMETERS AC_CXX_STD_CHAR_TRAITS dnl home-brewed compiler error detection AC_CXX_TEMPLATE_CAST_ARRAY dnl Checks for header files. AC_HEADER_DIRENT AC_CHECK_HEADER(sys/select.h) AC_CHECK_HEADER(winsock.h) dnl Check for socken_t in accept AC_ACCEPT_USES_SOCKLEN_T AC_CHECK_FUNC(scandir, if test "$uname" = "SunOS"; then echo Not using Solaris scandir BSD emulation function. else AC_DEFINE(HAVE_SCANDIR) fi) AC_CHECK_FUNC(vsnprintf, if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then echo Not using built-in vsnprintf function because you are running HP-UX 10.20. else AC_DEFINE(HAVE_VSNPRINTF) fi) AC_CHECK_FUNC(snprintf, if test "$uname" = "HP-UX" -a "$uversion" = "1020"; then echo Not using built-in snprintf function because you are running HP-UX 10.20. else AC_DEFINE(HAVE_SNPRINTF) fi) AC_CHECK_FUNCS(vsprintf) dnl # checks for a reasonable wait function that takes sub-second argument AC_CHECK_FUNCS(usleep nanosleep) if test "$have_x" = "yes" ; then dnl some headers might be poorly defined, in particular regarding X11 headers and Solaris (things have improved lately) # Check for X AC_PATH_XTRA echo "Ignoring libraries \"$X_PRE_LIBS\" requested by configure." dnl# LIBS="$LIBS$X_LIBS$X_PRE_LIBS" if test "$with_magick" != "no" ; then # this seems to be sufficient somehow # as Magick will include the right libraries and flags already XLIBS="-lX11 -lXext" else # I'm not sure how reliable this is... XLIBS="$X_LIBS -lX11 -lXext" fi # LIBS="$LIBS$X_LIBS" CFLAGS="$CFLAGS $X_CFLAGS" CPPFLAGS="$CPPFLAGS $X_CFLAGS" AC_SUBST(XLIBS) # check for some incorrect X11 headers AC_CXX_X11_HEADER_PERMISSIVE # check for Xinerama AC_X11_HAS_XINERAMA XLIBS="$XLIBS $XINERAMA" fi MAKEDEPEND="\$(CXX) -M" dnl# add warnings to compiler switches: dnl# do this last so messing with switches does not break tests if test -n "$GXX"; then GCC_ACCEPTS_INCLUDE_DIR # this will add -I$INCLUDE_DIR if the compiler does not complain about it. GCC_ACCEPTS_DEPRECATED_HEADERS # this will test if -Wno-deprecated is necessary CFLAGS="-Wall $CFLAGS" # GNU C++ is sometimes missing bits of the STL AC_CXX_STRSTREAM # other bits for g++ CXXFLAGS="-Wall -Wno-return-type -Wno-unknown-pragmas $CXXFLAGS" if test -z "$DEBUGFLAG"; then CFLAGS="-O2 $CFLAGS" CXXFLAGS="-O2 $CXXFLAGS" else CFLAGS="$DEBUGFLAG $CFLAGS" CXXFLAGS="$DEBUGFLAG $CXXFLAGS" fi else case `(uname) 2>/dev/null` in IRIX*) # Running some flavor of IRIX; see which version and # set things up according... if test "$uversion" -ge 62; then # We are running IRIX 6.2 or higher; uncomment the following # lines if you don't have IDO 7.2 or higher: # # CXX="CC -n32" # CC="cc -n32" # LD="ld -n32" # MAKEDEPEND="CC -M" echo "FOR BEST RESULTS BEFORE COMPILING: setenv SGI_ABI -n32" # -woff 3322 is necessary due to errors in Xlib headers on IRIX CFLAGS="-fullwarn $CFLAGS" CXXFLAGS="-fullwarn -woff 1685,3322 $CXXFLAGS" else CXXFLAGS="+w +pp $CXXFLAGS" fi if test -z "$DEBUGFLAG"; then CFLAGS="-O2 $CFLAGS" CXXFLAGS="-O2 $CXXFLAGS" fi ;; HP-UX*) # Running HP-UX; these options should work for the HP compilers. if test -z "$DEBUGFLAG"; then CFLAGS="+O2 $CFLAGS" CXXFLAGS="+O2 +W336,501,736,740,749,829 $CXXFLAGS" fi ;; SunOS*) # Solaris if test -z "$DEBUGFLAG"; then CFLAGS="-O" CXXFLAGS="-O" fi ;; OSF*) # DEC Unix (Compaq silly tru64) if test -z "$DEBUGFLAG"; then CFLAGS="-O2 -Olimit 2000 $CFLAGS" CXXFLAGS="-ttimestamp -O2 -Olimit 2000 $CXXFLAGS" else CFLAGS="$DEBUGFLAG $CFLAGS" CXXFLAGS="$DEBUGFLAG $CXXFLAGS" fi CFLAGS="$CFLAGS -I${prefix}/include" CXXFLAGS="$CXXFLAGS -I${prefix}/include" LIBCOMMAND="/usr/bin/ar cr" # make sure we use the system's archiver. GNU's not compatible with cxx # we need the IOStream library, and we enable ALL the compiler messages CXXFLAGS="-w1 -D__USE_STD_IOSTREAM $CXXFLAGS" # the CXX compiler requires this when using automated template # instantiation. LIBXTRA="cxx_repository/*.o" ;; Linux*) # test for the Intel compiler if test "$CXX" = "icc" ; then if test -z "$DEBUGFLAG"; then CFLAGS="-O2 -w1" CXXFLAGS="-O2" fi else echo "+++ Unknown compiler, using safe optimization flags" if test -z "$DEBUGFLAG"; then CFLAGS="-O" CXXFLAGS="-O" fi fi ;; Darwin*) # Mac OS/X, where cc is really gcc # assume presence of fink ;; *) # Running some other operating system; inform the user they # should contribute the necessary options to fltk-bugs@easysw.com... echo "+++ Untried platform" echo "+++ Building Imview with default compiler flags; contact" echo "+++ hut66au at gmail dot com with uname and compiler options needed" echo "+++ for your platform, or set the CFLAGS and CXXFLAGS options" echo "+++ before running configure." ;; esac fi dnl extra stuff needed by some compilers (such as CXX under DEC Unix, for automated dnl template instanciation, that occurs using the STL) AC_SUBST(LIBXTRA) # # Find math library # MATHLIB='' AC_CHECK_LIB(m,sqrt,MATHLIB=" -lm",,) LIBS="$LIBS $MATHLIB" # -lm is needed almost everywhere AC_SUBST(MATHLIB) dnl These library are problematic? dnl Checks for libraries. dnl We do not use OpenGL, but sometimes fltk may require it. #AC_CHECK_LIB(GL, main) dnl Checking for correct version dnl $ECHO -n "Checking for fltk version: " majorver=`(${FLUID} -o /tmp/toto -c /dev/null ; grep 'version' /tmp/toto | awk '{printf("%.0f\n", $NF)}' )` minorver=`( grep 'version' /tmp/toto | awk '{printf("%0.f\n", ($NF-int($NF)) * 100)}' )` patchver=`( grep 'version' /tmp/toto | awk '{printf("%0.f\n", 100*((($NF-int($NF))*100)-int(($NF-int($NF))*100)))}' )` rm /tmp/toto # clean up if test $majorver -eq 1 -a $minorver -ge 1 then echo "... OK" else echo "" echo "*** Please select FLTK version 1.1.x" echo "*** NOTE that FLTK 2.0 or greater is not supported yet..." echo "*** FLTK 1.0.x is only supported by imview-1.0.x or lesser" exit 1 fi fltk_alt_suff=`echo $CXX | sed 's%/%_%g'` echo "Alternative libfltk name: " libfltk_${fltk_alt_suff}.a echo "Configured libfltk name: " $fltk_config_name AC_SUBST(FLUID) AC_SUBST(FLTKLIB) dnl add extra flags for linking xtra_cflags=`$my_fltk_config --cflags` xtra_ldflags=`$my_fltk_config --ldflags` if test "$have_wingdi" = 'yes' ; then echo "Building for the Windows GDI" CPPFLAGS="$CPPFLAGS ${xtra_cflags}" XLIBS="$XLIBS ${xtra_ldflags}" fi if test "$have_macos" = 'yes' ; then echo "Building for MacOS Carbon environment" XLIBS="$XLIBS -framework Carbon -framework ApplicationServices" fi dnl See if we need the True-Type renderer need_Xft=`$my_fltk_config --ldflags | grep Xft` echo -n "Testing if $fltklib needs True Type rendering" if test "$need_Xft" != "" then echo "... Yes" FLTKEXTRA="$FLTKEXTRA -lXft" else echo "... No" fi AC_SUBST(FLTKEXTRA) dnl PThreads. Very very very useful! dnl Without them, no server! THREADLIB='' if test "$with_server" != 'no' then # Unix if test "$have_x" != "no" -o "$have_carbon" != "no" ; then echo "Testing for Unix threads" echo "Standard Pthreads:" AC_CHECK_LIB(pthread,pthread_attr_init, [AC_DEFINE(HAVE_PTHREADS, 1,Define if you have Posix thread methods.) THREADLIB="-lpthread" THREADDEF="-D_REENTRANT"], echo "Old DEC threads:" AC_CHECK_LIB(pthreads, pthread_attr_create, [AC_DEFINE(HAVE_DECTHREADS, 1,Define if you have DEC unix thread methods, very close to pthreads.) AC_DEFINE(HAVE_PTHREADS, 1, We fake the Pthreads.) THREADLIB="-lpthreads"], with_server="no"; echo "*** The server would not be able to run", ), ) else # for Windows we use a compatibility library, slightly different name echo "Testing for windows compatible pthreads" AC_CHECK_LIB(${WINTHREAD},pthread_attr_init, [AC_DEFINE(HAVE_PTHREADS, 1,Define if you have Posix thread methods.) THREADLIB="-l${WINTHREAD}" THREADDEF=""], with_server="no"; echo "*** The server would not be able to run",) fi # LIBS="$THREADLIB $LIBS" CPPFLAGS="$THREADDEF $CPPFLAGS" fi AC_SUBST(THREADLIB) dnl Check for Unix SYSV shared memory and semaphores IPC. if test "$with_sysv_ipc" != "no" then AC_CHECK_FUNC(ftok, AC_DEFINE(HAVE_SYSV_IPC, 1,Define if you have Unix SYSV IPC.), with_sysv_ipc='no') CPPFLAGS="$SYSVDEF $CPPFLAGS" fi dnl Check for POSIX IPC if test "$with_posix_ipc" != "no" then POSIX_IPC_LIB='' AC_CHECK_LIB(rt,shm_open, [SAVELIBS=$LIBS LIBS="$LIBS -lrt" $ECHO -n "checking if the POSIX semaphores actually work... " AC_TRY_RUN([ #include #include #include #include #include #include #ifdef Solaris #define TESTPATH "/px_ipc_test" #else #define TESTPATH "/tmp/px_ipc_test" #endif int main() { sem_t *sem; int err; fputs("testpath = " TESTPATH, stderr); sem=sem_open(TESTPATH, O_RDWR | O_CREAT, 0600,0); if (sem == SEM_FAILED) { perror("semtest, sem_open failed:"); exit(1); } if ((err = sem_close(sem)) != 0) { perror("semtest, sem_close failed:"); return(err); } if ((err = sem_unlink(TESTPATH)) != 0) { perror("semtest, sem_unlink failed:"); } return(err); } ], [echo "yes" AC_DEFINE(HAVE_POSIX_IPC) POSIX_IPC_LIB="-lrt"], [echo "no" POSIX_IPC_LIB="" with_posix_ipc=no], [echo "no (cross-compiling)" POSIX_IPC_LIB="" with_posix_ipc=no]) LIBS=$SAVELIBS], with_posix_ipc=no) AC_SUBST(POSIX_IPC_LIB) fi dnl ImageMagick is very useful, but optional dnl Moreover the API keeps changing and that's really annoying. if test "$with_magick" != "no" then MAGICKLIB='' # check if we can find the configuration utility AC_CHECK_PROG(HAVE_MAGICK_CONFIG, Magick-config, "yes", "no") if test "$HAVE_MAGICK_CONFIG" != "no" then # verify that Magick associated libraries are not incompatible if test "$have_x" != "yes" -a "`Magick-config --libs | grep X11`" != "" ; then # conflict echo "Magick library conflicts with requested absence of X11 library usage" with_magick=no else # this might turn really ugly CPPFLAGS="$CPPFLAGS "`Magick-config --cppflags` LDFLAGS="$LDFLAGS "`Magick-config --ldflags` IMLIBS="$IMLIBS "`Magick-config --libs` # we are not finished: we must check we have the correct version AC_CHECK_LIB(Magick, DispatchImage, AC_DEFINE(HAVE_MAGICK) MAGICKLIB=" -lMagick", MAGICKLIB="", $IMLIBS) if test "$MAGICKLIB" != " -lMagick" ; then echo "Magick library found, but version is incorrect, we need version 5.x ; 6.x is not supported at this stage." with_magick="no" else # check if ImageMagick uses the new exception structure AC_MAGICK_REASON # check if ImageMagick uses InitMagick now AC_MAGICK_INIT # check if some extra arguments are required AC_MAGICK_NEEDS_MORE_EXCEPTION fi fi else echo "*** Magick-config not found in path!" with_magick="no" fi fi # ZLIB is not an option, required by some libraries ZLIB="" AC_CHECK_LIB(z, gzopen, AC_DEFINE(HAVE_LIBZ) ZLIB=" -lz") if test "$ZLIB" == "" then ## second chance AC_CHECK_LIB(fltk_z, gzopen, AC_DEFINE(HAVE_LIBZ) ZLIB=" -lfltk_z") fi dnl JPEG Library, also optional, maybe needed by Magick if test "$with_jpeg" != "no" then JPEGLIB='' if test "$fltk_image_name" != "" then AC_CHECK_LIB(jpeg, jpeg_write_raw_data, AC_DEFINE(HAVE_JPEG) JPEGLIB=" -ljpeg", with_jpeg=no) else # jpeg is normally compiled with the images libs AC_CHECK_LIB(fltk_jpeg, jpeg_write_raw_data, AC_DEFINE(HAVE_JPEG) JPEGLIB=" -lfltk_jpeg", AC_CHECK_LIB(jpeg, jpeg_write_raw_data, AC_DEFINE(HAVE_JPEG) JPEGLIB=" -ljpeg", with_jpeg=no)) fi AC_SUBST(JPEGLIB) fi dnl TIFF library, you know the deal by now if test "$with_tiff" != "no" then TIFFLIB='' AC_CHECK_LIB(tiff, TIFFClose, AC_DEFINE(HAVE_TIFF) TIFFLIB=" -ltiff", with_tiff=no, ${JPEGLIB} ${ZLIB}) AC_SUBST(TIFFLIB) fi dnl PINK support, requires no library, but the declaration of a Macro if test "$with_pink" != "no" then AC_DEFINE(HAVE_PINK_PGM_EXTENSIONS) fi dnl Native chooser support if test "$with_native_chooser" != "no" then AC_CHECK_HEADER(FL/Fl_Native_File_Chooser.H, AC_DEFINE(HAVE_NATIVE_CHOOSER)) fi # check for libpng as well, this is not a choice at this point, # it may be required by libfltk_image.a PNGLIB='' if test "$ZLIB" != "" then AC_CHECK_LIB(png, png_read_rows, AC_DEFINE(HAVE_PNG) PNGLIB=" -lpng", ,${ZLIB}) if test "$PNGLIB" == "" then ## second chance AC_CHECK_LIB(flt_png, png_read_rows, AC_DEFINE(HAVE_PNG) PNGLIB=" -lfltk_png", ,${ZLIB}) fi AC_SUBST(PNGLIB) fi dnl Create the `image lib' variable IMLIBS="$IMLIBS $TIFFLIB $JPEGLIB $PNGLIB $ZLIB" AC_SUBST(IMLIBS) dnl Installation stuff eval PrefPath="${DATA_DIR}/Imview/" AC_DEFINE_UNQUOTED(PrefPath,"$PrefPath",Define directory where preference and .lut files will live.) # optional #dnl Replace `main' with a function in -lefence: #AC_CHECK_LIB(efence, main) dnl Replace `main' with a function in -lgdi32: #AC_CHECK_LIB(gdi32, main) dnl Replace `main' with a function in -lgen: #AC_CHECK_LIB(gen, main) dnl Replace `main' with a function in -lnsl: #AC_CHECK_LIB(nsl, main) dnl Replace `main' with a function in -lpthread32: #AC_CHECK_LIB(pthread32, main) dnl Replace `main' with a function in -lsocket: #AC_CHECK_LIB(socket, main) dnl Replace `main' with a function in -luser32: #AC_CHECK_LIB(user32, main) dnl Replace `main' with a function in -lwsock32: #AC_CHECK_LIB(wsock32, main) # Add '-p' if prof source profiling support enabled if test "$with_prof" = 'yes' then CFLAGS="-p $CFLAGS" LDFLAGS="-p $LDFLAGS" fi # Add '-pg' if gprof source profiling support enabled if test "$with_gprof" = 'yes' then CFLAGS="-pg $CFLAGS" LDFLAGS="-pg $LDFLAGS" fi # Add '-ftest-coverage -fprofile-arcs' if gcov source profiling support enabled # This is a gcc-specific feature if test "$with_gcov" = 'yes' then CFLAGS="-ftest-coverage -fprofile-arcs $CFLAGS" LDFLAGS="-ftest-coverage -fprofile-arcs $LDFLAGS" fi # use double-buffering? if test "$with_dblbuf" = 'yes' then AC_DEFINE(IMVIEW_USES_DBLBUF) fi #dnl For these we go back to using the C language, as c++ 2.95 has become way too picky #dnl #AC_LANG_C #AC_C_INLINE this is creating more problem than it is solving AC_HEADER_STDC AC_CHECK_HEADERS(fcntl.h limits.h malloc.h sys/time.h unistd.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_SIZE_T AC_HEADER_TIME AC_STRUCT_TM dnl Checks for library functions. #AC_FUNC_SETVBUF_REVERSED AC_TYPE_SIGNAL AC_FUNC_VPRINTF AC_CHECK_FUNCS(select socket) AC_CHECK_FUNCS(getcwd strdup strerror strstr strtol uname) dnl some substitutions AC_SUBST(LIBCOMMAND) AC_SUBST(MAKEDEPEND) AC_OUTPUT(fluid/Makefile server/Makefile io/Makefile Makefile imview.list, echo timestamp > stamp-h) echo "" echo "Imview is configured as follows. Please verify that this" echo "configuration matches your expectations." echo "" echo "Host system type : $host" echo "Target system : $target" echo "" echo "Option Configure option Configured value" echo "----------------------------------------------------------" echo "System --with-server=$save_server $with_server" echo " --with-sysv-ipc=$save_sysv_ipc $with_sysv_ipc" echo " --with-posix-ipc=$save_posix_ipc $with_posix_ipc" echo "----------------------------------------------------------" echo "Compiling options --with-prof=$save_prof $with_prof" echo " --with-gprof=$save_gprof $with_gprof" echo " --with-gcov=$save_gcov $with_gcov" echo " --enable-debug=$save_debug $with_debug" echo "------------------------------------------------------------" echo "JPEG --with-jpeg=$save_jpeg $with_jpeg" echo "TIFF --with-tiff=$save_tiff $with_tiff" echo "MAGICK --with-magick=$save_magick $with_magick" echo "PINK --with-pink=$save_pink $with_pink" echo "Native Chooser --with-native-chooser=$save_native_chooser $with_native_chooser" echo "" if test "$save_server" != "$with_server" ; then echo "** Warning: Imview cannot be configured with the default server option" fi if test "$save_sysv_ipc" != "$with_sysv_ipc" ; then echo "** Warning: Imview cannot be configured with the default SYSV IPC option" fi if test "$save_posix_ipc" != "$with_posix_ipc" ; then echo "** Warning: Imview cannot be configured with the default POSIX IPC option" if test "$with_sysv_ipc" = "yes" ; then echo "** Warning: But you will be fine with the SYSV IPC, no worries." echo "" fi fi if test "$save_jpeg" != "$with_jpeg" ; then echo "** Warning: Imview cannot be configured with the desired JPEG option" fi if test "$save_tiff" != "$with_tiff" ; then echo "** Warning: Imview cannot be configured with the desired TIFF option" fi if test "$save_magick" != "$with_magick" ; then echo "** Warning: Imview cannot be configured with the desired Magick option" fi if test "$ac_cv_cxx_standard_char_traits" = "no" \ -o "$ac_cv_cxx_default_template_parameters" = "no" \ -o "$ac_cv_cxx_templates_as_template_arguments" = "no" ; then echo "** Warning: Your C++ compiler is not ISO compliant enough," echo "** Warning: this configuration is unsupported." echo "** Warning: See prerequisites in INSTALL file" fi if test "$have_x" = "yes" then echo "" echo "X configuration" echo " X_CFLAGS = $X_CFLAGS" echo " X_PRE_LIBS = $X_PRE_LIBS" echo " X_LIBS = $X_LIBS" echo " X_EXTRA_LIBS = $X_EXTRA_LIBS" fi if test "$have_wingdi" = 'yes' then echo "" echo "GDI configuration" echo " " fi if test "$have_carbon" = 'yes' then echo "" echo "MacOS Carbon configuration" echo " " fi echo "" echo "Final Compilation Flags:" echo " CC = $CC" echo " CXX = $CXX" echo " CFLAGS = $CFLAGS" echo " CXXFLAGS = $CXXFLAGS" echo " CPPFLAGS = $CPPFLAGS" echo " LDFLAGS = $LDFLAGS" echo " LIBRARIES = $FLTKLIB $FLTKEXTRA $IMLIBS $XLIBS $X_EXTRA_LIBS $THREADLIB $POSIX_IPC_LIB $MATHLIB" #echo " LIBS = $LIBS" if test "$ac_cv_cxx_needs_permissive" = 'yes' ; then echo "" echo "**** Warning ***" echo "** Your X11 headers are not compatible with ANSI C++" echo "** Imview should still compile, but you are going to see " echo "** a **LOT** of compilation warnings. The best way to" echo "** avoid this problem is to upgrade your X11 headers to" echo "** a more recent version, or to downgrade your compiler" echo "** to a more lenient one. If your X11 headers are under" echo "** /usr/include/X11, you can also try to upgrade your gcc" echo "** to version 2.95.3 or later" echo "****************" fi echo "" dnl The End imview-1.1.9c/CONTRIBUTORS0000644000076500007650000000161110720437041015650 0ustar talbottalbot00000000000000$Id: CONTRIBUTORS,v 4.1 2007/11/20 01:53:37 hut66au Exp $ ============================================================================== Too many ! See the CREDITS file, quoted here : CSIRO Math and Info Sciences Image Analysis and Biotech Imaging former and present staff: Ed Breen - early encouragements and support. Ronald Jones - first user and beta tester. Mark Berman - Frequent requests for improvements, early sponsor as group leader. Angela Johnstone - Agreed to let IMVIEW remain Free Software. Leanne Bischof - Group leader after 1999, continued support for imview. Kevin Cheong - Bug fixes, co-developer on sourceforge. Thanks to the sourceforge staff for their grant of resources. Thanks to all the users who provided feedback and ideas Thanks to all who provided bug reports and patches Thanks to Teemu Ikonen for his work as Debian Maintainer. He makes Imview available to the masses!imview-1.1.9c/COPYING0000644000076500007650000004310507653236446015050 0ustar talbottalbot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy 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 program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. imview-1.1.9c/COPYRIGHT0000644000076500007650000000164010211352053015257 0ustar talbottalbot00000000000000By accepting this notice, you agree to be bound by the following agreements: This software product, IMVIEW, has been developed by Hugues Talbot since 1997, and is copyrighted (C) 1997-2005 by the Australian Commonwealth Scientific and Industrial Research Organisation (CSIRO) with all rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (version 2) as published by the Free Software Foundation. It 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. A copy of the GNU General Public License is available in the file COPYING. If you did not receive it, write to: The Free Software Foundation 59 Temple Place Suite 330 Boston, MA 02111, USA imview-1.1.9c/CREDITS0000644000076500007650000001613610720437041015020 0ustar talbottalbot00000000000000$Id: CREDITS,v 4.2 2007/11/20 01:53:37 hut66au Exp $ ============================================================================== Here is an incomplete list of people who have actively participated in the development of IMVIEW : CSIRO Math and Info Sciences Image Analysis and Biotech Imaging former and present staff: Ed Breen - early encouragements and support. Ronald Jones - first user and beta tester. Mark Berman - Frequent requests for improvements, early sponsor as group leader. Angela Johnstone - Agreed to let IMVIEW remain Free Software. Leanne Bischof - Group leader after 1999, continued support for imview. Kevin Cheong - Bug fixes, co-developer on sourceforge. Thanks to the sourceforge staff for their grant of resources. $Id: CREDITS,v 4.2 2007/11/20 01:53:37 hut66au Exp $ ============================================================================== Too many ! See the CREDITS file, quoted here : CSIRO Math and Info Sciences Image Analysis and Biotech Imaging former and present staff: Ed Breen - early encouragements and support. Ronald Jones - first user and beta tester. Mark Berman - Frequent requests for improvements, early sponsor as group leader. Angela Johnstone - Agreed to let IMVIEW remain Free Software. Leanne Bischof - Group leader after 1999, continued support for imview. Kevin Cheong - Bug fixes, co-developer on sourceforge. Thanks to the sourceforge staff for their grant of resources. Thanks to all the users who provided feedback and ideas Thanks to all who provided bug reports and patches Thanks to Teemu Ikonen for his work as Debian Maintainer. He makes Imview available to the masses! ============================================================================== Here is a list of the contributors to imview and their copyright. HelpView.cxx: HelpView.hxx: // // // Help Viewer widget routines. // // Copyright 1997-2000 by Easy Software Products. // // These coded instructions, statements, and computer programs are the // property of Easy Software Products and are protected by Federal // copyright law. Distribution and use rights are outblockd in the file // "COPYING" which should have been included with this file. If this // file is missing or damaged please contact Easy Software Products // at: // // Attn: ESP Licensing Information // Easy Software Products // 44141 Airport View Drive, Suite 204 // Hollywood, Maryland 20636-3111 USA // // Voice: (301) 373-9600 // EMail: info@easysw.com // WWW: http://www.easysw.com StatusBox.cxx: StatusBox.hxx: /* Copyright (C) 1998 Craig P. Earls 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 program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ io/gnuplot.cxx: /*------------------------------------------------------------------------ * * C++ interface to gnuplot * * By Ed Breen. * * Modified Hugues Talbot 28 Jan 1997 * *-----------------------------------------------------------------------*/ io/ics.h: /************************************************************* FILE : ics.h PURPOSE : Definitions of dataset structure and other stuff for the ICS file format. USAGE : #include "ics.h" DESCRIPTION OF PARAMETERS : AUTHOR : Damir Sudar Copyright (c) University of California San Francisco HISTORY : 3/30/89 created ******************************************************************/ io/readgif.cxx: /* gif2ras.c - Converts from a Compuserve GIF (tm) image to a Sun Raster image. * * Copyright (c) 1988 by Patrick J. Naughton * * Author: Patrick J. Naughton * naughton@wind.sun.com * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation. * */ server/asynchat.cxx: server/asynchat.hxx: server/asyncore.cxx: server/asyncore.hxx: // ====================================================================== // Copyright 1996 by Sam Rushing // // All Rights Reserved // // Permission to use, copy, modify, and distribute this software and // its documentation for any purpose and without fee is hereby // granted, provided that the above copyright notice appear in all // copies and that both that copyright notice and this permission // notice appear in supporting documentation, and that the name of Sam // Rushing not be used in advertising or publicity pertaining to // distribution of the software without specific, written prior // permission. // // SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN // NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS // OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, // NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // ====================================================================== server/semaphore.cxx: server/semaphore.hxx: /****************************************************************************\ * * Written by * Tom Wagner (wagner@cs.umass.edu) * at the Distributed Problem Solving Lab * Department of Computer Science, University of Massachusetts, * Amherst, MA 01003 * * Copyright (c) 1995 UMASS CS Dept. All rights are reserved. * * Development of this code was partially supported by: * ONR grant N00014-92-J-1450 * NSF contract CDA-8922572 * * --------------------------------------------------------------------------- * * This code is free software; you can redistribute it and/or modify it. * However, this header must remain intact and unchanged. Additional * information may be appended after this header. Publications based on * this code must also include an appropriate reference. * * This code 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. * \****************************************************************************/ imview-1.1.9c/DESCRIPTION0000644000076500007650000000357207665407207015525 0ustar talbottalbot00000000000000The software project is a GUI-based scientific image analysis system. At the simplest level it provides an application which can display a large number of image formats, including but not limited to standards such as TIFF, JPEG, GIF, PNG, BMP, XPM, etc, and as such can replace or complement usual applications such as electric eyes (EE) or XV. It is much faster than XV and more mature than EE. This project has been in development since 1997 and is the result of an estimated 1000h of work. As with most image display tools these days, contrast, brightness and gamma controls are provided, as well as most usual niceties such as image cropping, a powerful zoom, rotations and symmetries, etc. For the image analyst (amateur or profesionnal), this software can display multi-spectral images (satellite data), 3D images (medical images), almost all types of pixels (not just 8bit data, but also 1-bit to 64-bit integers and floating point). It supports a number of scientific formats as well as just raw data (the user must provide the interpretation via a dialog). For analysis, pixel based analysis and segmentation tools are provided (single variable histogram thresholding, multi-variate histogram segmentation). Point-based information extraction is provided, as well as image annnotation, profile information, and more. This software is designed to integrate nicely into existing image analysis/image processing packages as an external viewer. Images can be uploaded into it via files, pipes, TCP sockets or shared memory. Most of this software capabilities can be controlled remotely via an interpreter. This was a closed-source project which has recently been opened under the GNU licence. Its main author is Hugues Talbot, from the Australian Commonwealth Scientific and Industrial Research Organization (CSIRO). The software can be downloaded from http://www.cmis.csiro.au/Hugues.Talbot/imview/ imview-1.1.9c/doc/0000755000076500007650000000000010756342325014547 5ustar talbottalbot00000000000000imview-1.1.9c/doc/gpl.html0000644000076500007650000004736407503620621016227 0ustar talbottalbot00000000000000 GNU General Public License - GNU Project - Free Software Foundation (FSF)

GNU General Public License

Table of Contents


GNU GENERAL PUBLIC LICENSE

Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.  
59 Temple Place - Suite 330, Boston, MA  02111-1307, USA

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.

Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and modification follow.

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.

You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:

  • a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.

  • b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.

  • c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.

In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:

  • a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,

  • b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,

  • c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.

7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.

It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.

This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.

10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.

one line to give the program's name and an idea of what it does.
Copyright (C) yyyy  name of author

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 program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this when it starts in an interactive mode:

Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
type `show w'.  This is free software, and you are welcome
to redistribute it under certain conditions; type `show c' 
for details.

The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names:

Yoyodyne, Inc., hereby disclaims all copyright
interest in the program `Gnomovision'
(which makes passes at compilers) written 
by James Hacker.

signature of Ty Coon, 1 April 1989
Ty Coon, President of Vice

This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License.


Copyright notice above.
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA

Updated: Last modified: Fri Dec 29 15:22:34 EST 2000


imview-1.1.9c/doc/imview.10000644000076500007650000002475507507761736016161 0ustar talbottalbot00000000000000.\" This manpage has been automatically generated by docbook2man .\" from a DocBook document. This tool can be found at: .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . .TH "IMVIEW" "1" "01 July 2002" "" "" .SH NAME imview \- displays and interactively analyses images .SH SYNOPSIS \fBimview\fR [ \fBoptions\fR ] [ \fBimage\fR\fI ...\fR ] .PP Where image is an image file in one of the supported formats, e.g: TIFF, JPEG, GIF, PNG, BMP, XPM, PNM, etc... .SH "DESCRIPTION" .PP \fBImview\fR is an X11 and Windows GDI GUI application for displaying images on screen. It has advanced capabilities for interactive image analysis (getting information out of images) and can be easily controlled through a socket connection for embedding in image analysis systems. .PP Imview supports a large number of popular and scientific image file formats, in part through the use of the ImageMagick library. .SH "OPTIONS" .PP Here is the complete list of optional arguments for \fBimview\fR. .TP \fB-\fR Reads an image from the standard input stream. Example: .TP \fB-a\fR Reads and appends to an existing pointfile (see option \fI-p\fR). .TP \fB-C \fR Specifies as the default look-up tables for all the images on the command line. .TP \fB-c \fR Applies the look-up table to the \fBpreceding\fR image on the command line (see example section). .TP \fB-debug\fR Starts a debugging GUI console where debugging messages can be seen (there are lots of them!). Under Unix messages are also appended to the file /tmp/imbugs.txt. .TP \fB-delete\fR Any image given to \fBimview\fR on the command line will be deleted after \fBimview\fR exits. This is useful when \fBimview\fR is started from an interpreter with a temporary image as argument. For safety only images with paths beginning with /tmp, /usr/tmp or under the standard environment variable-controlled TMPDIR directory are effectively deleted. .TP \fB-disable_io_keys\fR This option disables some I/O shortcut that are not menu-dependent, such as c that closes an image. This is useful in conjuction with options \fI-hide_menubar\fR and \fI-disable_menubar\fR for limiting the user's interaction with the application. .TP \fB-disable_menubar\fR This option completely disables the menu bar (but does not hide it, see \fI-hide_menubar\fR for that). Both hiding and disabling the menubar at the same time can be useful for producing a viewer that users cannot control other than through some other means than the menu (if \fBimview\fR is embedded in another application for example). .TP \fB-disable_quit\fR This option disables the shortcut ways of quitting the \fBimview\fR application, such as the Escape key, clicking the windows manager `close window' button, etc. This is useful to restrict the user's control over \fBimview\fR. .TP \fB-fork\fR Sends \fBimview\fR to the background (works on all platforms including windows). It is better to use this option rather than the shell semantics (adding & at the end of the command under Unix) when the server is ran in conjuction with \fI-server\fR, because imview will synchonize the foreground and background processes so that the foreground process can know the server port number. .TP \fB-gamma \fR Sets the default gamma for all the images. A gamma between 0 and 1.0 will darken the displayed image while a gamma greater than 1.0 will brighten them. .TP \fB-h\fR Prints an abbreviated list of options and exits. .TP \fB-hide_menubar\fR Hides the main menubar. The menu items are still accessible via shortcuts. For example try Alt+f to get the file->open menu. From there you can use the keyboard arrow keys to select a menu item for example. This is useful if you have little screen real estate, but confusing for the beginner! .TP \fB-no_dblbuf\fR Do not use double buffering at certain zoom factors. This is a hack you might want to experiment with if you find that \fBimview\fR does not redraw some parts of images after closing and re-opening images. .TP \fB-locked\fR Equivalent to all the following options used together: \fI-hide_menubar\fR, \fI-disable_menubar\fR, \fI-disable_iokeys\fR and \fI-disable_quit\fR. If run with this option, \fBimview\fR can only be controlled via a socket in server mode. This is useful for embedding imview in another application. .TP \fB-mag \fR Magnifies all images by . Any positive value is legal. Values between 0 and 1.0 will reduce the size of the images while values greater than 1.0 will expand them. .TP \fB-no_magick\fR Disables the use of the ImageMagick library. This library is very useful for reading and writing a large number of file formats but tries to do to much sometimes, such as converting text files to images. .TP \fB-p \fR Specifies the point file name. A pointfile is a regular text file in which point (pixel) information can be recorded. The default point file name is pointfile. This option simply changes that default, no other action is taken. .TP \fB-portfile \fR This option is only useful in combination with \fI-server\fR. \fBImview\fR's server binds to a port in the range 7600-7700. Because it is often useful to have more than one image server at the same time and because of the interactive nature of \fBimview\fR, the precise port number is impossible to predict, so when the server is started it prints the port it decided to bind against on the command line, or alternatively in a file, specified by this option. \fBNOTE:\fR If you are planning to send imview to the background, for this command to work as expected, you must also use the \fI-fork\fR option, otherwise the file might still be empty when the command returns. .TP \fB-server\fR Starts the \fBimview\fR server. In server mode \fBimview\fR performs as a TCP/IP server on which images can be uploaded and commands can be run. The aim is to make \fBimview\fR completely remote-controllable: every command accessible via the menu can also be made available through the server. \fBImview\fR uses its own text-based protocol. For simple commands a standard telnet session is enough to communicate with \fBimview\fR. However for uploading images into \fBimview\fR a protocol similar to FTP has been implemented. A simple \fBimview\fR client is shipped in source form with the imview distribution. For a specification of the \fBimview\fR protocol see the full documentation. \fBImview\fR's server port number is in the range 7600-7700 which allows up to 50 different imview server to be run on the same machine (each server uses up two ports: one for commands and the other for binary data exchange, such as uploading images). .TP \fB-stopdebug\fR Used in conjunction with \fI-debug\fR, will stop the program after each debugging message. To continue the user must type . .TP \fB-v\fR Prints the version and build numbers, the date of build, the configuration options and exits. .TP \fB-wt \fR Changes the title of the main window. The default is Imview. .SH "EXAMPLES" .PP In the following examples `%' indicate the shell prompt. .SS "SIMPLE USAGE" .nf % imview .fi .PP Simply starts imview displaying the splash screen. An image can then be loaded using the menus. .nf % imview myimage.tiff .fi .PP Will display image myimage.tiff. .nf % imview /home/talbot/images/astro/* .fi .PP Will display all images in the directory /home/talbot/images/astro/. Use <spacebar> to switch from one image to the next. .PP .SS "ADVANCED USAGE" .nf % imview aGreyLevelImage.tif -c heat.lut .fi .PP Will display image aGreyLevelImage.tif. Assuming this image only contains grey-level information (a black and white photograph for example), the false colours defined in heat.lut will be applied to it. .PP .SS "SERVER USAGE" .nf % imview -server -fork Port: 7600 .fi .PP This will start \fBimview\fR in server mode. The only difference with the normal mode is that \fBimview\fR can now be "remote-controlled" via a TCP/IP connection. The port \fBimview\fR is bound to is printed on the command line when the server starts. To save it to a file use the \fI-portfile\fR option. .PP A simple telnet session can be used to remote-control \fBimview\fR, as follows. See the full documentation for more details: .nf % telnet localhost 7600 user talbot Welcome, talbot /tmp/fileBlabla 000 OK load "/home/talbot/images/astro/neptune.tiff" 000 OK zoom factor 2 000 OK end Connection closed by foreign host. .fi .PP \fBimclient\fR is shipped with the source distribution as an implementation of a sample client that can upload images into imview, as follows: .nf % imclient -p 7600 /home/talbot/images/astro/jupiter.tiff .fi .SH "BUGS" .PP See the TODO file in the source distribution or the web site for an updated list of known bugs. Here is a list of the most significant ones: .TP 0.2i \(bu resize still a problem sometimes. Imview gets itself into a weird state with incorrect limits and partial redraws. Specifying a complete redraw should clear everything but doesn't. .TP 0.2i \(bu Move to the middle of the screen. Sometimes for no apparent reason Imview moves to the middle of the screen. This seems to be happening if the main window resises. .TP 0.2i \(bu last line and last column of image often missing when scrollbar are present. .SH "FILES" .PP .TP \fB~/.imview/preferences\fR User preferences .TP \fB<Installation directory>/Imview/*.lut\fR Colour look-up tables .TP \fB<Installation directory>/Imview/doc/*.html\fR On-line documentation .SH "SEE ALSO" .PP imclient (1), ImageMagick (1), djpeg (1) .PP libtiff (3T) .PP http://imview.sourceforge.net (full manual can be found there). .SH "AUTHOR" .PP The main author is Hugues Talbot <Hugues.Talbot@cmis.CSIRO.AU> .SH "COPYRIGHT" .PP Imview is Copyrighted (C) 1997-2002 by Hugues Talbot and was supported in parts by the Australian Commonwealth Science and Industry Research Organisation. Please see web site for full details. .PP 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. .PP 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. .PP You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. �������������������imview-1.1.9c/doc/quickhelp-1.html������������������������������������������������������������������0000644�0000765�0000765�00000001154�07503620621�017553� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <HEAD> <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9"> <TITLE>Imview on-line help: Introduction Next Previous Contents

1. Introduction

This on-line help only contains a limited amount of documentation on essential features.


Next Previous Contents imview-1.1.9c/doc/quickhelp-2.html0000644000076500007650000000263707503620621017563 0ustar talbottalbot00000000000000 Imview on-line help: Zoom Next Previous Contents

2. Zoom

2.1 Zooming with the mouse is as simple as 1,2,3:

  1. Hold the middle button of the mouse (buy one if you are using a 2-button mouse...).
  2. Drag it to the right and to the bottom of the image. This defines the zoom area.
  3. Release the right button once you have selected the part of the image you want to zoom to.
You are done.

2.2 Unzooming with the mouse

Just click with the right button of the mouse on the image.

2.3 To avoid zooming

To avoid zooming once you have defined a zoom area (assuming you have changed your mind), just drag above the upper-left corner of the selection rectangle. The selection rectangle disappears. Release the mouse button: nothing happens!


Next Previous Contents imview-1.1.9c/doc/quickhelp-3.html0000644000076500007650000000470507503620621017562 0ustar talbottalbot00000000000000 Imview on-line help: Point files Next Previous Contents

3. Point files

Point files are files that contains individual points (or pixels) coordinates, colour values, etc. They are very useful for interacting with other programs, for example defining areas of interest, following features, etc.

3.1 Defining points

  • To define points, hold down the shift key and press the left mouse button.
  • While the left mouse button is held down, you can view the coordinates and image values of the pixel you are pointing to at the top or at the bottom of the image in a small pop-up window.
  • The point is only defined when the left mouse button is released. a circle surrounds the location of the point that has just been defined.
  • If you change your mind about defining a new point, just release the shift key before you release the mouse button. No new point will then be defined.
  • To define a break in the point list, hold down the shift key and click the right mouse button.
  • To delete an arbitrary point from the point list, hold down both the shift key and the alt key, and press the left mouse button on the point that you want to delete. You have to click quite close to the point that you want to define.
  • You can delete the last point that has been defined by pressing alt+d.
  • You can delete all the points by pressing alt+D (same as alt+shift+d)

3.2 Saving points

  • the point list is not saved to disk until you do one of the following:
    1. Save the pointfile manually using the menu (Transform->Pointfile->Save current pointfile, or Alt+p).
    2. Switch to a new image.
    3. Quit the application.


Next Previous Contents imview-1.1.9c/doc/quickhelp-4.html0000644000076500007650000001117107503620621017556 0ustar talbottalbot00000000000000 Imview on-line help: Shortcuts Next Previous Contents

4. Shortcuts

Most menu action have one or more associated shortcut. The default shortcut is listed in the corresponding menu item. However there are additional shortcut that are listed below:


Main shortcut
Alternative Meaning
R Resets the display (default zoom, maximises window)
m Maximizes the window
r Redraws the image (at the current zoom and pan)
alt+c c Closes the current image
alt+shift+c Apply the default colourmap
alt+d deletes the last entered group or point
alt+shift+d delete all the points and groups
alt+e e Selects the Edit submenu
alt+f f Selects the File submenu
control+g Toggle the add point mode
alt+shift+g Turns the debugging messages on
alt+h h Selects the Help submenu
alt+i i Selects the Image submenu
alt+k k or <spacebar> Displays the next image in the list
alt+shift+k Keeps the points when switching images
alt+l i or Shift-<spacebar> Displays the previous image in the list
alt+n n Returns to the default zoom factor
alt+o o Opens a new image
alt+p Opens a new point file
alt+shift+p p saves the point file
control+p append to a pointfile
control+shift+p Prints the image
alt+q q, Esc Quits the application
alt+z To enter the current zoom factor by hand
alt+shift+z To enter the default zoom factor by hand
alt+. . Zooms in by 10%
alt+, , Zooms out by 10%
alt+' Declare the present zoom factor as the default
alt+> > Zooms in by 100%
alt+< < Zooms out by 100%
alt+[ Insert, [ Displays the next image plane (3D)
alt+] Delete, ] Displays the previous image plane (3D)
alt+| Allows the user to select an image plane manually
alt+{ Home Go to the next image sample
alt+÷ End Go to the previous image sample
alt+\ Selects the sample by hand
PageUp Displays the next frame
PageDown Displays the previous frame
? Displays the quick online help
alt+? Invoke netscape on the HTML version of this document
... ... to be completed ...
Principal shortcuts


Next Previous Contents imview-1.1.9c/doc/quickhelp.html0000644000076500007650000000243107503620621017414 0ustar talbottalbot00000000000000 Imview on-line help Next Previous Contents

Imview on-line help

Hugues Talbot

29 Jul 2000


This is the imview on-line help. It uses bare-bone formatting with the LinuxDoc SGML tools. For proper documentation read the full-blown manual that should have been shipped with the software.

1. Introduction

2. Zoom

3. Point files

4. Shortcuts


Next Previous Contents imview-1.1.9c/doc/warranty.html0000644000076500007650000000262607503620621017304 0ustar talbottalbot00000000000000 NO WARRANTY

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

imview-1.1.9c/FAQ0000644000076500007650000000015107752637127014342 0ustar talbottalbot00000000000000# # # Frequently Asked Questions # # Last updated: $Id: FAQ,v 4.1 2003/11/07 06:40:23 hut66au Exp $ # # imview-1.1.9c/fluid/0000755000076500007650000000000010756342326015106 5ustar talbottalbot00000000000000imview-1.1.9c/fluid/.cvsignore0000644000076500007650000000005407653237101017101 0ustar talbottalbot00000000000000makedepend *.a *.C *.H *.cxx *.hxx *.o .ix* imview-1.1.9c/fluid/addpoint.xpm0000644000076500007650000000217207653237103017436 0ustar talbottalbot00000000000000/* XPM */ static char *magick[] = { /* columns rows colors chars-per-pixel */ "32 28 2 1", " c gray0", "X s mask c none", /* pixels */ "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXX XXXXXXXXXXXXX", "XXXXXXXXXXXXX XXXXXXXXXXXXX", "XXXXXXXXXXXXX XX XXXXXXXXXXXXX", "XXXXXXXXXXXXX XX XXXXXXXXXXXXX", "XXXXXXXXXXXXX XXXXXXXXXXXXX", "XXXXXXXXXXXX XXXXXXXXXXXX", "XXXXXXXXXXX XXXXXX XXXXXXXXXXX", "XXXXXXXXXX XXXXXXXX XXXXXXXXXX", "XXXXXXXXX XXXXXXXXXX XXXXXXXXX", "XXXXXXXX XXXXX XXXXXX XXXXXXXX", "XXXXXXX XXXXX XXXXXX XXXXXXX", "XXXXXX XXXXX X X XXXXXX XXXXXX", "XXXXX XXXXXXXX XXXXXXXXX XXXXX", "XXXX XXXXXXXXX XXXXXXXXXX XXXX", "XXX XXXXXXXXXX XXXXXXXXXXX XXX", "XX XXXXXXXXXXX XXXXXXXXXXXX XX", "X XXXXXXXXXXXX XXXXXXXXXXXXX X", "XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "X X X X X X X X X X X X X X X XX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" }; imview-1.1.9c/fluid/annotatedlg.fl0000644000076500007650000001321707727302500017727 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0103 header_name {.h} code_name {.cxx} Function {annotatept_panel(annotatept &anpp)} {open } { Fl_Window {anpp.annotateWindow} { label {Annotate point} open xywh {29 68 451 317} type Single box ENGRAVED_BOX code0 {\#include "annotatePoints.hxx"} modal visible } { Fl_Group {} {open xywh {15 15 455 65} } { Fl_Input {anpp.annotateInput} { label {Annotation:} user_data {&anpp} user_data_type {annotatept*} callback annotateinput_cb tooltip {Text to appear next to point} xywh {125 15 310 60} type Multiline color 43 selection_color 143 labelfont 7 } } Fl_Group {} {open xywh {329 239 110 66} } { Fl_Box {} { xywh {349 269 88 36} box THIN_DOWN_FRAME } Fl_Return_Button {anpp.OKButton} { label OK user_data {&anpp} user_data_type {annotatept*} callback okbutton_cb tooltip {Accept changes} xywh {353 272 80 30} hotspot } } Fl_Button {anpp.CancelButton} { label Cancel user_data {&anpp} user_data_type {annotatept*} callback cancelbutton_cb selected tooltip {Close dialog -- discard changes} xywh {15 270 80 30} code0 {o->shortcut("^[");} } Fl_Group {} { label {Position:} open tooltip {Position of text relative to point} xywh {125 80 125 60} box ENGRAVED_FRAME labelfont 7 align 4 } { Fl_Round_Button {} { label NW user_data {&anpp} user_data_type {annotatept*} callback NW_cb xywh {160 80 30 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 39 align 4 } Fl_Round_Button {} { label NE user_data {&anpp} user_data_type {annotatept*} callback NE_cb xywh {190 80 30 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 39 align 8 } Fl_Round_Button {} { label SE user_data {&anpp} user_data_type {annotatept*} callback SE_cb xywh {190 110 30 30} type Radio down_box DIAMOND_DOWN_BOX value 1 selection_color 39 align 8 } Fl_Round_Button {} { label SW user_data {&anpp} user_data_type {annotatept*} callback SW_cb xywh {160 110 30 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 39 align 4 } } Fl_Choice {anpp.fontChoice} { label {Text font:} open tooltip {Text font} xywh {125 145 125 25} down_box BORDER_BOX labelfont 7 } { menuitem {} { label Helvetica xywh {10 10 100 20} value 1 } menuitem {} { label {Helv.Bold} xywh {10 10 100 20} } menuitem {} { label {Helv.Italic} xywh {20 20 100 20} } menuitem {} { label {Helv.Bold.Ital} xywh {10 10 100 20} } menuitem {} { label Courier xywh {20 20 100 20} } menuitem {} { label {Courier Bold} xywh {30 30 100 20} } menuitem {} { label {Courier Ital} xywh {40 40 100 20} } menuitem {} { label {Cour.Bold.Ital.} xywh {50 50 100 20} } menuitem {} { label Times xywh {60 60 100 20} } menuitem {} { label {Times Bold} xywh {70 70 100 20} } menuitem {} { label {Times.Bld.Ital.} xywh {80 80 100 20} } menuitem {} { label Symbol xywh {90 90 100 20} } menuitem {} { label Screen xywh {100 100 100 20} } menuitem {} { label {Screen Bold} xywh {110 110 100 20} } } Fl_Group {} { label {Distance:} open tooltip {Distance point-text} xywh {340 80 95 60} box ENGRAVED_BOX labelfont 7 align 4 } { Fl_Roller {anpp.distanceRoller} { user_data {&anpp} user_data_type {annotatept*} callback setdistance_cb xywh {345 85 85 25} type Horizontal align 1 minimum 5 maximum 40 step 1 value 7 } Fl_Value_Output {anpp.distanceValue} { xywh {345 110 85 25} minimum 5 maximum 40 step 1 value 7 } } Fl_Choice {anpp.fontColourChoice} { label {Colour:} open tooltip {Text colour} xywh {340 145 95 25} down_box BORDER_BOX labelfont 7 } { menuitem {} { label black xywh {30 30 100 20} } menuitem {} { label red xywh {20 20 100 20} } menuitem {} { label green xywh {20 20 100 20} } menuitem {} { label yellow xywh {30 30 100 20} } menuitem {} { label blue xywh {20 20 100 20} } menuitem {} { label magenta xywh {30 30 100 20} } menuitem {} { label cyan xywh {40 40 100 20} } menuitem {} { label white xywh {40 40 100 20} } } Fl_Group {} {open tooltip {Text size} xywh {125 185 310 40} } { Fl_Slider {anpp.fontSizeSlider} { label {Text size:} xywh {125 185 310 25} type {Horz Knob} labelfont 7 align 4 minimum 5 maximum 24 step 1 value 10 } Fl_Box {} { label {tiny small medium large huge} xywh {125 210 310 15} labelfont 4 labelsize 10 align 20 } } Fl_Round_Button {anpp.hiddenButton} { label {Hidden:} tooltip {Hide text} xywh {125 230 25 25} down_box ROUND_DOWN_BOX selection_color 39 labelfont 7 align 4 } Fl_Value_Slider {anpp.pointsizeValueSlider} { label {Point size:} tooltip {Size of point} xywh {265 230 170 25} type Horizontal labelfont 7 align 4 minimum 1 maximum 15 step 1 value 3 } } } imview-1.1.9c/fluid/arbitrary.fl0000644000076500007650000001155510720437045017431 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0107 header_name {.H} code_name {.C} Function {rawimage_panel(rawimage &ri)} {open } { Fl_Window {ri.rawimageWindow} { label {Unknown image format} open selected xywh {450 222 564 284} type Single code0 {\#include "rawImage.hxx"} non_modal visible } { Fl_Group {} { label Dimensions open xywh {12 105 258 51} box ENGRAVED_FRAME } { Fl_Input {ri.xInput} { label {X:} user_data {&ri} user_data_type {rawimage*} callback xinput_cb xywh {40 117 60 30} type Int class Fl_Int_Input } Fl_Input {ri.yInput} { label {Y:} user_data {&ri} user_data_type {rawimage*} callback yinput_cb xywh {120 117 60 30} type Int class Fl_Int_Input } Fl_Input {ri.zInput} { label {Z:} user_data {&ri} user_data_type {rawimage*} callback zinput_cb xywh {200 117 60 30} type Int class Fl_Int_Input } } Fl_Group {} { label Bands open xywh {11 179 259 49} box ENGRAVED_FRAME } { Fl_Input {ri.nbBandsInput} { label {Nb:} user_data {&ri} user_data_type {rawimage*} callback nbband_cb xywh {40 190 60 28} type Int class Fl_Int_Input } Fl_Choice {ri.bandTypeChoice} { user_data {&ri} user_data_type {rawimage*} callback interleave_cb open xywh {121 189 62 28} down_box BORDER_BOX } { MenuItem {} { label BIL xywh {0 0 100 20} } MenuItem {} { label BIP xywh {0 0 100 20} } MenuItem {} { label BSQ xywh {0 0 100 20} } } Fl_Button {ri.assignButton} { label Assign xywh {200 189 59 28} } } Fl_Group {} { label Pixel open xywh {280 105 274 51} box ENGRAVED_FRAME } { Fl_Choice {ri.pixelTypeChoice} { label {Type:} user_data {&ri} user_data_type {rawimage*} callback pixeltype_cb open xywh {324 116 79 29} down_box BORDER_BOX } { MenuItem {} { label Uchar xywh {0 0 100 20} } MenuItem {} { label Short xywh {0 0 100 20} } MenuItem {} { label UShort xywh {0 0 100 20} } MenuItem {} { label Int xywh {0 0 100 20} } MenuItem {} { label UInt xywh {0 0 100 20} } MenuItem {} { label Long xywh {0 0 100 20} } MenuItem {} { label ULong xywh {0 0 100 20} } MenuItem {} { label Float xywh {0 0 100 20} } MenuItem {} { label Double xywh {0 0 100 20} } } Fl_Choice {ri.byteOrderChoice} { label {Endian:} user_data {&ri} user_data_type {rawimage*} callback byteorder_cb open xywh {460 116 87 29} down_box BORDER_BOX } { MenuItem {} { label Default xywh {0 0 100 20} } MenuItem {} { label {Big (Sparc)} xywh {0 0 100 20} } MenuItem {} { label {Little (x86)} xywh {0 0 100 20} value 1 } MenuItem {} { label Guess xywh {0 0 100 20} value 1 } } } Fl_Group {} { label {File and header} open xywh {281 179 273 52} box ENGRAVED_FRAME } { Fl_Input {ri.headerSizeInput} { label {Skip:} user_data {&ri} user_data_type {rawimage*} callback headersize_cb xywh {460 190 88 27} type Int align 132 class Fl_Int_Input } Fl_Output {ri.filesizeOutput} { label {Size:} xywh {325 190 92 30} } } Fl_Button {ri.cancelButton} { label Cancel user_data {&ri} user_data_type {rawimage*} callback cancelbutton_cb xywh {382 242 75 30} } Fl_Button {ri.OKButton} { label Try user_data {&ri} user_data_type {rawimage*} callback okbutton_cb xywh {479 242 75 30} } Fl_Button {ri.helpButton} { label Help user_data {&ri} user_data_type {rawimage*} callback helpbutton_cb xywh {281 242 75 30} } Fl_Button {ri.computeHeaderButton} { label {Compute header} user_data {&ri} user_data_type {rawimage*} callback computeskip_cb xywh {11 242 119 30} } Fl_Output {ri.bannerOutput} { xywh {13 37 542 42} type Multiline box ENGRAVED_BOX color 93 selection_color 47 textfont 3 code0 {o->value("Sample text\\nSample text");} } Fl_Box {ri.titleBox} { label {File format not recognized} xywh {18 5 536 28} labelfont 1 labelsize 16 labelcolor 1 } } } Function {make_window()} {open } {} imview-1.1.9c/fluid/bivdlg.fl0000644000076500007650000001274007727302500016676 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0011 header_name {.H} code_name {.C} gridx 5 gridy 5 snap 3 Function {bivhist_panel(bivhist &bh)} {open } { Fl_Window {bh.bivhistWindow} { label {Bivariate histogram} open selected xywh {667 242 800 600} type Single resizable code0 {\#include "bivHist.hxx"} visible } { Fl_Group {} { xywh {0 45 685 510} resizable } { Fl_Scroll {bh.bivhistScroll} {open xywh {65 45 620 480} box THIN_DOWN_BOX color 53 resizable } {} Fl_Box {bh.absissaBox} { label X xywh {65 526 620 24} labelfont 3 align 16 class axisBox } Fl_Box {bh.ordinateBox} { label Y xywh {0 45 63 480} labelfont 3 align 16 class axisBox } Fl_Box {} { xywh {0 525 65 25} } } Fl_Group {} { xywh {0 560 800 35} } { Fl_Button {bh.printButton} { label print xywh {600 565 80 25} } Fl_Button {bh.saveButton} { label save xywh {510 565 80 25} } Fl_Box {} { xywh {690 560 100 35} box THIN_DOWN_BOX } Fl_Return_Button {bh.computeButton} { label compute user_data {&bh} user_data_type {bivhist*} callback computebivhist_cb xywh {695 565 90 25} } Fl_Button {bh.dismissButton} { label dismiss user_data {&bh} user_data_type {bivhist*} callback dismissbutton_cb xywh {65 565 70 25} } Fl_Box {} { xywh {135 560 375 35} resizable } Fl_Box {} { xywh {0 560 65 35} } Fl_Box {} { xywh {790 560 10 35} } } Fl_Group {} {open xywh {690 0 110 525} } { Fl_Group {} { label region open xywh {690 45 92 165} box ENGRAVED_BOX } { Fl_Group {} {open xywh {695 55 80 60} } { Fl_Button {bh.selectRegionButton} { label select xywh {695 55 80 25} type Radio code0 {o->value(1);} } Fl_Button {bh.clearRegionButton} { label clear xywh {695 90 80 25} type Radio } } Fl_Choice {bh.regioncolourChoice} { label {colour:} open xywh {695 140 80 25} align 1 } { menuitem {} { label red xywh {0 0 100 20} } menuitem {} { label green xywh {0 0 100 20} } menuitem {} { label yellow xywh {10 10 100 20} } menuitem {} { label blue xywh {0 0 100 20} } menuitem {} { label magenta xywh {10 10 100 20} } menuitem {} { label cyan xywh {20 20 100 20} } } Fl_Button {bh.clearAllRegionsButton} { label {clear all} xywh {695 175 80 25} } } Fl_Group {} { label zoom open xywh {690 235 92 115} box ENGRAVED_BOX } { Fl_Button {bh.zoominButton} { label enlarge user_data {&bh} user_data_type {bivhist*} callback zoominbutton_cb xywh {695 245 80 25} } Fl_Button {bh.zoomoutButton} { label shrink user_data {&bh} user_data_type {bivhist*} callback zoomoutbutton_cb xywh {695 280 80 25} } Fl_Button {bh.resetzoomButton} { label reset user_data {&bh} user_data_type {bivhist*} callback resetbutton_cb xywh {695 315 80 25} } } Fl_Group {} { label {pen width} open xywh {690 465 95 60} box ENGRAVED_BOX } { Fl_Roller {bh.penRadiusRoller} { user_data {&bh} user_data_type {bivhist*} callback setpenwidth_cb xywh {695 470 85 25} type Horizontal align 1 minimum 1 maximum 40 step 1 value 1 } Fl_Value_Output {bh.penWidthValue} { xywh {695 495 85 25} minimum 1 maximum 40 step 1 value 1 } } Fl_Group {} { label transparency open xywh {690 385 95 60} box ENGRAVED_BOX } { Fl_Roller {bh.transparencyRoller} { user_data {&bh} user_data_type {bivhist*} callback settransparency_cb xywh {695 390 85 25} type Horizontal align 1 step 0.05 } Fl_Value_Output {bh.transparencyValue} { xywh {695 415 85 25} step 0.05 } } Fl_Box {} { xywh {690 0 110 45} } Fl_Box {} { xywh {690 210 90 25} } Fl_Box {} { xywh {690 350 90 35} resizable } } Fl_Group {} { xywh {0 5 685 35} } { Fl_Group {} {open xywh {150 5 150 35} } { Fl_Group {} { label {vs.} open xywh {150 5 150 35} align 16 } { Fl_Input {bh.Xinput} { label {X:} xywh {170 10 35 25} type Int } Fl_Input {bh.Yinput} { label {Y:} xywh {260 10 35 25} type Int } } Fl_Box {} { label {Components:} xywh {150 5 150 35} box ENGRAVED_FRAME align 4 } } Fl_Output {bh.positionOutput} { label {Position:} xywh {460 5 225 35} box ENGRAVED_BOX color 49 } Fl_Box {} { xywh {0 5 150 35} } Fl_Box {} { xywh {300 5 160 35} resizable } } } } imview-1.1.9c/fluid/config.h.in0000644000076500007650000000044707653237104017135 0ustar talbottalbot00000000000000/* config.h.in. Generated automatically from configure.in by autoheader. */ /* Define to empty if the keyword does not work. */ #undef const /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define if your declares struct tm. */ #undef TM_IN_SYS_TIME imview-1.1.9c/fluid/configure.in0000644000076500007650000000053207653237105017417 0ustar talbottalbot00000000000000dnl Process this file with autoconf to produce a configure script. AC_INIT(printprefs.C) dnl Checks for programs. AC_PROG_CC dnl Checks for libraries. dnl Checks for header files. dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_STRUCT_TM dnl Checks for library functions. AC_HEADER_STDC AC_OUTPUT(Makefile) imview-1.1.9c/fluid/editpoint.xpm0000644000076500007650000000217407653237105017637 0ustar talbottalbot00000000000000/* XPM */ static char *magick[] = { /* columns rows colors chars-per-pixel */ "32 28 2 1", " c gray0", "# s mask c none", /* pixels */ "################################", "################################", "#### ## # # # # # ##", "### ### ########### ####### ##", "### ##### ########## # ### ##", "## ###### ######### ####### ##", "## ######## ######### # ## ##", "## ####### ######### ####### ##", "### ##### ######### # #### ##", "#### ### ########## ####### ##", "##### ########### # # ##", "########### ######### ####### ##", "############# ####### # # ##", "############### ##### ####### ##", "################# ### ####### ##", "################### # ##", "################################", "################################", "###### ##### ###############", "###### ######### ### ### #######", "###### ######### ####### #######", "###### ###### # ## ## ######", "###### ## ## ### ### #######", "###### ##### ### ### ### #######", "###### ##### ### ### ### #######", "###### ##### ## ### ### # #####", "###### ## # ## ### ######", "################################" }; imview-1.1.9c/fluid/fliph.xpm0000644000076500007650000000377607653237105016753 0ustar talbottalbot00000000000000/* XPM */ static char *magick[] = { /* columns rows colors chars-per-pixel */ "32 28 2 2", " c gray0", ". s mask c none", /* pixels */ ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " }; imview-1.1.9c/fluid/flipv.xpm0000644000076500007650000000377607653237105016771 0ustar talbottalbot00000000000000/* XPM */ static char *magick[] = { /* columns rows colors chars-per-pixel */ "32 28 2 2", " c gray0", ". s mask c none", /* pixels */ ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " }; imview-1.1.9c/fluid/hidetoolbar.xpm0000644000076500007650000001427107653237105020135 0ustar talbottalbot00000000000000/* XPM */ static char *hidetoolbar[] = { /* width height num_colors chars_per_pixel */ " 32 32 250 2", /* colors */ ".. c #0c0204", ".# c #7c8664", ".a c #394219", ".b c #784618", ".c c #471d09", ".d c #bcc29c", ".e c #6c6430", ".f c #0c2224", ".g c #5c441e", ".h c #b48254", ".i c #2f2406", ".j c #786218", ".k c #2f3313", ".l c #9ca078", ".m c #662d20", ".n c #9c6634", ".o c #99835e", ".p c #4c310c", ".q c #4c5430", ".r c #76644f", ".s c #2c352f", ".t c #ece2a4", ".u c #46432a", ".v c #544440", ".w c #472e2f", ".x c #240f04", ".y c #a0936f", ".z c #b7a571", ".A c #67441c", ".B c #2c222c", ".C c #7c724f", ".D c #64724c", ".E c #333c31", ".F c #443b35", ".G c #785220", ".H c #d4a268", ".I c #4c6254", ".J c #ecf6cc", ".K c #111407", ".L c #33433c", ".M c #e7c389", ".N c #575551", ".O c #aa8858", ".P c #322d16", ".Q c #8e6436", ".R c #323c1f", ".S c #173527", ".T c #8f7450", ".U c #acb19f", ".V c #484544", ".W c #745440", ".X c #9c9280", ".Y c #6a4b1e", ".Z c #374c3a", ".0 c #9ea08c", ".1 c #281906", ".2 c #3c3d2f", ".3 c #66645a", ".4 c #8c966c", ".5 c #503a10", ".6 c #1f2508", ".7 c #c4b27c", ".8 c #8e5d26", ".9 c #798476", "#. c #b49450", "## c #3c3511", "#a c #988270", "#b c #593c38", "#c c #391909", "#d c #242420", "#e c #46280a", "#f c #5a4b20", "#g c #643a08", "#h c #77756f", "#i c #0e1b0a", "#j c #e4d294", "#k c #3c2514", "#l c #78643e", "#m c #6a5429", "#n c #3c3535", "#o c #484a38", "#p c #543431", "#q c #f4f2dc", "#r c #a2a794", "#s c #878471", "#t c #cc9654", "#u c #9e7940", "#v c #583414", "#w c #906e4c", "#x c #644440", "#y c #745b2f", "#z c #666c60", "#A c #160504", "#B c #49544f", "#C c #c4a478", "#D c #664530", "#E c #302d27", "#F c #313c3e", "#G c #473e49", "#H c #d9b577", "#I c #3c453b", "#J c #695354", "#K c #e4d2c4", "#L c #84643d", "#M c #695c36", "#N c #d4deac", "#O c #2f2417", "#P c #483120", "#Q c #3c2b0b", "#R c #936f40", "#S c #291e07", "#T c #b6946a", "#U c #562824", "#V c #303420", "#W c #7a6b56", "#X c #483634", "#Y c #fbfbc3", "#Z c #a88464", "#0 c #4b4c49", "#1 c #694c2f", "#2 c #3b4b49", "#3 c #616b44", "#4 c #742d1f", "#5 c #343431", "#6 c #797d5c", "#7 c #4c3d34", "#8 c #dcc294", "#9 c #8c5e5c", "a. c #7c3927", "a# c #f4d8b4", "aa c #81453c", "ab c #c0b29c", "ac c #d7b98f", "ad c #e6e3cc", "ae c #f4d29c", "af c #a9977c", "ag c #b07848", "ah c #6c7e64", "ai c #8c7a74", "aj c #d4c2ac", "ak c #d4aa6c", "al c #1c3e2c", "am c #b48e64", "an c #5a6b5e", "ao c #787e70", "ap c #fcecaf", "aq c #c7ad77", "ar c #c4bea4", "as c #683828", "at c #745e3c", "au c #6c7567", "av c #845214", "aw c #846e51", "ax c #6c4b3f", "ay c #645e44", "az c #ecdeb4", "aA c #eceebc", "aB c #b7a989", "aC c #e4ba84", "aD c #a16f3f", "aE c #5a4c42", "aF c #595b53", "aG c #917d5c", "aH c #202c08", "aI c #998c71", "aJ c #202b23", "aK c #ecdea1", "aL c #fcfdd9", "aM c #b79c6f", "aN c #a48b6c", "aO c #ececc4", "aP c #dcceb4", "aQ c #8c8258", "aR c #ac9f74", "aS c #847654", "aT c #fcf4bf", "aU c #243524", "aV c #aca18c", "aW c #5c3a14", "aX c #1c1b0a", "aY c #aca68e", "aZ c #5c5e34", "a0 c #170c05", "a1 c #f8dc98", "a2 c #84622c", "a3 c #340e04", "a4 c #cc9e70", "a5 c #d4d8c8", "a6 c #0b0d04", "a7 c #696549", "a8 c #607368", "a9 c #3c3d1c", "b. c #482820", "b# c #695636", "ba c #845c2c", "bb c #3c2c2f", "bc c #ccb694", "bd c #e4ae7c", "be c #847d77", "bf c #c4ae8c", "bg c #a49a68", "bh c #8f6a3f", "bi c #999a81", "bj c #341e0d", "bk c #a07e50", "bl c #c48e54", "bm c #84664c", "bn c #3c2428", "bo c #1c1404", "bp c #8c9a8c", "bq c #6c6e44", "br c #fceac4", "bs c #846a6c", "bt c #ac9a6c", "bu c #744e1c", "bv c #44220c", "bw c #6c322c", "bx c #948a64", "by c #49360f", "bz c #bcaa74", "bA c #5c625c", "bB c #e4ca7c", "bC c #7c8a84", "bD c #7c6a44", "bE c #485a4c", "bF c #d4be94", "bG c #ac7e54", "bH c #745e5c", "bI c #3a432b", "bJ c #56442e", "bK c #454439", "bL c #49313f", "bM c #79745e", "bN c #775531", "bO c #2c1a1c", "bP c #523b20", "bQ c #594c31", "bR c #6c6c70", "bS c #888c80", "bT c #644c50", "bU c #47361f", "bV c #c4ba8c", "bW c #846a34", "bX c #74322c", "bY c #dccaa0", "bZ c #fcdeb4", "b0 c #4c523f", "b1 c #9c9694", "b2 c #3c3d40", "b3 c #3c351f", /* pixels */ "af#X.2.2#0.saJb0#o.R.k.Ra9.k###o.u#V#V.E.P.sbI.R.E.Z.R#oa8.F#O#p", "#Qbo#5#BaJ.PbI.q.kaH.k#i#Q.i#A##.P.Pa6.P.E.KbIbI.P.q.a.#bS#Fa0#b", "bJ.F#d.E#E.s.u.ia0##.e#MbtbtbtaRaG#s.X#r.Ua5.0a5ad.daObian.L#E#J", "b3#0#IaJ#0.FaE#Q#e#l#Zbx.zaMbD.r#KadaVbeb1be#s.0#qaLaz.0a8#F#d#7", "#O.V#B.saFaX.1#c.g#TacbZbraT.o#Majab.N.V#haF.V#zadaLaL.la8.Lb2.F", "#X#G#F.L#oaX##.eaRazaK#Yapapbz.obxbM#7#0#5aE.6.kbiaO#Y#3#z#2aF#P", "#b#n#F.E.Z.k#f.ebg#j.t#Y#Yap.zbtaRbM.P.R.2.s.Z.P#3aLaA.l.9#F#Gbn", ".w#5#0.La6##.e#..Map#Y#YaTa1btaQ.lay#I.3#o#I.kaU.k.J#N.4au#5#X#p", "bL#5#FaFa6###laMaeapaTapapaq.7btbiay#zan.L#z#IbI.6#YaA#6#h#Ebb#x", "bL#G#G#IaXbPaW.oaMaCa1bBbdakbW.TbxbC.9#F.L#FaH.k#Saz#YaBbI#F#5#b", "bL#G#naXbo.PbxaG#TbW.j.j.8#g.AbN#r.0.Z.EaUbI.2bQ.1azaTaw.R.s.B#J", "bn.B#I#VaX.k.xbj.i.5#f#m.Abu.Y#mbFara7#o.kaVbYbY#mbFbYbxau.s#Ibs", "bT.V#5#ia6b3.1bj#Q.x##.1#e#m#laSaBayb#.oaL#8#C.o.1.obV.y.EaJ.NbH", "bbb2aJbI.UbM#V#A...1#Abo#Q.1.Pbyabbra#aqa2bu.Obh#Law.C#raobC#B#X", "bT.3aJ#i.lao.K#S#7#KaPaV.1bobUa7aG#m.Y.c.ca3.Q.Y.g#Qa9aQ.9an#d.w", ".w#0bIal.D#6#oa0a0bj#Wa0.1bQ#M#W#1.p.T.Q#c.G#u#y.o#Q#O.0.9#2.3ai", "#k#nbIaH#3.abQ.P#Aa3.v#1aGataIaNbx.C.i.p.oaMat#maI.6.PbpbpaJ#Bbb", "#b.F.RaH.abqa7#QbP#1#l#C#T.O.Obfafbob3.Pboaybx#s#W.K#0.U.9.sb2bb", "#b#7#VaH.aaZaIb#.T.T.O.M.HaC.Obcbx#s#dbI.K#EbR.u#dbo#d#rbp.L#Ibb", "#b.V#IaH.6a9bg.Y.T#CaC.Ma1avbha#bM#z#B#2.L.f#I#i#S#o#Ebibp.L#5bO", "#p#7bK.RaH.6#M#kbNam#H.H#t.n.bataVbR#2.f#F#F.s#5#db3.FaIa8#B#z.v", ".w#E.EaU.ZaX.iby.A.A#Ragavba#Raf.XaF#2#F#2.sa6.F.vbPbP.3#z#BbAaE", "bL#5.L.LbI.k.1#P#Dbv#g.G.G.8atbJ#sbS#IaJ#5.B.FaEbJbPbP#aaF#B.s.F", ".v#F.Z.LalbI#E.x#1.A.b.Aa2atbJ#P#6#5bob0#XbobPbP#D#1#vaw#oan#IaE", "#7.L#2.San.Z#5#Absbm.Ga2.oac.o#sbM#5bK.2.ibj.g.A.YaW.A#WaFau#E.v", ".VaJal.Sal.ZaUa6#lbm#u#.#u#ebQ##an#B#i#I.1.i.A#m.A.Y#laGbebR#n#p", "#XaX.L.IbE.S.E.2#Oaw#H#..8.b.5#Sa7.E#0a9.1by.Aba#Ra2#yaSaobRb2bn", "bLbbb2bA#F#5b2#X#A#b#Za4bl.h#R#1.r#W#Oa0a3.Q.n.b.8aDbh.oana8#0bQ", "#p#JbL#0#5aF#n#5bO#c.p#Tbd.ha4#ZaIbO#k.WaDbGagaDaDbaa2aRah.Zal#V", "bb#0.saU.Z.ZaU.s.EaJ.6#f#y#Rbf#a.raV.Caf.ybkbk#.aMaN.yaY.9#V.2#S", "#P.1#o#obI#I#o#F#0.2#Vbybv.p#eb##a.r#a#1.W.Q#wbh#waNaVaIbJ#k#P#U", "#U#cax.WbvbJ#x#PbJ#Ub.aW.ma..mbw#UaaaabX#4#4#4a.as.c#U#9.maa.mbX" }; imview-1.1.9c/fluid/imginfodlg.fl0000644000076500007650000000172507727302500017547 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0104 header_name {.H} code_name {.C} Function {imageinfo_panel(imageinfo &s)} {open } { Fl_Window {s.outputWindow} { label {Image information} open selected xywh {600 461 450 240} type Single box ENGRAVED_BOX resizable code0 {\#include "imageInfo.hxx"} visible } { Fl_Box {} { xywh {10 20 432 170} box ENGRAVED_FRAME } Fl_Box {} { label {Image Information} xywh {157 10 120 20} box FLAT_BOX } Fl_Output {s.textOutput} { xywh {15 30 422 155} type Multiline box FLAT_BOX selection_color 47 textsize 12 resizable } Fl_Group {} {open xywh {330 190 114 50} } { Fl_Box {} { xywh {340 197 102 36} box THIN_DOWN_FRAME } Fl_Return_Button {s.OKButton} { label {Dismiss } user_data {&s} user_data_type {imageinfo*} callback okbutton_cb xywh {344 200 94 30} hotspot } } } } imview-1.1.9c/fluid/Makefile.in0000644000076500007650000000433410211621421017135 0ustar talbottalbot00000000000000# -*- Makefile -*- # Hand-generated makefile for the fluid part of ImView # # These C++ files are fluid-generated # SHELL = /bin/sh VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ subdirs = @subdirs@ top_srcdir = @top_srcdir@ srcdir = @srcdir@ bindir = $(exec_prefix)/bin infodir = $(prefix)/info libdir = $(prefix)/lib/gnudl mandir = $(prefix)/man/man1 # compilers and flags CC = @CC@ CXX = @CXX@ FLUID = @FLUID@ CPPFLAGS = @CPPFLAGS@ CFLAGS = $(CPPFLAGS) @CFLAGS@ CXXFLAGS = $(CPPFLAGS) @CXXFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ INSTALL = @INSTALL@ # program to make the archive: LIBNAME = @LIBNAME@ LIBCOMMAND = @LIBCOMMAND@ RANLIB = @RANLIB@ DSONAME = @DSONAME@ DSOCOMMAND = @DSOCOMMAND@ # we are building a library TOP = ${top_srcdir} TARGET = imview_ui.a # so as to include the class declarations and config.h CXXFLAGS += -I${TOP} -I.. FLUIDFILES = \ printdlg.fl \ savedlg.fl \ imginfodlg.fl \ transfer.fl \ spectra.fl \ savespectdlg.fl \ prntspectdlg.fl \ profile.fl \ userprefdlg.fl \ tmpmsgdlg.fl \ bivdlg.fl \ progress.fl \ arbitrary.fl \ annotatedlg.fl \ toolbardlg.fl \ transfer2.fl \ sliderdlg.fl \ view3ddlg.fl CPPFILES = $(FLUIDFILES:.fl=.cxx) OBJECTS = $(CPPFILES:.cxx=.o) ## rules for C and H files to be generated from .fl files .SUFFIXES : .cxx .o .fl .cc # DEC Unix has some .cc files to be included. Do not compile them .cc: @echo "Do nothing with $<" .cxx.o : $(CXX) $(CXXTRA) $(CXXFLAGS) -c $< .fl.hxx: ${FLUID} -h .hxx -o .cxx -c $< .fl.cxx: ${FLUID} -h .hxx -o .cxx -c $< $(TARGET) : $(OBJECTS) $(LIBCOMMAND) $(TARGET) $(OBJECTS) $(RANLIB) $(TARGET) all: $(TARGET) test: @echo "TOP:\t\t:" $(TOP) @echo "Fluid files:\t" $(FLUIDFILES) @echo "CPP files:\t" $(CPPFILES) @echo "Object files:\t" $(OBJECTS) @echo "Target: \t" $(TARGET) clean: - @rm *.cxx *.hxx *.o *.a realclean: - @rm *.cxx *.hxx *.o *.a *~ *.da *.bb *.bbg .ix[0-9]* .inslog* depend: $(CPPFILES) ${CFILES} $(CXX) $(CXXTRA) $(CXXFLAGS) -M $^ > makedepend makedepend: touch makedepend include makedepend # dependencies imview-1.1.9c/fluid/measure.xpm0000644000076500007650000000212207653237105017272 0ustar talbottalbot00000000000000/* XPM */ static char * measure_xpm[] = { "32 28 2 1", " s mask c none ", ". c #000000000000", " . . ", " . .. ", " ... . . ", " . .... . . ", " . .... .. ", " . .... . ", " .... . ", " .. .... . ", " . .... ... ", " . .... .. ", " . .... . ", " . .... ", " . . .... ", " . . .. ", " . . ", " . . ", " . . ", " . . ", " . . ", " . . ... . ", " . . .. . . ", " . .. . . ", " ... . . ", " . .. . . ", " . .. .. ", " . ", " . ", " "}; imview-1.1.9c/fluid/pencil.xpm0000644000076500007650000000157710065765504017120 0ustar talbottalbot00000000000000/* XPM */ static char *pencil[] = { /* columns rows colors chars-per-pixel */ "22 22 15 1", " c opaque", ". c gray19", "X c #400000", "o c #800000", "O c #c00000", "+ c #cc0000", "@ c red", "# c #808080", "$ c #aaaaaa", "% c #ff8080", "& c #c8c8c8", "* c gainsboro", "= c #ffc0c0", "- c white", "; c None", /* pixels */ ";;;;;;;;;;;;;;;;;;o@%O", ";;;;;;;;;;;;;;;;;oO=OO", ";;;;;;;;;;;;;;;;oO=OOO", ";;;;;;;;;;;;;;;oO=OOOo", ";;;;;;;;;;;;;;oO=OOOoo", ";;;;;;;;;;;;;oO=OOOoo ", ";;;;;;;;;;;;oO=OOOoo ;", ";;;;;;;;;;;oO=OOOoo ;;", ";;;;;;;;;;oO=OOOoo ;;;", ";;;;;;;;;oO=OOOoo ;;;;", ";;;;;;;;oO=OOOoo ;;;;;", ";;;;;;;oO=OOOoo ;;;;;;", ";;;;;;oO=OOOoo ;;;;;;;", ";;;;;oO=OOOoo ;;;;;;;;", ";;;;;-&OOOoo ;;;;;;;;;", ";;;;*-*&Ooo ;;;;;;;;;;", ";;;;-*&&#o ;;;;;;;;;;;", ";;;-*&$#. ;;;;;;;;;;;;", ";;;O&$. ;;;;;;;;;;;;;;", ";;OoX ;;;;;;;;;;;;;;;;", ";;oX;;;;;;;;;;;;;;;;;;", ";;;;;;;;;;;;;;;;;;;;;;" }; imview-1.1.9c/fluid/printdlg.fl0000644000076500007650000002334610065514677017267 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0105 header_name {.H} code_name {.C} Function {printprefs_panel(printprefs &s)} { callback chosenmargin_cb open } { Fl_Window {s.prefWindow} { label {Print an image} open xywh {579 360 415 420} type Double box ENGRAVED_BOX code0 {\#include "printPrefs.hxx"} visible } { Fl_Group {s.printtypeGroup} { label {Print to:} open xywh {150 10 260 30} labelfont 7 align 4 } { Fl_Check_Button {s.printerCheck} { label Printer user_data {&s} user_data_type {printprefs*} callback printercheck_cb xywh {150 10 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 12 } Fl_Check_Button {s.fileCheck} { label File user_data {&s} user_data_type {printprefs*} callback filecheck_cb xywh {250 10 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 12 } } Fl_Group {s.inputGroup} {open xywh {150 40 265 110} } { Fl_Input {s.commandInput} { label {Print command:} user_data {&s} user_data_type {printprefs*} callback commandInput_cb xywh {150 40 260 30} color 43 selection_color 12 labelfont 7 textfont 4 textsize 12 } Fl_Input {s.filenameInput} { label {File name:} user_data {&s} user_data_type {printprefs*} callback filenameInput_cb xywh {150 80 190 30} selection_color 12 labelfont 7 labelcolor 31 textfont 4 textsize 12 textcolor 31 deactivate } Fl_Button {s.browseButton} { label {Browse...} user_data {&s} user_data_type {printprefs*} callback browsebutton_cb xywh {340 80 70 30} labelcolor 31 deactivate } Fl_Input {s.titleInput} { label {Page title:} user_data {&s} user_data_type {printprefs*} callback titleInput_cb xywh {150 120 260 30} color 43 selection_color 12 labelfont 7 textfont 4 textsize 12 } } Fl_Tabs {} {open xywh {0 165 430 200} } { Fl_Group {} { label {main parameters} open xywh {0 190 430 175} } { Fl_Group {s.orientationGroup} { label {Orientation:} open tooltip {General page orientation} xywh {155 205 200 30} labelfont 7 align 4 } { Fl_Check_Button {s.portraitCheck} { label Portrait user_data {&s} user_data_type {printprefs*} callback portraitcheck_cb xywh {155 205 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 12 } Fl_Check_Button {s.landscapeCheck} { label Landscape user_data {&s} user_data_type {printprefs*} callback landscapecheck_cb xywh {255 205 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 12 } } Fl_Group {s.papersizeGroup} { label {Paper size:} open xywh {155 235 268 30} labelfont 7 align 4 } { Fl_Choice {s.papersizeChoice} { user_data {&s} user_data_type {printprefs*} callback papersize_cb open tooltip {size of sheet the images will be printed on} xywh {160 235 85 30} down_box BORDER_BOX } { menuitem {} { label Automatic xywh {0 0 100 20} deactivate } menuitem {} { label A5 xywh {0 0 100 20} value 1 } menuitem {} { label B5 xywh {0 0 100 20} value 1 } menuitem {} { label A4 selected xywh {0 0 100 20} value 1 } menuitem {} { label Letter xywh {0 0 100 20} value 1 } menuitem {} { label Legal xywh {0 0 100 20} value 1 } menuitem {} { label A3 xywh {0 0 100 20} value 1 } } } Fl_Group {s.languageGroup} { label {Language:} open tooltip {Use PS for printing and EPS for inclusion in other documents} xywh {155 265 200 30} labelfont 7 align 4 } { Fl_Check_Button {s.psCheck} { label PS user_data {&s} user_data_type {printprefs*} callback pscheck_cb xywh {155 265 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 12 } Fl_Check_Button {s.epsCheck} { label EPS user_data {&s} user_data_type {printprefs*} callback epscheck_cb xywh {255 265 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 12 } } Fl_Group {s.fitGroup} { label {Fit on page:} open tooltip {Print the current image or the whole list, on the one page} xywh {155 294 205 31} labelfont 7 align 4 } { Fl_Check_Button {s.oneImageCheck} { label {One image} user_data {&s} user_data_type {printprefs*} callback oneimagecheck_cb xywh {155 295 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 12 } Fl_Check_Button {s.wholeListCheck} { label {Whole list} user_data {&s} user_data_type {printprefs*} callback wholelistcheck_cb xywh {255 294 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 12 } } Fl_Input {s.nbcopiesInput} { label {Nb copies:} user_data {&s} user_data_type {printprefs*} callback nbcopies_cb tooltip {Single or multiple copies} xywh {155 325 40 30} type Int color 43 selection_color 12 labelfont 7 textfont 4 textsize 12 } Fl_Group {s.subsetGroup} { label {Image:} open tooltip {Prints whole image or only currently displayed subset} xywh {255 325 171 30} labelfont 7 align 4 } { Fl_Check_Button {s.wholeCheck} { label Whole user_data {&s} user_data_type {printprefs*} callback wholecheck_cb xywh {256 325 80 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 12 } Fl_Check_Button {s.subsetCheck} { label Subset user_data {&s} user_data_type {printprefs*} callback subsetcheck_cb xywh {340 325 70 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 12 } } } Fl_Group {} { label margins open xywh {0 190 430 175} hide } { Fl_Group {} { label {custom margins:} open xywh {140 250 265 105} box ENGRAVED_FRAME align 4 deactivate } { Fl_Input {s.leftMarginInput} { label {left:} xywh {190 260 65 25} } Fl_Input {s.rightMarginInput} { label {right:} xywh {320 260 65 25} } Fl_Input {s.topMarginInput} { label {top:} xywh {190 290 65 25} } Fl_Input {s.bottomMarginInput} { label {bottom:} xywh {320 290 65 25} } Fl_Input {s.titleMarginInput} { label {title:} tooltip {Title height} xywh {190 320 65 25} } } Fl_Choice {s.marginDims} { label {Margin dimensions:} user_data {&s} user_data_type {printprefs*} callback marginchoice_cb open xywh {140 215 110 25} down_box BORDER_BOX } { menuitem {s.standardMarginItem} { label standard user_data 0 callback chosenmargin_cb tooltip {reasonable margins all around} xywh {0 0 100 20} } menuitem {s.smallMarginItem} { label small user_data 1 callback chosenmargin_cb tooltip {small margins} xywh {0 0 100 20} } menuitem {s.largeMarginItem} { label large user_data 2 callback chosenmargin_cb tooltip {wide margins} xywh {0 0 100 20} } menuitem {s.zeroMarginItem} { label zero user_data 3 callback chosenmargin_cb tooltip {no margin (print to the edge)} xywh {0 0 100 20} } menuitem {s.customMarginItem} { label custom user_data 4 callback chosenmargin_cb tooltip {define margins below} xywh {0 0 100 20} } } Fl_Choice {} { label {Unit:} open xywh {300 215 105 25} down_box BORDER_BOX } { menuitem {} { label {point (pt)} xywh {0 0 100 20} } menuitem {} { label mm xywh {0 0 100 20} } menuitem {} { label cm xywh {0 0 100 20} } menuitem {} { label {inches (in)} xywh {0 0 100 20} } } } } Fl_Group {} {open xywh {30 375 370 40} } { Fl_Button {s.CancelButton} { label Cancel user_data {&s} user_data_type {printprefs*} callback cancelbutton_cb xywh {30 380 80 30} code0 {o->shortcut("^[");} } Fl_Button {s.PreviewButton} { label Preview user_data {&s} user_data_type {printprefs*} callback previewbutton_cb xywh {180 380 80 30} } Fl_Group {} {open xywh {310 375 90 40} } { Fl_Box {} { xywh {310 375 88 40} box THIN_DOWN_FRAME } Fl_Return_Button {s.OKButton} { label Print user_data {&s} user_data_type {printprefs*} callback okbutton_cb xywh {314 380 80 30} hotspot } } } } } imview-1.1.9c/fluid/prntspectdlg.fl0000644000076500007650000001206307727302500020136 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.00 header_name {.h} code_name {.cxx} gridx 10 gridy 10 snap 3 Function {printspect_panel(printspect &s)} {open } { Fl_Window {s.prefWindow} { label {Print one-dimensional data} open selected xywh {541 300 430 330} type Single box ENGRAVED_BOX code0 {\#include "printSpect.hxx"} modal visible } { Fl_Box {} { xywh {0 164 430 106} box ENGRAVED_BOX } Fl_Group {s.printtypeGroup} { label {Print to:} open xywh {150 10 260 30} labelfont 7 align 4 } { Fl_Check_Button {s.printerCheck} { label Printer user_data {&s} user_data_type {printspect*} callback printercheck_cb xywh {150 10 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 17 } Fl_Check_Button {s.fileCheck} { label File user_data {&s} user_data_type {printspect*} callback filecheck_cb xywh {250 10 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 17 } } Fl_Group {s.inputGroup} {open xywh {150 40 265 110} } { Fl_Input {s.commandInput} { label {Print command:} user_data {&s} user_data_type {printspect*} callback commandInput_cb xywh {150 40 260 30} color 43 selection_color 43 labelfont 7 align 132 textfont 4 textsize 12 } Fl_Input {s.filenameInput} { label {File name:} user_data {&s} user_data_type {printspect*} callback filenameInput_cb xywh {150 80 190 30} selection_color 43 labelfont 7 labelcolor 31 align 132 textfont 4 textsize 12 textcolor 31 deactivate } Fl_Button {s.browseButton} { label {Browse...} user_data {&s} user_data_type {printspect*} callback browsebutton_cb xywh {340 80 70 30} labelcolor 31 deactivate } Fl_Input {s.titleInput} { label {Page title:} user_data {&s} user_data_type {printspect*} callback titleInput_cb xywh {150 120 260 30} color 43 selection_color 43 labelfont 7 align 132 textfont 4 textsize 12 } } Fl_Group {s.orientationGroup} { label {Orientation:} open xywh {150 165 200 30} labelfont 7 align 4 } { Fl_Check_Button {s.portraitCheck} { label Portrait user_data {&s} user_data_type {printspect*} callback portraitcheck_cb xywh {150 165 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 17 } Fl_Check_Button {s.landscapeCheck} { label Landscape user_data {&s} user_data_type {printspect*} callback landscapecheck_cb xywh {250 165 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 17 } } Fl_Group {s.papersizeGroup} { label {Paper size:} open xywh {150 195 268 30} labelfont 7 align 4 } { Fl_Check_Button {s.A4Check} { label A4 user_data {&s} user_data_type {printspect*} callback a4check_cb xywh {150 195 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 17 } Fl_Check_Button {s.letterCheck} { label Letter user_data {&s} user_data_type {printspect*} callback lettercheck_cb xywh {250 195 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 17 } Fl_Check_Button {s.A3Check} { label A3 user_data {&s} user_data_type {printspect*} callback a3check_cb xywh {350 195 50 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 17 } } Fl_Button {s.CancelButton} { label Cancel user_data {&s} user_data_type {printspect*} callback cancelbutton_cb xywh {30 287 80 30} code0 {o->shortcut("^[");} } Fl_Input {s.nbcopiesInput} { label {Nb copies:} user_data {&s} user_data_type {printspect*} callback nbcopies_cb xywh {150 230 40 30} type Int color 43 selection_color 43 labelfont 7 textfont 4 textsize 12 } Fl_Group {s.joinGroup} { label {Join:} open xywh {250 230 170 30} labelfont 7 align 4 } { Fl_Check_Button {s.linesCheck} { label Lines user_data {&s} user_data_type {printspect*} callback linescheck_cb xywh {250 230 80 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 17 } Fl_Check_Button {s.splinesCheck} { label Splines user_data {&s} user_data_type {printspect*} callback splinescheck_cb xywh {350 230 70 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 17 } } Fl_Group {} {open xywh {290 284 110 46} } { Fl_Box {} { xywh {310 284 88 36} box THIN_DOWN_FRAME } Fl_Return_Button {s.OKButton} { label Print user_data {&s} user_data_type {printspect*} callback okbutton_cb xywh {314 287 80 30} hotspot } } Fl_Button {s.previewButton} { label Preview user_data {&s} user_data_type {printspect*} callback previewbutton_cb xywh {210 287 80 30} type Toggle down_box DOWN_BOX when 1 code0 {o->shortcut("p");} } } } imview-1.1.9c/fluid/profile.fl0000644000076500007650000000717607653237110017100 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0011 header_name {.h} code_name {.cxx} gridx 3 gridy 3 snap 3 Function {profile_panel(profile &s)} {open } { Fl_Window {s.profileWindow} { label {Display Profile} open xywh {198 253 622 398} type Double box ENGRAVED_BOX labeltype NORMAL_LABEL align 4 resizable code0 {\#include "profileBox.hxx"} visible } { Fl_Group {} {open xywh {-3 309 621 79} } { Fl_Group {} {open xywh {306 312 312 74} } { Fl_Group {} { label {RGB Range is:} open xywh {306 312 312 30} labelfont 7 align 20 } { Fl_Check_Button {s.absolute} { label Absolute user_data {&s} user_data_type {profile*} callback absolutecheck_cb xywh {520 312 98 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 42 } Fl_Check_Button {s.relative} { label Relative user_data {&s} user_data_type {profile*} callback relativecheck_cb xywh {435 312 87 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 42 } } Fl_Group {} {open xywh {308 350 310 36} } { Fl_Box {} { xywh {507 350 99 36} box THIN_DOWN_FRAME } Fl_Return_Button {s.OKButton} { label {Dismiss } user_data {&s} user_data_type {profile*} callback okbutton_cb xywh {511 353 91 30} hotspot } Fl_Button {s.saveButton} { label Save user_data {&s} user_data_type {profile*} callback savebutton_cb xywh {408 354 91 29} } Fl_Button {s.printButton} { label Print user_data {&s} user_data_type {profile*} callback printbutton_cb xywh {308 354 91 29} } } } Fl_Box {} { xywh {252 312 54 75} resizable } Fl_Group {} {open xywh {-3 309 255 79} } { Fl_Output {s.xvalue} { label {x:} xywh {88 318 68 20} } Fl_Output {s.yvalue} { label {y:} xywh {88 340 68 20} } Fl_Output {s.zvalue} { label {z:} xywh {88 362 68 20} } Fl_Output {s.Rvalue} { label {R:} xywh {181 318 69 20} } Fl_Output {s.Gvalue} { label {G:} xywh {181 340 69 18} } Fl_Output {s.Bvalue} { label {B:} xywh {181 362 69 20} } } } Fl_Group {} {open xywh {0 -144 627 454} resizable } { Fl_Group {} {open xywh {0 0 618 30} } { Fl_Output {s.profileTitle} { xywh {120 3 350 24} box EMBOSSED_BOX selection_color 47 align 0 textcolor 36 resizable } Fl_Check_Button {s.keepline} { label {Keep line:} user_data {&s} user_data_type {profile*} callback keepline_cb xywh {582 3 36 27} down_box ROUND_DOWN_BOX labelfont 7 align 4 } Fl_Box {} { xywh {0 3 120 24} } } Fl_Box {s.profileBox} { user_data {&s} user_data_type {profile*} xywh {66 30 537 260} box EMBOSSED_BOX color 93 selection_color 47 resizable class myProfileBox } Fl_Box {s.abcissaBox} { label {profile length} selected xywh {66 290 537 20} labelsize 10 class axisBox } Fl_Box {s.ordinateBox} { label {profile values} xywh {0 30 66 260} labelsize 10 align 152 class axisBox } } } } imview-1.1.9c/fluid/progress.fl0000644000076500007650000000124507727302500017271 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.00 header_name {.H} code_name {.C} gridx 5 gridy 5 snap 3 Function {progress_panel(progress &p)} {open } { Fl_Window {p.progressWindow} { label {Progress Indicator} open selected xywh {735 239 300 100} type Single resizable code0 {\#include "progressInfo.hxx"} visible } { Fl_Slider {p.progressSlider} { label Progress xywh {25 25 255 25} type {Horz Fill} color 174 selection_color 230 align 1 maximum 100 } Fl_Return_Button {} { label Dismiss user_data {&p} user_data_type {progress *} callback okbutton_cb xywh {195 60 85 25} } } } imview-1.1.9c/fluid/rmpoint.xpm0000644000076500007650000000217407653237110017324 0ustar talbottalbot00000000000000/* XPM */ static char *magick[] = { /* columns rows colors chars-per-pixel */ "32 28 2 1", " c gray0", "# s mask c none", /* pixels */ "################################", "############ #################", "############ # #################", "############ #################", "##### ### ##################", "###### ## # # ##################", "####### ## # ##################", "######## ## # ##################", "######### ## ##################", "## ###### ## ##################", "## #### # ## #################", "## ## # ### ## ################", "## ### #### ## ###############", "#### # # ## ## ##############", "###### ### # ## #############", "###### # ### # ## ############", "###### ### # # ## ###########", "##### ###### ### # #### ####", "##### ####### ### ## ###", "#### ######## # ## ##", "### ######### ####### # ## ##", "### ######### ###### ## ##", "## ########## ###### # ## ###", "## ########## ###### ## ######", "############# ####### ## ######", "############# ######## # ######", "############# ######### ######", "################################" }; imview-1.1.9c/fluid/rotate+90.xpm0000644000076500007650000000377607653237110017367 0ustar talbottalbot00000000000000/* XPM */ static char *magick[] = { /* columns rows colors chars-per-pixel */ "32 28 2 2", " c gray0", ". s mask c none", /* pixels */ ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " }; imview-1.1.9c/fluid/rotate-90.xpm0000644000076500007650000000377607653237111017372 0ustar talbottalbot00000000000000/* XPM */ static char *magick[] = { /* columns rows colors chars-per-pixel */ "32 28 2 2", " c gray0", ". s mask c none", /* pixels */ ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . ", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " }; imview-1.1.9c/fluid/savedlg.fl0000644000076500007650000001037607727302500017057 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0104 header_name {.H} code_name {.C} Function {saveprefs_panel(saveprefs &svpr)} {open } { Fl_Window {svpr.saveWindow} { label {Save an image} open selected xywh {793 662 450 210} type Double box ENGRAVED_BOX code0 {\#include "savePrefs.hxx"} modal visible } { Fl_Box {} { xywh {0 100 450 60} box ENGRAVED_BOX } Fl_Group {svpr.inputGroup} {open xywh {130 20 300 30} selection_color 43 } { Fl_Input {svpr.filenameInput} { label {File name:} user_data {&svpr} user_data_type {saveprefs*} callback filenameinput_cb xywh {130 20 230 30} color 43 selection_color 84 labelfont 7 textfont 4 textsize 12 } Fl_Button {svpr.browseButton} { label {Browse...} user_data {&svpr} user_data_type {saveprefs*} callback browsebutton_cb xywh {360 20 70 30} } } Fl_Group {} {open xywh {130 64 301 26} } { Fl_Choice {svpr.formatChoice} { label {Format:} user_data {&svpr} user_data_type {saveprefs*} callback formatchoice_cb open xywh {130 64 90 26} down_box BORDER_BOX labelfont 7 textfont 4 textsize 12 } { menuitem {svpr.tiffmenuitem} { label TIFF user_data 0 callback chosenformat_cb xywh {0 0 100 20} labelfont 4 labelsize 12 } menuitem zimagemenuitem { label {Z-IMAGE} user_data 1 callback chosenformat_cb xywh {0 0 100 20} labelfont 4 labelsize 12 } menuitem euromenuitem { label Euro user_data 2 callback chosenformat_cb xywh {10 10 100 20} labelfont 4 labelsize 12 hide deactivate } menuitem {svpr.pngmenuitem} { label PNG user_data 3 callback chosenformat_cb xywh {10 10 100 20} value 1 labelfont 4 labelsize 12 } menuitem {svpr.jpgmenuitem} { label JPEG user_data 4 callback chosenformat_cb xywh {20 20 100 20} value 1 labelfont 4 labelsize 12 } } Fl_Choice {svpr.compressionChoice} { label {Compression:} user_data {&svpr} user_data_type {saveprefs*} callback compressionchoice_cb open xywh {340 64 91 26} down_box BORDER_BOX labelfont 7 labelcolor 40 textfont 4 textsize 12 textcolor 40 } { menuitem {} { label None xywh {0 0 100 20} } } } Fl_Group {svpr.subsetGroup} { label {Save image:} open xywh {130 100 200 30} labelfont 7 align 4 } { Fl_Check_Button {svpr.wholeCheck} { label Whole user_data {&svpr} user_data_type {saveprefs*} callback wholecheck_cb xywh {130 100 80 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 84 } Fl_Check_Button {svpr.subsetCheck} { label Subset user_data {&svpr} user_data_type {saveprefs*} callback subsetcheck_cb xywh {250 100 70 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 84 } } Fl_Group svprwhatGroup { label {Save what:} open xywh {130 130 220 30} labelfont 7 align 4 } { Fl_Check_Button {svpr.visibleCheck} { label {Visible image} user_data {&svpr} user_data_type {saveprefs*} callback visiblecheck_cb xywh {130 130 80 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 84 } Fl_Check_Button {svpr.underlyingCheck} { label {Raw data} user_data {&svpr} user_data_type {saveprefs*} callback underlyingcheck_cb xywh {250 130 100 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 83 } } Fl_Button {svpr.CancelButton} { label Cancel user_data {&svpr} user_data_type {saveprefs*} callback cancelbutton_cb xywh {30 170 80 30} code0 {o->shortcut("^[");} } Fl_Group {} {open xywh {324 160 110 50} } { Fl_Box {} { xywh {344 167 88 36} box THIN_DOWN_FRAME } Fl_Return_Button {svpr.OKButton} { label Save user_data {&svpr} user_data_type {saveprefs*} callback okbutton_cb xywh {348 170 80 30} hotspot } } } } imview-1.1.9c/fluid/savespectdlg.fl0000644000076500007650000000440707727302500020114 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0104 header_name {.H} code_name {.C} Function {savespect_panel(savespect &svsp)} {open } { Fl_Window {svsp.saveWindow} { label {Save one-dimensional data} open selected xywh {20 710 440 150} type Single box ENGRAVED_BOX code0 {\#include "saveSpect.hxx"} modal visible } { Fl_Group {svsp.inputGroup} {open xywh {130 20 300 30} selection_color 43 align 129 } { Fl_Input {svsp.filenameInput} { label {Filename:} user_data {&svsp} user_data_type {savespect*} callback filenameinput_cb xywh {130 20 230 30} color 43 selection_color 43 labelfont 7 textfont 4 textsize 12 } Fl_Button {svsp.browseButton} { label {Browse...} user_data {&svsp} user_data_type {savespect*} callback browsebutton_cb xywh {360 20 70 30} } } Fl_Group {} {open xywh {130 64 301 26} } { Fl_Choice {svsp.formatChoice} { label {Format:} user_data {&svsp} user_data_type {savespect*} callback formatchoice_cb open xywh {130 64 90 26} down_box BORDER_BOX labelfont 7 align 132 textfont 4 textsize 12 } { menuitem tiffmenuitem { label TIFF user_data 0 callback chosenSpectFormat_cb xywh {10 10 100 20} labelfont 4 labelsize 12 } menuitem zimagemenuitem { label {Z-IMAGE} user_data 1 callback chosenSpectFormat_cb xywh {0 0 100 20} labelfont 4 labelsize 12 } menuitem euromenuitem { label Euro user_data 2 callback chosenSpectFormat_cb xywh {0 0 100 20} labelfont 4 labelsize 12 } } } Fl_Button {svsp.CancelButton} { label Cancel user_data {&svsp} user_data_type {savespect*} callback cancelbutton_cb xywh {30 107 80 30} code0 {o->shortcut("^[");} } Fl_Group {} {open xywh {324 104 110 46} } { Fl_Box {} { xywh {344 104 88 36} box THIN_DOWN_FRAME } Fl_Return_Button {svsp.OKButton} { label Save user_data {&svsp} user_data_type {savespect*} callback okbutton_cb xywh {348 107 80 30} hotspot } } } } imview-1.1.9c/fluid/selectpoint.xpm0000644000076500007650000000217307653237113020167 0ustar talbottalbot00000000000000/* XPM */ static char *magick[] = { /* columns rows colors chars-per-pixel */ "32 28 2 1", " c gray0", "# s mask c none", /* pixels */ "################################", "# ####################### ##", "# ##", "# ####################### ##", "## ################ ###### ###", "## ##### ##### ### #### ###", "## #### #### ### ####### ### ###", "## ### ###### ## ####### ### ###", "## ### ######### ####### ### ###", "## #### ######### ### #### ###", "## ##### ####### ###### ###", "## ######### ############### ###", "## ########## ############## ###", "## ### ###### ######## ##### ###", "## #### #### ########## #### ###", "## ##### ############ ### ###", "## ############ ### ## ###", "## ############### ###### ## ###", "## ############### ###### ## ###", "## ### #### ###### ## ###", "## ### ###### #### ###### ## ###", "## ### ###### #### ##### ### ###", "## ### ###### #### #### #### ###", "## ### #### ### ##### ###", "## ######################### ###", "# ####################### ##", "# ##", "# ####################### ##" }; imview-1.1.9c/fluid/sliderdlg.fl0000644000076500007650000000163707727302500017403 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0103 header_name {.hxx} code_name {.cxx} Function {slider_panel(slideinput &s)} {open } { Fl_Window {s.sliceWindow} { label {Choose slice} open xywh {247 168 480 45} type Single box ENGRAVED_BOX code0 {\#include "sliceSlider.hxx"} visible } { Fl_Return_Button {} { label Dismiss user_data {&s} user_data_type {slideinput *} callback okbutton_cb selected tooltip {Close window} xywh {385 10 85 25} } Fl_Scrollbar {s.sliceSlider} { user_data {&s} user_data_type {slideinput *} callback sliceslider_cb tooltip {Select slice} xywh {115 10 260 25} type Horizontal color 40 labelcolor 32 } Fl_Value_Input {s.sliceValue} { label {value:} user_data {&s} user_data_type {slideinput *} callback slicevalue_cb tooltip {Drag to change} xywh {55 10 50 25} } } } imview-1.1.9c/fluid/spectra.fl0000644000076500007650000000601107665653027017100 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0103 header_name {.h} code_name {.cxx} Function {spectra_panel(spectra &s)} {open } { Fl_Window {s.spectraWindow} { label {Display spectra} open xywh {1724 497 570 395} type Double box ENGRAVED_BOX align 4 resizable code0 {\#include "spectraBox.hxx"} visible } { Fl_Group {} {open xywh {0 0 560 310} resizable } { Fl_Output {s.spectrumTitle} {selected tooltip {Coordinates of image point} xywh {130 6 290 21} box EMBOSSED_BOX selection_color 47 } Fl_Box {s.spectraBox} { user_data {&s} user_data_type {spectra*} tooltip {Spectrum at selected image point} xywh {48 30 512 260} box EMBOSSED_BOX color 204 selection_color 47 resizable class mySpectraBox } Fl_Box {s.abcissaBox} { xywh {48 290 512 20} class axisBox } Fl_Box {s.ordinateBox} { xywh {0 30 48 260} class axisBox } } Fl_Group {} {open xywh {0 310 556 30} } { Fl_Box {} { xywh {270 310 50 30} resizable } Fl_Group {} {open xywh {0 312 272 28} } { Fl_Output {s.xvalue} { label {component:} tooltip {Component/depth index} xywh {126 312 49 28} } Fl_Output {s.yvalue} { label {value:} tooltip {component value} xywh {222 312 50 28} } } Fl_Group {} { label {Display is:} open xywh {390 310 166 30} align 4 } { Fl_Check_Button {s.absolute} { label Absolute user_data {&s} user_data_type {spectra*} callback absolutecheck_cb tooltip {Display fixed range (0-255)} xywh {472 310 84 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 42 } Fl_Check_Button {s.relative} { label Relative user_data {&s} user_data_type {spectra*} callback relativecheck_cb tooltip {Fit to display range} xywh {390 310 84 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 42 } } } Fl_Group {} {open xywh {0 340 560 40} } { Fl_Group {} {open xywh {260 340 300 40} } { Fl_Box {} { xywh {459 344 99 36} box THIN_DOWN_FRAME } Fl_Return_Button {s.OKButton} { label {Dismiss } user_data {&s} user_data_type {spectra*} callback okbutton_cb tooltip {Close window} xywh {463 347 91 30} hotspot } Fl_Button {s.saveButton} { label Save user_data {&s} user_data_type {spectra*} callback savebutton_cb tooltip {Save to text or binary format} xywh {360 348 91 29} } Fl_Button {s.printButton} { label Print user_data {&s} user_data_type {spectra*} callback printbutton_cb tooltip {Print spectrum (or save to PS)} xywh {260 348 91 29} } } Fl_Group {} {open xywh {0 340 250 40} resizable } {} } } } imview-1.1.9c/fluid/tmpmsgdlg.fl0000644000076500007650000000124407727302500017422 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.00 header_name {.H} code_name {.C} gridx 5 gridy 5 snap 3 Function {tmpmsg_panel(tmpmsg &tm)} {open } { Fl_Window {tm.outputWindow} { label {Warning message ring} open selected xywh {495 270 520 335} type Single color 15 resizable code0 {\#include "tmpMsg.hxx"} visible } { Fl_Output {tm.MessageOutput} { label Warning xywh {20 25 480 265} type Multiline box ENGRAVED_BOX color 197 labelfont 9 labelsize 16 align 1 resizable } Fl_Return_Button {} { label Dismiss callback {((Fl_Window*)(o->parent()))->hide();} xywh {395 300 105 25} } } } imview-1.1.9c/fluid/toolbardlg.fl0000644000076500007650000000562110066460704017561 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0105 header_name {.h} code_name {.cxx} Function {toolbar_panel(toolbar &tb)} {open } { Fl_Window {tb.toolbarWindow} { label Toolbar open xywh {1856 80 540 60} type Single box ENGRAVED_BOX code0 {\#include "toolbar.hxx"} visible } { Fl_Group {} {open xywh {5 5 270 50} box ENGRAVED_FRAME align 16 } { Fl_Button {} { user_data {&tb} user_data_type {toolbar*} callback setzoommode_cb tooltip {Zoom mode, toggles constrained/unconstrained zoom} image {zoom_s.xpm} xywh {10 10 40 40} type Radio value 1 selection_color 42 labelsize 10 class tipButton } Fl_Button {} { user_data {&tb} user_data_type {toolbar*} callback setmeasuremode_cb tooltip {Measurement mode, shortcut = } image {measure.xpm} xywh {55 10 40 40} type Radio selection_color 41 labelsize 10 class tipButton } Fl_Choice {} { user_data {&tb} user_data_type {toolbar*} callback setpointmode_cb open selected tooltip {Point modes} image {pencil.xpm} xywh {140 10 130 40} down_box BORDER_BOX when 6 } { menuitem {} { label {Add points} tooltip {Add point} xywh {0 0 100 20} } menuitem {} { label {Select points} tooltip {Select points} xywh {10 10 100 20} } menuitem {} { label {Draw points} tooltip {Draw points} xywh {20 20 100 20} } menuitem {} { label {Rm points} tooltip {Remove a single point} xywh {10 10 100 20} } menuitem {} { label {Remove group} tooltip {Remove a whole groups} xywh {20 20 100 20} } } } Fl_Group {} {open xywh {280 5 175 50} box ENGRAVED_FRAME align 16 } { Fl_Button {} { callback local_rotate90right_cb tooltip {Rotate 90 degree clockwise} image {rotate+90.xpm} xywh {285 10 40 40} labelsize 10 class tipButton } Fl_Button {} { callback local_rotate90left_cb tooltip {Rotate 90 degree counter-clockwise} image {rotate-90.xpm} xywh {325 10 45 40} labelsize 10 class tipButton } Fl_Button {} { callback local_flipv_cb tooltip {Flip image horizontally} image {flipv.xpm} xywh {370 10 40 40} labelsize 10 class tipButton } Fl_Button {} { callback local_fliph_cb tooltip {Flip image vertically} image {fliph.xpm} xywh {410 10 40 40} labelsize 10 class tipButton } } Fl_Group {} {open xywh {460 5 55 50} box ENGRAVED_FRAME align 16 } { Fl_Button {} { user_data {&tb} user_data_type {toolbar*} callback hidetoolbar_cb tooltip {Hide in shadow} image {hidetoolbar.xpm} xywh {465 10 45 40} labelsize 10 class tipButton } } } } imview-1.1.9c/fluid/transfer.fl0000644000076500007650000001105607727302500017252 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0104 header_name {.H} code_name {.C} Function {transfer_panel(transfer &s)} {open } { Fl_Window {s.transferWindow} { label {Edit transfer function} open selected xywh {670 500 570 330} type Double box THIN_UP_BOX code0 {\#include "transferFunction.hxx"} code1 {\#include "transferBox.hxx"} visible } { Fl_Group {} {open xywh {453 277 110 50} } { Fl_Box {} { xywh {462 284 99 36} box THIN_DOWN_FRAME } Fl_Return_Button {s.OKButton} { label {Dismiss } user_data {&s} user_data_type {transfer*} callback okbutton_cb xywh {466 287 91 30} hotspot } } Fl_Group {} {open xywh {10 9 402 321} } { Fl_Box {} { xywh {20 10 370 266} box EMBOSSED_FRAME } Fl_Slider {s.contrastSlider} { label {Contrast } user_data {&s} user_data_type {transfer*} callback contrastslider_cb tooltip {Change slope of transfer function} xywh {20 280 370 20} type Horizontal labelsize 12 align 8 code0 {o->when(FL_WHEN_CHANGED|FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);} } Fl_Box {s.transferBox} { user_data {&s} user_data_type {transfer*} tooltip {Transfer function graph} xywh {25 15 360 256} box FLAT_BOX color 199 selection_color 47 class myTransferBox } Fl_Slider {s.brightnessSlider} { label {Brightness } user_data {&s} user_data_type {transfer*} callback brightnessslider_cb tooltip {Change additive constant to transfer function} xywh {20 300 370 20} type Horizontal labelsize 12 align 8 code0 {o->when(FL_WHEN_CHANGED|FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);} } Fl_Slider {s.gammaSlider} { user_data {&s} user_data_type {transfer*} callback gammaslider_cb tooltip {Change gamma} xywh {393 11 19 264} labelsize 12 align 4 code0 {o->when(FL_WHEN_CHANGED|FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);} } } Fl_Choice {s.displayChoice} { user_data {&s} user_data_type {transfer*} callback displaychoice_cb open tooltip {Display transfer function or histogram} xywh {420 10 140 30} down_box BORDER_BOX align 0 textsize 12 } {} Fl_Button {s.resetButton} { label reset user_data {&s} user_data_type {transfer*} callback resetbutton_cb tooltip {reset to linear, 1:1 transfer} xywh {420 50 68 20} labelsize 12 } Fl_Button {s.normaliseButton} { label normalise user_data {&s} user_data_type {transfer*} callback normalisebutton_cb tooltip {set min to black and max to white} xywh {494 50 66 19} labelsize 12 } Fl_Input {s.gammaInput} { label {Gamma:} user_data {&s} user_data_type {transfer*} callback gammainput_cb tooltip {transfer function = 1^(1/gamma)} xywh {469 124 90 30} type Float labelsize 12 when 8 textsize 12 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Float_Input } Fl_Input {s.topInput} { label {Top:} user_data {&s} user_data_type {transfer*} callback topinput_cb tooltip {intersection with top edge of box} xywh {469 154 90 30} type Int labelsize 12 when 8 textsize 12 class Fl_Int_Input } Fl_Input {s.bottomInput} { label {Bottom:} user_data {&s} user_data_type {transfer*} callback bottominput_cb tooltip {intersection with bottom edge of box} xywh {469 184 90 30} type Int labelsize 12 when 8 textsize 12 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Int_Input } Fl_Input {s.leftInput} { label {Left:} user_data {&s} user_data_type {transfer*} callback leftinput_cb tooltip {intersection with left edge of box} xywh {469 214 90 30} type Int labelsize 12 when 8 textsize 12 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Int_Input } Fl_Input {s.rightInput} { label {Right:} user_data {&s} user_data_type {transfer*} callback rightinput_cb tooltip {intersection with right edge of box} xywh {469 244 90 30} type Int labelsize 12 when 8 textsize 12 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Int_Input } Fl_Check_Button {s.applyToAllButton} { label {Apply to all images} user_data {&s} user_data_type {transfer*} callback applytoallbutton_cb tooltip {Apply same transfer to all images} xywh {420 80 140 20} box UP_FRAME down_box ROUND_UP_BOX selection_color 130 labelsize 12 align 16 } } } imview-1.1.9c/fluid/transfer2.fl0000644000076500007650000003370010211621421017320 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0106 header_name {.H} code_name {.C} Function {RGB_transfer_panel(transferRGB &s)} {open } { Fl_Window {s.RGBtransferWindow} { label {Edit transfer function} open selected xywh {1828 57 655 515} type Double resizable code0 {\#include "transferRGBFunction.hxx"} code1 {\#include "transferRGBBox.hxx"} visible } { Fl_Group {} { xywh {490 345 160 167} } { Fl_Box {} { xywh {490 345 160 130} resizable } Fl_Group {} {open xywh {490 475 159 37} } { Fl_Group {} {open xywh {550 475 99 37} } { Fl_Box {} { xywh {550 475 99 37} box THIN_DOWN_FRAME } Fl_Return_Button {s.OKButton} { label {Dismiss } user_data {&s} user_data_type {transferRGB*} callback okbutton_cb xywh {554 479 91 30} } } Fl_Box {} { xywh {490 475 60 35} resizable } } } Fl_Group {} { label link xywh {0 370 490 140} align 8 } { Fl_Group {} {open xywh {420 370 70 140} align 8 } { Fl_Group {} {open xywh {420 370 50 40} } { Fl_Box {} { xywh {420 380 50 20} box BORDER_FRAME color 0 } Fl_Box {} { xywh {420 370 30 40} box FLAT_BOX } } Fl_Group {} {open xywh {420 420 50 40} } { Fl_Box {} { xywh {420 430 50 20} box BORDER_FRAME color 0 } Fl_Box {} { xywh {420 420 30 40} box FLAT_BOX } } Fl_Group {} {open xywh {420 470 50 40} } { Fl_Box {} { xywh {420 480 50 19} box BORDER_FRAME color 0 } Fl_Box {} { xywh {420 470 30 40} box FLAT_BOX } } Fl_Group {} {open xywh {460 380 30 120} } { Fl_Group {} {open xywh {460 388 30 102} } { Fl_Group {} {open xywh {460 388 30 52} } { Fl_Box {} { xywh {469 389 21 51} box BORDER_FRAME color 0 } Fl_Box {} { xywh {460 400 20 30} box FLAT_BOX } } Fl_Group {} {open xywh {460 438 30 52} } { Fl_Box {} { xywh {469 439 21 51} box BORDER_FRAME color 0 } Fl_Box {} { xywh {460 450 20 30} box FLAT_BOX } } } Fl_Round_Button {s.linkRButton} { xywh {470 380 20 20} down_box ROUND_DOWN_BOX selection_color 3 } Fl_Round_Button {s.linkGButton} { xywh {470 430 20 20} down_box ROUND_DOWN_BOX selection_color 3 } Fl_Round_Button {s.linkBButton} { xywh {470 480 20 20} down_box ROUND_DOWN_BOX selection_color 3 } } } Fl_Group {} {open xywh {30 370 370 140} resizable } { Fl_Slider {s.RcontrastSlider} { label {R cntrst} user_data {&s} user_data_type {transferRGB*} callback contrastslider_cb xywh {30 370 370 20} type {Horz Knob} color 9 labelsize 12 align 8 code0 {o->when(FL_WHEN_CHANGED|FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);} } Fl_Slider {s.RbrightnessSlider} { label {R bright} user_data {&s} user_data_type {transferRGB*} callback brightnessslider_cb xywh {30 390 370 20} type {Horz Knob} color 9 labelsize 12 align 8 code0 {o->when(FL_WHEN_CHANGED|FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);} } Fl_Slider {s.GcontrastSlider} { label {G cntrst} user_data {&s} user_data_type {transferRGB*} callback contrastslider_cb xywh {30 420 370 20} type {Horz Knob} color 10 labelsize 12 align 8 code0 {o->when(FL_WHEN_CHANGED|FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);} } Fl_Slider {s.GbrightnessSlider} { label {G bright} user_data {&s} user_data_type {transferRGB*} callback brightnessslider_cb xywh {30 440 370 20} type {Horz Knob} color 10 labelsize 12 align 8 code0 {o->when(FL_WHEN_CHANGED|FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);} } Fl_Slider {s.BcontrastSlider} { label {B cntrst} user_data {&s} user_data_type {transferRGB*} callback contrastslider_cb xywh {30 470 370 20} type {Horz Knob} color 12 labelsize 12 align 8 code0 {o->when(FL_WHEN_CHANGED|FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);} } Fl_Slider {s.BbrightnessSlider} { label {B bright} user_data {&s} user_data_type {transferRGB*} callback brightnessslider_cb xywh {30 490 370 20} type {Horz Knob} color 12 labelsize 12 align 8 code0 {o->when(FL_WHEN_CHANGED|FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);} } } Fl_Box {} { xywh {0 370 30 140} } } Fl_Group {} { label gamma xywh {420 0 60 370} align 17 } { Fl_Group {} {open xywh {420 20 60 320} resizable } { Fl_Slider {s.RgammaSlider} { user_data {&s} user_data_type {transferRGB*} callback gammaslider_cb xywh {420 20 20 320} type {Vert Knob} color 9 labelsize 12 align 4 code0 {o->when(FL_WHEN_CHANGED|FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);} } Fl_Slider {s.GgammaSlider} { user_data {&s} user_data_type {transferRGB*} callback gammaslider_cb xywh {440 20 20 320} type {Vert Knob} color 10 labelsize 12 align 4 code0 {o->when(FL_WHEN_CHANGED|FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);} } Fl_Slider {s.BgammaSlider} { user_data {&s} user_data_type {transferRGB*} callback gammaslider_cb xywh {460 20 20 320} type {Vert Knob} color 12 labelsize 12 align 4 code0 {o->when(FL_WHEN_CHANGED|FL_WHEN_RELEASE|FL_WHEN_NOT_CHANGED);} } } Fl_Box {} { xywh {420 340 60 30} } Fl_Box {} { xywh {420 0 60 25} } } Fl_Group {s.displayBoxGroup} {open xywh {0 10 400 350} resizable } { Fl_Box {s.RGBtransferBox} { user_data {&s} user_data_type {transfer*} xywh {30 20 370 320} box ENGRAVED_BOX color 43 selection_color 47 resizable class myTransferRGBBox } Fl_Group {} {open xywh {30 340 370 20} } { Fl_Box {} { label {Input data range} xywh {50 340 330 20} labelsize 12 resizable } Fl_Box {} { label min xywh {30 340 20 20} labelsize 12 } Fl_Box {} { label max xywh {380 340 20 20} labelsize 12 } } Fl_Group {} {open xywh {0 20 30 320} } { Fl_Box {} { label {out val} xywh {0 30 30 300} labelsize 12 align 128 resizable } Fl_Box {} { label 0 xywh {0 330 30 10} labelsize 12 } Fl_Box {} { label 255 xywh {0 20 30 15} labelsize 12 } } } Fl_Group {} {open xywh {490 0 160 345} } { Fl_Group {} {open xywh {490 20 160 320} box ENGRAVED_FRAME } { Fl_Choice {s.displayChoice} { user_data {&s} user_data_type {transferRGB*} callback displaychoice_cb open xywh {500 30 140 30} down_box BORDER_BOX align 0 textsize 10 } {} Fl_Button {s.resetButton} { label reset user_data {&s} user_data_type {transferRGB*} callback resetbutton_cb xywh {500 66 60 24} labelsize 12 } Fl_Button {s.normaliseButton} { label normalise user_data {&s} user_data_type {transferRGB*} callback normalisebutton_cb xywh {570 66 70 24} labelsize 12 } Fl_Check_Button {s.applyToAllButton} { label {Apply to all images} user_data {&s} user_data_type {transferRGB*} callback applytoallbutton_cb xywh {499 305 141 20} box UP_FRAME down_box ROUND_UP_BOX selection_color 130 labelsize 12 align 16 } Fl_Group {} { label {Affected:} open xywh {540 110 95 25} labelsize 10 align 132 } { Fl_Button {s.Rselect} { label R user_data {&s} user_data_type {transferRGB*} callback selectchannel_cb xywh {540 110 25 25} type Toggle value 1 color 9 selection_color 1 } Fl_Button {s.Gselect} { label G user_data {&s} user_data_type {transferRGB*} callback selectchannel_cb xywh {575 110 25 25} type Toggle value 1 color 10 selection_color 2 } Fl_Button {s.Bselect} { label B user_data {&s} user_data_type {transferRGB*} callback selectchannel_cb xywh {610 110 25 25} type Toggle value 1 color 12 selection_color 4 } } Fl_Group {} {open xywh {535 145 105 150} } { Fl_Input {s.RgammaInput} { label {Gamma:} user_data {&s} user_data_type {transferRGB*} callback gammainput_cb xywh {535 145 35 30} type Float color 9 labelsize 10 when 8 textsize 10 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Float_Input } Fl_Input {s.RtopInput} { label {Top:} user_data {&s} user_data_type {transferRGB*} callback topinput_cb xywh {535 175 35 30} type Int color 9 labelsize 10 when 8 textsize 10 class Fl_Int_Input } Fl_Input {s.RbottomInput} { label {Bottom:} user_data {&s} user_data_type {transferRGB*} callback bottominput_cb xywh {535 205 35 30} type Int color 9 labelsize 10 when 8 textsize 10 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Int_Input } Fl_Input {s.RleftInput} { label {Left:} user_data {&s} user_data_type {transferRGB*} callback leftinput_cb xywh {535 235 35 30} type Int color 9 labelsize 10 when 8 textsize 10 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Int_Input } Fl_Input {s.RrightInput} { label {Right:} user_data {&s} user_data_type {transferRGB*} callback rightinput_cb xywh {535 265 35 30} type Int color 9 labelsize 10 when 8 textsize 10 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Int_Input } Fl_Input {s.GgammaInput} { user_data {&s} user_data_type {transferRGB*} callback gammainput_cb xywh {570 145 35 30} type Float color 10 labelsize 10 when 8 textsize 10 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Float_Input } Fl_Input {s.GtopInput} { user_data {&s} user_data_type {transferRGB*} callback topinput_cb xywh {570 175 35 30} type Int color 10 labelsize 10 when 8 textsize 10 class Fl_Int_Input } Fl_Input {s.GbottomInput} { user_data {&s} user_data_type {transferRGB*} callback bottominput_cb xywh {570 205 35 30} type Int color 10 labelsize 10 when 8 textsize 10 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Int_Input } Fl_Input {s.GleftInput} { user_data {&s} user_data_type {transferRGB*} callback leftinput_cb xywh {570 235 35 30} type Int color 10 labelsize 10 when 8 textsize 10 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Int_Input } Fl_Input {s.GrightInput} { user_data {&s} user_data_type {transferRGB*} callback rightinput_cb xywh {570 265 35 30} type Int color 10 labelsize 10 when 8 textsize 10 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Int_Input } Fl_Input {s.BgammaInput} { user_data {&s} user_data_type {transferRGB*} callback gammainput_cb xywh {605 145 35 30} type Float color 12 labelsize 10 when 8 textsize 10 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Float_Input } Fl_Input {s.BtopInput} { user_data {&s} user_data_type {transferRGB*} callback topinput_cb xywh {605 175 35 30} type Int color 12 labelsize 10 when 8 textsize 10 class Fl_Int_Input } Fl_Input {s.BbottomInput} { user_data {&s} user_data_type {transferRGB*} callback bottominput_cb xywh {605 205 35 30} type Int color 12 labelsize 10 when 8 textsize 10 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Int_Input } Fl_Input {s.BleftInput} { user_data {&s} user_data_type {transferRGB*} callback leftinput_cb xywh {605 235 35 30} type Int color 12 labelsize 10 when 8 textsize 10 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Int_Input } Fl_Input {s.BrightInput} { user_data {&s} user_data_type {transferRGB*} callback rightinput_cb xywh {605 265 35 30} type Int color 12 labelsize 10 when 8 textsize 10 code0 {o->when(FL_WHEN_RELEASE|FL_WHEN_ENTER_KEY);} class Fl_Int_Input } } } Fl_Box {} { xywh {490 340 160 5} resizable } Fl_Box {} { xywh {490 0 160 20} } } } } imview-1.1.9c/fluid/userprefdlg.fl0000644000076500007650000003037210736204165017754 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0107 header_name {.H} code_name {.C} Function {userprefs_panel(userprefs &up)} {open } { Fl_Window {up.userprefsWindow} { label {User Preferences} open xywh {1699 227 575 330} type Single box ENGRAVED_BOX code0 {\#include "userPrefs.hxx"} visible } { Fl_Tabs {} {open xywh {5 25 560 245} box THIN_UP_FRAME code0 {o->value(up.generalGroup);} } { Fl_Group {up.generalGroup} { label General open xywh {10 55 550 210} box FLAT_BOX hide } { Fl_Round_Button {up.smoothWhenZoomoutButton} { label {Smooth when zooming out: } user_data {&up} user_data_type {userprefs*} callback smoothzoomout_cb tooltip {Linear interpolation for zoom factors < 1.0} xywh {204 110 25 25} down_box ROUND_DOWN_BOX align 4 } Fl_Group {} { label {Default zoom behaviour is:} open tooltip {Constrain (or not) zoom box to same aspect ratio as main window} xywh {200 135 300 30} align 4 } { Fl_Check_Button {up.constrainZoomCheck} { label Constrained user_data {&up} user_data_type {userprefs*} callback constrainedzoom_cb xywh {200 135 30 30} type Radio down_box DIAMOND_DOWN_BOX value 1 selection_color 39 align 8 } Fl_Check_Button {up.unconstrainZoomCheck} { label Unconstrained user_data {&up} user_data_type {userprefs*} callback unconstrainedzoom_cb xywh {325 135 30 30} type Radio down_box DIAMOND_DOWN_BOX selection_color 39 align 8 } } Fl_Group {} {open xywh {202 75 353 30} } { Fl_Input {up.pathToPrefsInput} { label {Path to preference file: } tooltip {Changing that does nothing -- information only} xywh {205 80 280 25} textfont 4 textsize 12 code0 {o->value("preferences");} } Fl_Button {up.prefBrowse} { label Browse user_data {&up} user_data_type {userprefs*} callback prefbrowse_cb xywh {485 80 70 25} deactivate } } Fl_Round_Button {up.keepPointsButton} { label {Keep points when switching images: } user_data {&up} user_data_type {userprefs*} callback keeppoints_cb tooltip {Keep points (as in pointfiles) on display} xywh {530 110 25 25} down_box ROUND_DOWN_BOX align 4 } Fl_Value_Slider {up.transparencyValueSlider} { label {Overlay transparency:} user_data {&up} user_data_type {userprefs*} callback transparency_cb tooltip {0 = fully transparent ; 1= fully opaque} xywh {200 165 355 25} type Horizontal align 4 when 4 step 0.05 } } Fl_Group {} { label Postscript open xywh {10 55 550 210} box FLAT_BOX } { Fl_Group {} {open xywh {170 70 385 25} } { Fl_Input {up.pathToGsInput} { label {Path to Ghostscript:} user_data {&up} user_data_type {userprefs*} callback pathtogsinput_cb tooltip {Path to postscript interpreter} xywh {170 70 315 25} textfont 4 textsize 12 code0 {o->value("gs");} } Fl_Button {up.gsBrowse} { label Browse user_data {&up} user_data_type {userprefs*} callback gsbrowse_cb xywh {485 70 70 25} deactivate } } Fl_Group {} {open xywh {170 105 130 25} align 0 } { Fl_Input {up.renderInput} { label {Render at:} user_data {&up} user_data_type {userprefs*} callback renderinput_cb tooltip {Resolution at which the file is rendered} xywh {170 105 75 25} type Int textfont 4 textsize 12 code0 {o->value("300");} class Fl_Int_Input } Fl_Box {} { label dpi xywh {245 105 55 25} align 20 } } Fl_Group {} {open xywh {355 105 130 25} } { Fl_Input {up.displayInput} { label {display at:} user_data {&up} user_data_type {userprefs*} callback displayinput_cb tooltip {Display resolution} xywh {355 105 75 25} type Int textfont 4 textsize 12 code0 {o->value("150");} class Fl_Int_Input } Fl_Box {} { label dpi xywh {430 105 55 25} align 20 } } Fl_Group {} { label {Render in:} open tooltip {Use colour except if speed is an issue} xywh {170 135 275 25} align 132 } { Fl_Check_Button {up.colourCheck} { label colour user_data {&up} user_data_type {userprefs*} callback colourcheck_cb xywh {170 135 70 25} type Radio down_box DIAMOND_DOWN_BOX selection_color 39 } Fl_Check_Button {up.greyCheck} { label grey user_data {&up} user_data_type {userprefs*} callback greycheck_cb xywh {270 135 70 25} type Radio down_box DIAMOND_DOWN_BOX selection_color 39 } Fl_Check_Button {up.bwCheck} { label {binary b&&w} user_data {&up} user_data_type {userprefs*} callback bwcheck_cb xywh {355 135 90 25} type Radio down_box DIAMOND_DOWN_BOX value 1 selection_color 39 } } Fl_Group {} {open xywh {105 165 325 25} } { Fl_Round_Button {up.antialiasButton} { label {Antialias:} user_data {&up} user_data_type {userprefs*} callback aabutton_cb tooltip {Smoothing at the rendering level} xywh {355 165 20 25} down_box ROUND_DOWN_BOX value 1 align 4 } Fl_Round_Button {up.smoothButton} { label {Smooth:} user_data {&up} user_data_type {userprefs*} callback smoothbutton_cb tooltip {Smooth at the display level} xywh {170 165 20 25} down_box ROUND_DOWN_BOX value 1 align 4 } } Fl_Choice {up.boundingChoice} { label {Bounding box:} user_data {&up} user_data_type {userprefs*} callback boundingchoice_cb open tooltip {Set this if the display is truncated} xywh {170 195 125 25} down_box BORDER_BOX } { MenuItem {} { label Automatic xywh {0 0 100 20} } MenuItem {} { label A5 xywh {0 0 100 20} } MenuItem {} { label B5 xywh {5 5 100 20} value 1 } MenuItem {} { label A4 xywh {0 0 100 20} value 1 } MenuItem {} { label Letter xywh {0 0 100 20} value 1 } MenuItem {} { label Legal xywh {10 10 100 20} value 1 } MenuItem {} { label A3 xywh {20 20 100 20} value 1 } } Fl_Group {} {open xywh {170 230 385 25} } { Fl_Input {up.pathToPSPreviewer} { label {Path to previewer:} user_data {&up} user_data_type {userprefs*} callback pathtogvinput_cb selected tooltip {Postscript previewer (for print preview)} xywh {170 230 315 25} textfont 4 textsize 12 code0 {o->value("ghostview");} } Fl_Button {up.gvBrowse} { label Browse user_data {&up} user_data_type {userprefs*} callback gsbrowse_cb xywh {485 230 70 25} deactivate } } } Fl_Group {} { label Server xywh {10 55 550 210} box FLAT_BOX hide } { Fl_Group {} {open xywh {25 70 530 55} box ENGRAVED_BOX labelfont 10 } { Fl_Slider {up.pollFrequencySlider} { label {Poll frequency} user_data {&up} user_data_type {userprefs*} callback pollslider_cb tooltip {Influences speed of image loadup via server} xywh {125 75 320 25} type Horizontal align 4 } Fl_Input {up.pollFrequencyInput} { user_data {&up} user_data_type {userprefs*} callback pollinput_cb xywh {455 75 65 25} type Float when 8 code0 {o->value("100");} class Fl_Float_Input } Fl_Box {} { label Hz xywh {520 70 35 30} } Fl_Box {} { label 10 xywh {115 100 25 25} } Fl_Box {} { label 1000 xywh {420 100 40 25} } Fl_Box {} { label 100 xywh {275 100 25 25} } } Fl_Group {} { label Security open xywh {25 155 155 45} box ENGRAVED_BOX labelfont 10 } { Fl_Round_Button {up.securityPasswordButton} { label {Require password} user_data {&up} user_data_type {userprefs*} callback requirepassword_cb xywh {155 155 25 25} down_box ROUND_DOWN_BOX align 4 deactivate } Fl_Round_Button {up.securityLocalhostButton} { label {Localhost only} user_data {&up} user_data_type {userprefs*} callback localhostonly_cb xywh {155 175 25 25} down_box ROUND_DOWN_BOX align 4 deactivate } } Fl_Box {} { label {<- these settings not available yet} xywh {190 165 255 25} labelfont 3 align 20 } } Fl_Group {} { label Expert open xywh {10 55 550 210} box FLAT_BOX hide } { Fl_Round_Button {up.hideMenuButton} { label {Hide menu} user_data {&up} user_data_type {userprefs*} callback hidemenu_cb tooltip {Will hide the main menu} xywh {100 65 25 25} down_box ROUND_DOWN_BOX align 4 } } Fl_Group {} { label Debug xywh {10 50 550 215} box FLAT_BOX hide } { Fl_Box {} { label {Do not modify anything here unless you know what you are doing!!} xywh {51 74 500 20} box ENGRAVED_BOX labelfont 3 } Fl_Round_Button {up.showDebugMsgButton} { label {Show debug messages} user_data {&up} user_data_type {userprefs*} callback showdebug_cb xywh {275 110 30 25} down_box ROUND_DOWN_BOX align 4 } Fl_Round_Button {up.stopAfterDebugMsgButton} { label {Stop after each debug message} user_data {&up} user_data_type {userprefs*} callback stopdebug_cb xywh {275 135 30 25} down_box ROUND_DOWN_BOX align 4 } Fl_Input {up.xorValueBreakLineInput} { label {XOR value for `break' lines:} user_data {&up} user_data_type {userprefs*} callback xorbreakline_cb xywh {280 170 120 25} textfont 4 textsize 12 code0 {o->value("0xffffffff");} } Fl_Input {up.xorValueProfileLineInput} { label {XOR value for profile lines:} user_data {&up} user_data_type {userprefs*} callback xorprofileline_cb xywh {280 200 120 25} textfont 4 textsize 12 code0 {o->value("0xffffffff");} } Fl_Box {} { label {This item won't be saved} xywh {295 116 265 15} labelfont 2 labelsize 12 align 20 } Fl_Box {} { label {This item won't be saved} xywh {295 141 265 15} labelfont 2 labelsize 12 align 20 } } } Fl_Group {} { xywh {265 285 300 35} } { Fl_Group {} {open xywh {470 285 95 35} box THIN_DOWN_FRAME } { Fl_Return_Button {up.OKButton} { label OK user_data {&up} user_data_type {userprefs*} callback okbutton_cb xywh {475 290 85 25} } } Fl_Button {up.saveButton} { label Save user_data {&up} user_data_type {userprefs*} callback savebutton_cb xywh {370 290 90 25} } Fl_Button {up.cancelButton} { label Cancel user_data {&up} user_data_type {userprefs*} callback cancelbutton_cb xywh {265 290 95 25} } } } } imview-1.1.9c/fluid/view3ddlg.fl0000644000076500007650000000144610211621421017304 0ustar talbottalbot00000000000000# data file for the Fltk User Interface Designer (fluid) version 1.0106 header_name {.h} code_name {.cxx} Function {view3d_panel(view3D &s)} {open selected } { Fl_Window {s.view3dWindow} { label {3D view} open xywh {1694 160 520 450} type Double resizable code0 {\#include "view3d.hxx"} code1 {\#include "simpleViewer.hxx"} visible } { Fl_Tile {s.contentTile} {open xywh {0 0 520 450} } { Fl_Group {s.topView} {open xywh {0 0 235 245} box EMBOSSED_FRAME class simpleViewer } {} Fl_Group {} {open xywh {235 0 285 245} box EMBOSSED_FRAME } {} Fl_Group {} {open xywh {0 245 235 205} box EMBOSSED_FRAME } {} Fl_Group {} {open xywh {235 245 285 205} box EMBOSSED_FRAME } {} } } } imview-1.1.9c/fluid/zoom_s.xpm0000644000076500007650000000233207653237116017144 0ustar talbottalbot00000000000000/* XPM */ static char * zoom_s_xpm[] = { "33 31 2 1", " s mask c none", ". c #000000000000", " ", " ", " ", " ............ ", " . . . . . ", " . . . . ", " . . . . ", " . ................... ", " . . . . ", " . . . . ", " . . . . ", " ........... . ", " . . ", " . . . . ", " . . . . ", " . . . ", " . . . ", " . . . . ", " . . . ", " . . . . ", " .. . ", " ................... ", " ....... ", " .. ", " .. .... .... ... ... ", " .. .. .. .. .. .. .. ..", " .. . . . . .. .. ..", " .. . . . . .. .. ..", " .. .. .. .. .. .. .. ..", " ....... .... .... .. .. ..", " "}; imview-1.1.9c/header.txt0000644000076500007650000000315407653236461016003 0ustar talbottalbot00000000000000/* * $Id: header.txt,v 4.0 2003/04/28 14:39:45 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Most of imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ imview-1.1.9c/imageInfo.cxx0000644000076500007650000001235207730062750016426 0ustar talbottalbot00000000000000/* * $Id: imageInfo.cxx,v 4.2 2003/09/11 12:09:12 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * An image info panel using fluid * * Hugues Talbot 2 May 1998 * *-----------------------------------------------------------------------*/ #include #include #include "imview.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "menubar.hxx" #include "imageInfo.hxx" extern char *imgDesc; extern imageIO *IOBlackBox; extern imageViewer *mainViewer; imageinfo::imageinfo() { dbgprintf("Image info panel constructed\n"); // make sure this is done, fluid depends on it... outputWindow = 0; return; } void imageinfo::setDefaults() { dbgprintf("Setting defaults for info panel\n"); textOutput->value("We have no information at this stage...\n"); return; } void imageinfo::update(bool forced) { static char buffer[2048]; static char tmpbuf[100]; if (outputWindow && (outputWindow->visible() || forced)) { if (IOBlackBox->imageData() == 0) { sprintf(buffer, "No image present\n"); } else { int x, y, w, h; sprintf(buffer, "Path to image: %s\n", IOBlackBox->getImName()); int spp = IOBlackBox->getCurrImgNbSamples(); sprintf(tmpbuf, "Size: %dx%dx%d, %d sample%c\n", IOBlackBox->imageWidth(), IOBlackBox->imageHeight(), IOBlackBox->imageThickness(), spp, (spp > 1) ? 's':' ' ); strcat(buffer, tmpbuf); sprintf(tmpbuf, "Format: %s\n", IOBlackBox->getImgDesc()); strcat(buffer, tmpbuf); sprintf(tmpbuf, "Pixel type: %s\n", IOBlackBox->typeName(IOBlackBox->getCurrImgPixType())); strcat(buffer, tmpbuf); sprintf(tmpbuf, "Image type: %s\n", IOBlackBox->imgTypeName(IOBlackBox->getCurrImgImgType())); strcat(buffer, tmpbuf); int xO, yO, zO; xO = IOBlackBox->getXOffset(); yO = IOBlackBox->getYOffset(); zO = IOBlackBox->getZOffset(); sprintf(tmpbuf, "Offsets: xO=%d, yO=%d, zO=%d\n", xO, yO, zO); strcat(buffer, tmpbuf); if (mainViewer->getdisplaymode() == IMV_DISPLAY_IMG_FIT_WINDOW) { sprintf(tmpbuf, "Current X zoom factor: %f\n", mainViewer->xZoomFactor()); strcat(buffer, tmpbuf); sprintf(tmpbuf, "Current Y zoom factor: %f\n", mainViewer->yZoomFactor()); strcat(buffer, tmpbuf); sprintf(tmpbuf, "Aspect ratio: %f\n", mainViewer->xZoomFactor()/mainViewer->yZoomFactor()); strcat(buffer, tmpbuf); } else { sprintf(tmpbuf, "Current zoom factor: %f ", mainViewer->zoomFactor()); strcat(buffer, tmpbuf); sprintf(tmpbuf, "Default zoom factor: %f \n", mainViewer->getDefaultZoomFactor()); strcat(buffer, tmpbuf); sprintf(tmpbuf, "Minimum zoom factor: %f \n", mainViewer->getMinZoomFactor()); strcat(buffer, tmpbuf); } mainViewer->getCurrentBox(x,y,w,h); sprintf(tmpbuf, "Current subset: x=%d y=%d z=%d w=%d h=%d\n", x, y, IOBlackBox->getCurrZpos(), w, h); strcat(buffer, tmpbuf); sprintf(tmpbuf, "Frame: %d/%d\n", IOBlackBox->getCurrImgFrame()+1, IOBlackBox->getCurrImgNbFrames()); strcat(buffer, tmpbuf); } if (textOutput) textOutput->value((const char *)buffer); } return; } void imageinfo::show() { update(true); outputWindow->show(); } void imageinfo::hide() { outputWindow->hide(); } // callbacks associated with the dialog void okbutton_cb(Fl_Return_Button *, imageinfo *panel) { dbgprintf("Dismiss Button pressed on image info panel\n"); // hide the window panel->hide(); return; } imview-1.1.9c/imageInfo.hxx0000644000076500007650000000453207653236462016443 0ustar talbottalbot00000000000000/* * $Id: imageInfo.hxx,v 4.0 2003/04/28 14:39:46 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * An image info panel * * Hugues Talbot 2 May 1998 * *-----------------------------------------------------------------------*/ #ifndef IMAGEINFO_H #define IMAGEINFO_H #include #include #include #include #include #include class imageinfo { public: imageinfo(); void update(bool forced=false); void setDefaults(); void show(); void hide(); friend Fl_Window *imageinfo_panel(imageinfo &s); private: Fl_Window *outputWindow; Fl_Output *textOutput; Fl_Return_Button *OKButton; }; #endif // IMAGEINFO_H imview-1.1.9c/imageIO.cxx0000644000076500007650000011570010730372352016037 0ustar talbottalbot00000000000000/* * $Id: imageIO.cxx,v 4.15 2007/12/14 03:13:46 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * the imageIO class * * This class allows to read/write image files, determines the image format * and loads the image into memory. * * At this point only RGB and grey-level images are allowed * the formats that are understood are: * JPEG first implemented because of extreme simplicity * GIF second implemented to explore concept of colour map * TIFF third implemented to explore data type!=char and multispectral != RGB * ZIMAGE can't do without it! very complex format (multicomponent). * PNG very useful * ICS (SCILimage) because I need it now (26 Mar 1998) * Many provided by ImageMagick * META (ITK) used by Olena and others * ... * * * Hugues Talbot 28 Oct 1997 * * Modified Hugues Talbot 12 Dec 2007 * *-----------------------------------------------------------------------*/ #include #include #include #include #include "imunistd.h" #include #include // C++ strings #include "imnmspc.hxx" // contains namespace definition, if needed #include // STL maps. #include "imview.hxx" #include "nocase.hxx" #include "server/interpreter.hxx" #include "io/imSystem.hxx" #include "io/readjpeg.hxx" #include "io/readgif.hxx" #include "io/readtiff.hxx" #include "io/readZimage.hxx" #include "io/readics.hxx" #include "io/readpnm.hxx" #include "io/readsocket.hxx" #include "io/readraw.hxx" #include "io/readmat5.hxx" #include "io/readMagick.hxx" #include "io/newprefio.hxx" #include "io/readps.hxx" #include "io/readpng.hxx" #include "io/readmeta.hxx" #include "imageIO.hxx" #include "pointfile.hxx" #include "imageViewer.hxx" #include "tmpMsg.hxx" #include "rawImage.hxx" #include "userPrefs.hxx" typedef map::iterator mi; // Map iterator (can't be const) extern map psfilemap; extern map rawfilemap; // extern const char *psonlyfile; extern int deleteAfter; extern imageViewer *mainViewer; extern imprefs *fileprefs; extern tmpmsg *tmpmsgPanel; extern rawimage *rawImagePanel; extern userprefs *userprefsPanel; extern bool useMagick; extern bool forceMagick; extern bool forceRaw; imageIO::imageIO() { imdata = 0; overlay = 0; currBuffp = 0; // this is to mean that no gamma has been // applied yet. mgammas[0] = mgammas[1] = mgammas[2] = -1.0; minval_cache = maxval_cache = 0.0; // access to the image ID vector (from both GUI and server) semaphore_init(&access_imgvect); dontFreeBuffers = false; // free associated buffers when switching images. dbgprintf("ImageIO initialized\n"); } imageIO::~imageIO() { dbgprintf("ImageIO destroyed\n"); delete[] imdata; imdata = 0; delete[] overlay; overlay = 0; } int imageIO::imageFormat(const char *filename) { /** return file format based on magic number RETURN VALUE: int DESCRIPTION: This function will open the file fname, read a few bytes and determine the type from these few bytes. Most image types can be worked out this way. HISTORY: Hugues Talbot 11 Sep 1997 TESTS: REFERENCES: KEYWORDS: **/ FILE *fp; unsigned char magicno[HEADER_LENGTH]; /* first bytes of file */ int rv, n; static char tmpfilename[1024], *tp; #ifdef HAVE_PTHREADS // if we don't have them, no sockets either // If this image coming from a socket? if (findHeader(filename) != 0) // it's an incomplete check, but it will do. return IMAGEIO_SOCKET; #endif // is this raw data read from a raw file, that the user has already // identified? if (rawfilemap.find(filename) != rawfilemap.end()) { return IMAGEIO_RAW; // we'll have to perform the find again this way. } if (forceRaw) { rv = IMAGEIO_UNKNOWN; return(rv); } // then try our luck with SCILimage and MetaImage (mha/mhd) strcpy(tmpfilename, filename); if ((tp = strrchr(tmpfilename, '.')) != 0) { if ((strncmp(tp, ".ics", 4) == 0) || (strncmp(tp, ".ids", 4) == 0)) { if (access(tmpfilename, R_OK) == 0) { return IMAGEIO_SCILIMAGE; } else { return IMAGEIO_UNREADABLE; } } if ((strncmp(tp, ".mha", 4) == 0) || (strncmp(tp, ".mhd", 4) == 0)) { if (access(tmpfilename, R_OK) == 0) { return IMAGEIO_METAIMAGE; } else { return IMAGEIO_UNREADABLE; } } } strcat(tmpfilename, ".ics"); if (access(tmpfilename, F_OK) == 0) { if (access(tmpfilename, R_OK) == 0) { return IMAGEIO_SCILIMAGE; } else { return IMAGEIO_UNREADABLE; } } // try the general case with magic numbers if (!filename) return IMAGEIO_NOTHERE; else if (!(fp = im_fopen(filename, "rb"))) return IMAGEIO_UNREADABLE; n = fread(magicno, (size_t) 1, (size_t) HEADER_LENGTH, fp); fclose(fp); if (n<4) return IMAGEIO_TOOSMALL; /* files less than 4 bytes long... */ rv = IMAGEIO_UNKNOWN; if (strncmp((char *) magicno, "CSIROZ version", (size_t)14)==0) rv = IMAGEIO_ZIMAGE; #ifdef HAVE_TIFF else if (!forceMagick && ((magicno[0]=='M' && magicno[1]=='M') || (magicno[0]=='I' && magicno[1]=='I'))) rv = IMAGEIO_TIFF; #endif #ifdef HAVE_JPEG else if (!forceMagick && (magicno[0]==0xff && magicno[1]==0xd8 && magicno[2]==0xff)) rv = IMAGEIO_JPEG; #endif #ifdef HAVE_PNG else if (!forceMagick && (magicno[1] == 'P' && magicno[2] == 'N' && magicno[3] == 'G')) rv = IMAGEIO_PNG; #endif else if (!forceMagick &&(magicno[0] == 'G' && magicno[1] == 'I' && magicno[2] == 'F' && magicno[3] == '8')) rv = IMAGEIO_GIF; else if (!forceMagick && ((magicno[0] == 'P' && magicno[1] >= '1' && magicno[1] <= 'B'))) rv = IMAGEIO_PNM; else if (!forceMagick && ((magicno[0] == '%' && magicno[1] == '!'))) rv = IMAGEIO_PS; else if ( (magicno[126] == 0x49 && magicno[127] == 0x4d) || (magicno[126] == 0x4d && magicno[127] == 0x49) ) { rv = IMAGEIO_MAT5; if ( !((magicno[124] == 0x00 && magicno[125] == 0x01) || (magicno[124] == 0x01 && magicno[125] == 0x00)) ) { errprintf("Found MATLAB 5 file with version other than 1: %s", filename); rv = IMAGEIO_UNKNOWN; } } #ifdef HAVE_MAGICK else if (useMagick && testMagickImage(filename)) // can imageMagick read this image? rv = IMAGEIO_MAGICK; #endif return rv; } int imageIO::read(const char *filename, int frame) { int rv = 0; int format = imageFormat(filename); if (format >=0 ) { imageHasNoFile = false; // we assume a file is attached to the image switch (format) { case IMAGEIO_JPEG: dbgprintf("Input image is jpeg\n"); rv = readJpegImage(filename); break; case IMAGEIO_GIF: dbgprintf("Input image is GIF\n"); rv = readGifImage(filename, frame); break; case IMAGEIO_TIFF: dbgprintf("Input image is TIFF\n"); rv = readTiffImage(filename, frame); break; case IMAGEIO_ZIMAGE: dbgprintf("Input image is Z-IMAGE\n"); rv = readZImage(filename, frame); break; case IMAGEIO_SCILIMAGE: dbgprintf("Input image is SCIL\n"); rv = readICSImage(filename); break; case IMAGEIO_METAIMAGE: dbgprintf("Input image is META (ITK)\n"); rv = readMETAImage(filename, frame); break; case IMAGEIO_PNM: dbgprintf("Input image is PNM\n"); rv = readPNMImage(filename); break; case IMAGEIO_PS: dbgprintf("Rendering a postscript file\n"); rv = renderPSFile(filename, frame); break; case IMAGEIO_MAT5: dbgprintf("Input iage is MAT5\n"); rv = readMat5(filename, frame); break; case IMAGEIO_PNG: dbgprintf("Input image is PNG\n"); rv = readPNGImage(filename, frame); break; case IMAGEIO_SOCKET: dbgprintf("Input image coming from socket\n"); rv = readSocket(filename, frame); if (rv == 0) { // This will mean extra buffers are involved, whish // we'll have to free when the image is manually closed imageHasNoFile = true; } break; case IMAGEIO_MAGICK: rv = readMagickImage(filename, frame); break; case IMAGEIO_RAW: dbgprintf("Input image is raw (no header)\n"); rv = readRaw(filename, frame); break; case IMAGEIO_TOOSMALL: errprintf("Input file %s is too small to determine format\n", filename); rv = 4; break; case IMAGEIO_NOTHERE: errprintf("No file name given for image input\n"); rv = 3; break; case IMAGEIO_UNREADABLE: errprintf("Cannot read image %s\n" "%s", filename, strerror(errno)); rv = 2; break; case IMAGEIO_UNKNOWN: errprintf("Unrecognized image format: %s\n", filename); rv = 1; // things didn't go well break; default: // shouldn't happen errprintf("Unknown input image error\n"); rv = 100; break; } // in any case, record where we are at currFrame = frame; } else rv = 200; // couldn't read image if (rv == 0) flush_minmax_cache(); return rv; } int imageIO::getNbFrames(const char *fname) { int rv = 0; int format = imageFormat(fname); switch (format) { case IMAGEIO_JPEG: rv = jpegnbsubfiles(fname); break; case IMAGEIO_GIF: rv = gifnbsubfiles(fname); break; case IMAGEIO_TIFF: rv = tiffnbsubfiles(fname); break; case IMAGEIO_ZIMAGE: rv = zimagenbsubfiles(fname); break; case IMAGEIO_SCILIMAGE: rv = icsnbsubfiles(fname); break; case IMAGEIO_METAIMAGE: rv = metanbsubfiles(fname); break; case IMAGEIO_PNM: rv = pnmnbsubfiles(fname); break; case IMAGEIO_PS: { mi p = psfilemap.find(fname); if (p == psfilemap.end()) { // read the image read(fname); // try again if ((p = psfilemap.find(fname)) != psfilemap.end()) rv = tiffnbsubfiles((p->second).getfilename().c_str()); else { errprintf("Cannot determine the number of pages in the document\n"); rv = -50; } } else { rv = tiffnbsubfiles((p->second).getfilename().c_str()); } } break; case IMAGEIO_MAT5: rv = mat5nbsubfiles(fname); break; case IMAGEIO_PNG: rv = pngnbcomp(fname); break; case IMAGEIO_MAGICK: rv = magicknbsubfiles(fname); break; case IMAGEIO_SOCKET: rv = socketnbcomp(fname); break; case IMAGEIO_RAW: rv = rawnbcomp(fname); break; case IMAGEIO_TOOSMALL: errprintf("Input file %s is too small to determine format\n", fname); rv = -40; break; case IMAGEIO_NOTHERE: errprintf("No file name given for image input\n"); rv = -30; break; case IMAGEIO_UNREADABLE: errprintf("Cannot read image %s\n" "%s", fname, strerror(errno)); rv = -20; break; case IMAGEIO_UNKNOWN: dbgprintf("GetNbFrames: Unrecognized image format: %s\n", fname); if (rawImagePanel == 0) { rawImagePanel = new rawimage; rawimage_panel(*rawImagePanel); // important! rawImagePanel->setDefaults(); } rawImagePanel->setFileName(fname); // show the panel rawImagePanel->show(); rv = -10; // impossible to know the number of frames at this point. dbgprintf("Unknown image format\n"); break; default: // shouldn't happen errprintf("Unknown input image error\n"); rv = -100; break; } dbgprintf("File %s has %d subimages\n", fname, rv); currImgNbFrames = rv; return rv; } bool imageIO::isOverlay(const char *filename) { return (strncmp(filename, OVERLAY_MARKER, strlen(OVERLAY_MARKER)) == 0); } // the idea: // - save all buffers & all images parameters // - read an image via normal I/O (read) // - make sure it's suitable // - render to overlay buffer // - re-establish saved buffer // - display image. // BAAD idea. Hugues Talbot 1 Mar 2001 // instead, have a readXXXOverlay for each XXX format // int imageIO::readOverlay(const char *filename) { int retval = 0; int format = imageFormat(filename); // do we have any data ? if (imdata) { switch (format) { case IMAGEIO_TIFF: retval = readTiffOverlay(filename); // sets the overlay if present break; case IMAGEIO_ZIMAGE: retval = readZOverlay(filename); break; case IMAGEIO_SOCKET: retval = readSocketOverlay(filename); break; case IMAGEIO_TOOSMALL: errprintf("Input file %s is too small to determine format\n", filename); retval = 4; break; case IMAGEIO_NOTHERE: errprintf("No file name given for image input\n"); retval = 3; break; case IMAGEIO_UNREADABLE: errprintf("Cannot read image %s\n" "%s", filename, strerror(errno)); retval = 2; break; case IMAGEIO_UNKNOWN: errprintf("Unrecognized image format: %s\n", filename); retval = 1; // things didn't go well break; default: errprintf("Unsupported image type for overlays at this time, sorry\n"); retval = 100; } } else { errprintf("No image loaded\n"); retval = 1; } return retval; } int imageIO::renderOverlay(const char *filename, void *p, int imspp, int start[3], int end[3], pixtype thepixtype) { int w = end[0]-start[0]+1; int h = end[1]-start[1]+1; int z = end[2]-start[2]+1; int res = 0; if ((w == imageWidth()) && (h == imageHeight()) && (z == imageThickness())) { if ((thepixtype == IM_BINARY) ||(thepixtype == IM_INT1) || (thepixtype == IM_UINT1) || (thepixtype == IM_INT2) || (thepixtype == IM_UINT2) || (thepixtype == IM_INT4) || (thepixtype == IM_UINT4)) { if (imspp == 1) { // image is OK, render in buffer uchar *ovl = new uchar[w*h*z]; switch (thepixtype) { case IM_BINARY: case IM_INT1: case IM_UINT1: { char **b = (char **)p; memcpy(ovl, b[0], w * h * z * sizeof(uchar)); } break; case IM_INT2: { short **b = (short **)p; short *begin, *end; uchar *ovlb; ovlb = ovl; begin = b[0]; end = begin + w * h * z; while (begin != end) *ovlb++ = *begin++ & 0xFF; } break; case IM_UINT2: { unsigned short **b = (unsigned short **)p; unsigned short *begin, *end; uchar *ovlb; ovlb = ovl; begin = b[0]; end = begin + w * h * z; while (begin != end) *ovlb++ = *begin++ & 0xFF; } break; case IM_INT4: { int **b = (int **)p; int *begin, *end; uchar *ovlb; ovlb = ovl; begin = b[0]; end = begin + w * h * z; while (begin != end) *ovlb++ = *begin++ & 0xFF; } break; case IM_UINT4: { unsigned int **b = (unsigned int **)p; unsigned int *begin, *end; uchar *ovlb; ovlb = ovl; begin = b[0]; end = begin + w * h * z; while (begin != end) *ovlb++ = *begin++ & 0xFF; } break; default: errprintf("Overlay image %s has an unsuitable pixel type (%s)\n", filename, typeName(thepixtype)); res = 3; break; } if (res == 0) { // set the overlay in place and do the display ovlspp = 1; setOverlay(ovl); } } else if (imspp == 3) { // image is OK, render in buffer uchar *ovl = new uchar[3*w*h*z]; int i; // overlay buffer will be arranged RGBRGBRGB... switch (thepixtype) { case IM_BINARY: case IM_INT1: case IM_UINT1: { char **b = (char **)p; char *begin, *end; uchar *ovlb; for (i = 0 ; i < 3 ; i++) { begin = b[i]; end = begin + w * h * z; ovlb = ovl+i; while(begin != end) { *ovlb = *begin++; ovlb += 3; } } } break; case IM_INT2: { short **b = (short **)p; short *begin, *end; uchar *ovlb; for (i = 0 ; i < 3 ; i++) { begin = b[i]; end = begin + w * h * z; ovlb = ovl+i; while(begin != end) { *ovlb = *begin++ & 0xFF; ovlb += 3; } } } break; case IM_UINT2: { unsigned short **b = (unsigned short **)p; unsigned short *begin, *end; uchar *ovlb; for (i = 0 ; i < 3 ; i++) { begin = b[i]; end = begin + w * h * z; ovlb = ovl+i; while(begin != end) { *ovlb = *begin++ & 0xFF; ovlb += 3; } } } break; case IM_INT4: { int **b = (int **)p; int *begin, *end; uchar *ovlb; for (i = 0 ; i < 3 ; i++) { begin = b[i]; end = begin + w * h * z; ovlb = ovl+i; while(begin != end) { *ovlb = *begin++ & 0xFF; ovlb += 3; } } } break; case IM_UINT4: { unsigned int **b = (unsigned int **)p; unsigned int *begin, *end; uchar *ovlb; for (i = 0 ; i < 3 ; i++) { begin = b[i]; end = begin + w * h * z; ovlb = ovl+i; while(begin != end) { *ovlb = *begin++ & 0xFF; ovlb += 3; } } } break; default: errprintf("Overlay image %s has an unsuitable pixel type (%s)\n", filename, typeName(thepixtype)); res = 3; break; } if (res == 0) { // set the overlay in place and do the display ovlspp = 3; setOverlay(ovl); } } else { errprintf("Image %s is unsuitable as an overlay. Only single spectrum\n" "or RGB images are acceptable\n", filename); } } else { errprintf("Image %s has an unsuitable pixel type to serve\n" "as an overlay for the current image", filename); res = 2; } } else { dbgprintf("Overlay dimensions: %dx%d%d, image dimensions: %dx%d%d", w, h, z, imageWidth(), imageHeight(), imageThickness()); errprintf("Image %s has unsuitable dimensions (%4dx%4dx%4d) to serve\n" "as an overlay for the current image (%4dx%4dx%4d)", filename, w, h, z, imageWidth(), imageHeight(), imageThickness()); res = 1; } return res; } int imageIO::write(const char *filename, int format) { dbgprintf("Writing imge %s under format %d\n", filename, format); return 0; } ///////////////////////////////////// // access to the image representation int imageIO::wholeImage(uchar **bufR, uchar **bufG, uchar **bufB) { int nbpix = currImgWidth*currImgHeight; if (imspp == 1) { // simply return a copy of the image data *bufR = new uchar[nbpix]; *bufG = 0; *bufB = 0; memcpy(*bufR, imdata, nbpix); return 1; } else if (imspp == 3) { uchar *ucp, *ucpr, *ucpg, *ucpb, *end; // we have to separate the three samples *bufR = new uchar[nbpix]; *bufG = new uchar[nbpix]; *bufB = new uchar[nbpix]; ucp = imdata; end = ucp + nbpix * 3; ucpr = *bufR; ucpg = *bufG; ucpb = *bufB; while (ucp < end) { *ucpr++ = *ucp++; *ucpg++ = *ucp++; *ucpb++ = *ucp++; } return 3; } else return 0; } int imageIO::subsetImage(uchar **bufR, uchar **bufG, uchar **bufB, int &bx, int &by, int &bw, int &bh) { mainViewer->getCurrentBox(bx, by, bw, bh); dbgprintf("Current viewed subset is: Ox=%d, Oy=%d, W=%d, H=%d\n", bx, by, bw, bh); if (imspp == 1) { int j; uchar *ucp, *ucpl; long nbpix = bh*bw; *bufR = new uchar[nbpix]; *bufG = *bufB = 0; for (j = 0 ; j < bh ; j++) { ucp = imdata + (by+j)*currImgWidth + bx; ucpl = *bufR + j*bw; memcpy(ucpl, ucp, bw); } } else if (imspp == 3) { int i, j; uchar *ucp, *ucpr, *ucpg, *ucpb; long nbpix = bh*bw; *bufR = new uchar[nbpix]; *bufG = new uchar[nbpix]; *bufB = new uchar[nbpix]; for (j = 0 ; j < bh ; j++) { ucp = imdata + 3*((by+j)*currImgWidth + bx); ucpr = *bufR + j*bw; ucpg = *bufG + j*bw; ucpb = *bufB + j*bw; for (i = 0 ; i < bw ; i++) { *ucpr++ = *ucp++; *ucpg++ = *ucp++; *ucpb++ = *ucp++; } } } else return 0; return imspp; } // special function for the bivariate histogram. // take the current subset into account // return 0 if quite alright // we do not cope well with 3D buffers yet. int imageIO::subsetForBH(vector &v, int Xcomp, int Ycomp, double &minXval, double &minYval, double &maxXval, double &maxYval) { int bx, by, bw, bh; int delta, i, j; int retval = 0; double dx, dy; mainViewer->getCurrentBox(bx, by, bw, bh); dbgprintf("Current viewed subset is: Ox=%d, Oy=%d, W=%d, H=%d\n", bx, by, bw, bh); if ((Xcomp < currImgNbSamples) && (Ycomp < currImgNbSamples)) { int zoff = buffZOffset; // we take the current position as the default // empty the vector v.clear(); if (currBuffp) { switch (currPixType) { case IM_BINARY: case IM_UINT1: case IM_INT1: { uchar *ucpX, *ucpY; ucpX = (uchar*)currBuffp[Xcomp] + zoff + currImgWidth*by + bx; ucpY = (uchar*)currBuffp[Ycomp] + zoff + currImgWidth*by + bx; minXval = maxXval = (double)*ucpX; minYval = maxYval = (double)*ucpY; for (j = 0 ; j < bh ; j++) { ucpX = (uchar*)currBuffp[Xcomp] + zoff + currImgWidth*(by+j) + bx; ucpY = (uchar*)currBuffp[Ycomp] + zoff + currImgWidth*(by+j) + bx; for (i = 0 ; i < bw ; i++) { dx = (double)*ucpX; dy = (double)*ucpY; if (dx < minXval) minXval = dx; if (dy < minYval) minYval = dy; if (dx > maxXval) maxXval = dx; if (dy > maxYval) maxYval = dy; delta = bx+i + (by+j)*currImgWidth; v.push_back(BHPoint(BHPBlack,delta,dx ,dy)); ucpX++; ucpY++; } } } break; case IM_INT4: case IM_UINT4: { int *ucpX, *ucpY; ucpX = (int*)currBuffp[Xcomp] + zoff + currImgWidth*by + bx; ucpY = (int*)currBuffp[Ycomp] + zoff + currImgWidth*by + bx; minXval = maxXval = (double)*ucpX; minYval = maxYval = (double)*ucpY; for (j = 0 ; j < bh ; j++) { ucpX = (int*)currBuffp[Xcomp] + zoff + currImgWidth*(by+j) + bx; ucpY = (int*)currBuffp[Ycomp] + zoff + currImgWidth*(by+j) + bx; for (i = 0 ; i < bw ; i++) { dx = (double)*ucpX; dy = (double)*ucpY; if (dx < minXval) minXval = dx; if (dy < minYval) minYval = dy; if (dx > maxXval) maxXval = dx; if (dy > maxYval) maxYval = dy; delta = bx+i + (by+j)*currImgWidth; v.push_back(BHPoint(BHPBlack,delta,dx ,dy)); ucpX++; ucpY++; } } } break; case IM_DOUBLE: { double *ucpX, *ucpY; ucpX = (double*)currBuffp[Xcomp] + zoff + currImgWidth*by + bx; ucpY = (double*)currBuffp[Ycomp] + zoff + currImgWidth*by + bx; minXval = maxXval = (double)*ucpX; minYval = maxYval = (double)*ucpY; for (j = 0 ; j < bh ; j++) { ucpX = (double*)currBuffp[Xcomp] + zoff + currImgWidth*(by+j) + bx; ucpY = (double*)currBuffp[Ycomp] + zoff + currImgWidth*(by+j) + bx; for (i = 0 ; i < bw ; i++) { dx = *ucpX; dy = *ucpY; if (dx < minXval) minXval = dx; if (dy < minYval) minYval = dy; if (dx > maxXval) maxXval = dx; if (dy > maxYval) maxYval = dy; delta = bx+i + (by+j)*currImgWidth; v.push_back(BHPoint(BHPBlack,delta,dx ,dy)); ucpX++; ucpY++; } } } break; default: retval = 2; break; } } else { uchar *ucpX, *ucpY, *beg; // data is just char. beg = imdata + currImgNbSamples*(by*currImgWidth + bx); minXval = maxXval = (double)*(beg + Xcomp); minYval = maxYval = (double)*(beg + Ycomp); for (j = 0 ; j < bh ; j++) { beg = imdata + currImgNbSamples*((by+j)*currImgWidth + bx); ucpX = beg + Xcomp; ucpY = beg + Ycomp; for (i = 0 ; i < bw ; i++) { dx = (double)*ucpX; dy = (double)*ucpY; if (dx < minXval) minXval = dx; if (dy < minYval) minYval = dy; if (dx > maxXval) maxXval = dx; if (dy > maxYval) maxYval = dy; delta = bx+i + (by+j)*currImgWidth; v.push_back(BHPoint(BHPBlack,delta,dx ,dy)); ucpX += currImgNbSamples; ucpY += currImgNbSamples; } } } } else retval = 1; // and do nothing else return retval; } int imageIO::renderPSFile(const char *filename, int frame) { char errfile[1024], panelmsg[1024]; int rv = 0; static int psreadres; mi p; // map iterator char *imTempPSFileName = 0; float Ox, Oy, W, H, resolution, imgW, imgH; dbgprintf("Input image is POSTSCRIPT\n"); // we need the user prefs panel if (userprefsPanel == 0) { userprefsPanel = new userprefs; userprefs_panel(*userprefsPanel); userprefsPanel->setDefaults(); // no need to show it though } // see if we have rendered this file already if (((p = psfilemap.find(filename)) == psfilemap.end()) || ((p->second).gethash() != userprefsPanel->getPsPrefsHash())) { if (p != psfilemap.end()) { dbgprintf("Re-rendering postscript file\n"); // destroying previous cache file string cache = (p->second).getfilename(); dbgprintf("Removing previous cache file %s\n", cache.c_str()); unlink(cache.c_str()); } else dbgprintf("Rendering postscript file (for the first time)\n"); imTempPSFileName = tempnam(0, "flim"); char gscommand[1024]; strcpy(errfile, imTempPSFileName); strcat(errfile, ".err"); if (!tmpmsgPanel) { tmpmsgPanel= new tmpmsg; tmpmsg_panel(*tmpmsgPanel); } psinfo mypsinfo(filename); sprintf(panelmsg, "Calling GhostScript interpreter on file\n" "%s\n" "This may take a while", filename); tmpmsgPanel->setMessage(panelmsg); tmpmsgPanel->show(); // this trick below is to ensure that the message on // the warning panel is displayed. for (int w = 0 ; w < 3 ; w++) Fl::wait(0.05); // respond to events for a few milliseconds // parsing the file gets the bounding box and fixes a few things // such as making sure a showpage is present, etc. mypsinfo.parsefile(); mypsinfo.getBoundingBox(Ox, Oy, W, H); resolution = fileprefs->psRenderRes(); imgW = (W * resolution)/DEFAULT_PS_RES + 0.5 ; imgH = (H * resolution)/DEFAULT_PS_RES + 0.5 ; sprintf(gscommand, "%s -q -dNOPAUSE -dBATCH -dMaxBitmap=50000000 -sDEVICE=%s " "-dTextAlphaBits=%u -dGraphicsAlphaBits=%u -g%dx%d -r%d -sOutputFile=%s %s -c quit 2> %s", fileprefs->gspath(), (fileprefs->psRenderDepth() == PSREND_BW) ? "tiffg4":"tiff24nc", (fileprefs->psAntialiasRender()) ? 4:1, (fileprefs->psAntialiasRender()) ? 4:1, (int)imgW, (int)imgH, (int)(resolution + 0.5), imTempPSFileName, mypsinfo.getTmpFilename(), // use the temporary file made when parsing errfile); dbgprintf("executing:\n%s\n", gscommand); // call the system for rendering the file to an image // maybe this should be done in a separate thread... psreadres = system(gscommand); if (psreadres == 0) rv = read(imTempPSFileName, frame); // OK, recursive read! else { errprintf("Failed to run the Ghostscript interpreter correctly"); rv = 5; } tmpmsgPanel->hide(); } else { // read the temp file dbgprintf("Using pre-rendered file %s\n", (p->second).getfilename().c_str()); rv = read((p->second).getfilename().c_str(), frame); } if (rv != 0) { // could not read struct stat statbuf; if (imTempPSFileName) { // erase the temp file and delete the temporary storage unlink(imTempPSFileName); free(imTempPSFileName); imTempPSFileName = 0; } // delete the faulty map entry if (p != psfilemap.end()) { psfilemap.erase(p); } if ((stat(errfile, &statbuf) == 0) && (statbuf.st_size > 0)) { errprintf("Postscript rendering of % failed\n" "Error log to be found in file %s\n", filename, errfile); } } else { if (imTempPSFileName) { // everything went well, save the temporary name to the map string tempps(imTempPSFileName); string currenthash = userprefsPanel->getPsPrefsHash(); image_psfile rendercache(tempps, currenthash); psfilemap[filename] = rendercache; // this makes a copy free(imTempPSFileName); imTempPSFileName = 0; } // else the temp file is already in the map // set the zoom factor and the smooth flag double renderes = fileprefs->psRenderRes(); double dspres = fileprefs->psDisplayRes(); double zoomf; if (renderes != 0) zoomf = dspres/renderes; else zoomf = 1.0; mainViewer->setDefaultZoomFactor(zoomf); if (fileprefs->psRenderSmooth()) fileprefs->smoothZoomout(true); else fileprefs->smoothZoomout(false); // destroy the file containing the errors unlink(errfile); } return rv; } // messaging GUI <-> server // This is a message FROM the server TO the GUI void imageIO::pleaseDisplay(const string &s) { semaphore_down(&access_imgvect); dbgprintf("Ok, will display %s later on\n", s.c_str()); imgToDisplay.push_back(s); semaphore_up(&access_imgvect); } // this is the GUI checking on the messages int imageIO::checkDisplay(string &as) { int retval = 0; semaphore_down(&access_imgvect); if (!imgToDisplay.empty()) { as = imgToDisplay.front(); dbgprintf("Aha: image %s is to be displayed!\n", as.c_str()); // effectively an inefficient 'pop_front' imgToDisplay.erase(imgToDisplay.begin()); retval = 1; } semaphore_up(&access_imgvect); return retval; } #ifdef HAVE_PTHREADS // surrogate for HAVE_SERVER // find header based on name IMAGE_HEADER *imageIO::findHeader(const char *name) { IMAGE_HEADER *res ; semaphore_down(&access_imgvect); res = put::find_header(name); semaphore_up(&access_imgvect); return res; } // find header based on id IMAGE_HEADER *imageIO::findHeader(unsigned int id) { IMAGE_HEADER *res ; semaphore_down(&access_imgvect); res = put::find_header(id); semaphore_up(&access_imgvect); return res; } // delete header based on ID void imageIO::closeHeader(unsigned int id) { semaphore_down(&access_imgvect); put::delete_header(id); semaphore_up(&access_imgvect); } // delete header based on name void imageIO::closeHeader(const char *fname) { semaphore_down(&access_imgvect); put::delete_header(fname); semaphore_up(&access_imgvect); } #else // we fake 'em, we still need the definitions // find header based on name IMAGE_HEADER *imageIO::findHeader(const char *) { return 0; } // find header based on id IMAGE_HEADER *imageIO::findHeader(unsigned int) { return 0; } // delete header based on ID void imageIO::closeHeader(unsigned int) { } // delete header based on name void imageIO::closeHeader(const char *) { } #endif imview-1.1.9c/imageIO.hxx0000644000076500007650000003317510730372352016051 0ustar talbottalbot00000000000000/* * $Id: imageIO.hxx,v 4.8 2007/12/14 03:13:46 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * the imageIO class * * This class allows to read image files, determines the image format * and loads the image into memory. * * At this point only RGB and grey-level images are allowed * the formats that are understood are: * JPEG * GIF * TIFF * Z-IMAGE * * Hugues Talbot 28 Oct 1997 * *-----------------------------------------------------------------------*/ #ifndef IMAGEIO_H #define IMAGEIO_H #include #include // STL #include #include #include "imnmspc.hxx" // namespace definition, if required #ifdef HAVE_PTHREADS #include "server/semaphore.hxx" #endif #include "machine.hxx" using std::vector; using std::string; // recognized format #define IMAGEIO_TOOSMALL -4 #define IMAGEIO_NOTHERE -3 #define IMAGEIO_UNREADABLE -2 #define IMAGEIO_UNKNOWN -1 #define IMAGEIO_RAW 0 // this means: no format at all #define IMAGEIO_JPEG 1 #define IMAGEIO_TIFF 2 #define IMAGEIO_ZIMAGE 3 // the world-famous Zimage format #define IMAGEIO_GIF 4 #define IMAGEIO_SCILIMAGE 5 #define IMAGEIO_PNM 6 #define IMAGEIO_PS 7 // postcript, thanks to GS. #define IMAGEIO_MAT5 8 // MATLAB level 5 MAT-file format #define IMAGEIO_PNG 9 #define IMAGEIO_SOCKET 10 // coming from a socket #define IMAGEIO_MAGICK 11 // read through the ImageMagick library #define IMAGEIO_METAIMAGE 12 #define HEADER_LENGTH 128 // number of bytes to read when // determining the file format typedef long (rot3dtransf)(int x, int y, int z); // this is a base class. class imageIO { public: imageIO(); ~imageIO(); int imageFormat(const char *filename); int read(const char *filename, int frame=0); // reads the data in bool isOverlay(const char *filename); // decide whether a file is an overlay int readOverlay(const char *filename); // overlay on top of existing image int renderOverlay(const char *filename, void *p, int imspp, int start[3], int end[3], pixtype thepixtype); int getNbFrames(const char *filename); // go get the number of frames int applyCurrentCLUT(void); // apply the known clut is present int applyCLUTtoCurrentImage(const char *CLUTpath, bool useRaw = false); int saveToRawBuffers(bool keepGreyIfPossible); // double parameters and the maps are redundant only for // CHAR images. void setOverlay(uchar *buf); int setPixelInOverlay(int index, uchar value); int write(const char *filename, int format = 0); int wholeImage(uchar **R, uchar **G, uchar **B); int subsetImage(uchar **R, uchar **G, uchar **B, int &bx, int &by, int &bw, int &bh); int subsetForBH(vector &v, int Xcomp, int Ycomp, double &minXval, double &minYval, double &maxXval, double &maxYval); unsigned char *imageData(void) {return imdata;} int imageWidth(void) {return currImgWidth;} int imageHeight(void) {return currImgHeight;} int imageThickness(void) {return currImgThickness;} int imageDepth(void) {return imspp;} char *getClutNameIfPresent(const char *impath); int checkForClut(const char *clutName, const char *imageName, uchar theCLUT[][256]); char *getRawDataInfo(int xpos, int ypos); char *getRawDataInfo(int xpos, int ypos, int zpos); double *getRawDataVector(int xpos, int ypos, int *nb); double *get3DRawDataVector(int xpos, int ypos, int *nb); void getLineDataVectors(int X2, int Y2, int X, int Y, double *&red, double *&green, double *&blue, int &nb); int hasRawData(void); void setImData(unsigned char *p); void applyImageParameters(IMAGEPARM *p=0, const char *imname = 0, char *lutname = 0, bool keepgamma = false); // transforms void rotateRight(void); void rotateLeft(void); void rotate180(void); void flipv(void); void fliph(void); void rotate3Dup(void); void rotate3Ddown(void); // messaging to GUI <-> image server void pleaseDisplay(const string &us); int checkDisplay(string &as); IMAGE_HEADER *findHeader(unsigned int id); IMAGE_HEADER *findHeader(const char *name); void closeHeader(unsigned int id); void closeHeader(const char *fname); // quick functions int getCurrZpos(void) { return currZpos; } int getCurrImgThickness(void) { return currImgThickness; } int getXOffset(void) { return xOffset;} int getYOffset(void) { return yOffset;} int getZOffset(void) { return zOffset;} int getCurrImgNbComps(void) { return currImgNbComps; } int getCurrImgNbFrames(void) { return currImgNbFrames; } int getCurrImgFrame(void) { return currFrame;} int getCurrImgNbSamples(void) { return currImgNbSamples;} const char *getImgDesc(void) {return imgDesc; } pixtype getCurrImgPixType(void) { return currPixType; } imgtype getCurrImgImgType(void) { return currImgType; } void **getCurrBuffp(void) { return currBuffp; } const char *getImName() const {return imName;} void setImName(const char *Name) {imName = Name;} void setCurrBuffp(void **p, bool untouchable=false) { if (currBuffp != 0) freeCurrentBuffers(); currBuffp = p; dontFreeBuffers = untouchable; // are these buffer freeable? } void setCurrImgWidth(int w) {currImgWidth = w;} void setCurrImgHeight(int h) {currImgHeight = h;} void setCurrImgThickness(int t) {currImgThickness = t;} void setXOffset(int x) {xOffset = x;} void setYOffset(int y) {yOffset = y;} void setZOffset(int z) {zOffset = z;} void setCurrZPos(int z) {currZpos = z;} void setCurrImgType(imgtype i) {currImgType = i;} void setCurrPixType(pixtype p) {currPixType = p;} void setCurrImgNbComps(int n) {currImgNbComps = n;} void setCurrImgNbFrames(int f) {currImgNbFrames = f;} void setCurrFrame(int ff) {currFrame = ff;} void setCurrImgSpp(int n) { imspp = n; } void setCurrImgNbSamples(int n) { currImgNbSamples = n; } void setCurrImgColourMap(unsigned short **cmap) {currImgColourMap = cmap;} void setCurrImgNbColours(long nbcols) {currImgNbColours = nbcols;} void setImgDesc(const char *str) { imgDesc = str; } /* avoid lengthy calculation at each change of slice diaplay */ void flush_minmax_cache(void) {minval_cache=maxval_cache=0.0;} void minmax_set_cache(double amin, double amax) { minval_cache = amin; maxval_cache = amax; } void minmax_get_cache(double &amin, double &amax) { amin = minval_cache; amax = maxval_cache; } bool minmax_iscached(void) { return ((minval_cache != maxval_cache) || (minval_cache != 0.0)); } char *typeName(pixtype atype); char *imgTypeName(imgtype atype); size_t typeSize(pixtype whatType); void freeRawBuffers(void *p, int imspp); // a helper function for I/O void saveGammaParameters(double *x0, double *y0, double *x1, double *y1, double *gamma, uchar *Rmap, uchar *Gmap, uchar *Bmap); private: unsigned char *imdata; // for display unsigned char *overlay; // to display things on top of images. const char *imgDesc, *imName, *currImgCLUTPath; int imspp, ovlspp; // messaging GUI <-> server vector imgToDisplay; Semaphore access_imgvect; void freeCurrentBuffers(void); int xOffset, yOffset, zOffset; int currImgNbFrames; int currImgNbComps; // number of components = # of independent images in one file ; imview supports 1 int currImgNbSamples; // number of samples per pixels (usually 1, 3 or many) int currImgWidth, currImgHeight, currImgThickness; int currZpos; int currComp, currFrame; long buffZOffset; imgtype currImgType; pixtype currPixType; unsigned short **currImgColourMap; long currImgNbColours; void **currBuffp; // some bools bool currImgHasCLUT, currImgHasGamma, currImgHasOverlay; bool dontFreeBuffers, imageHasNoFile; // for sockets, their data is memory only. // for keeping the gamma information double mx0[3], my0[3], mx1[3], my1[3], mgammas[3]; uchar mRmap[256], mGmap[256], mBmap[256]; bool hasGmap; // min/max value cache double minval_cache, maxval_cache; // private methods //private: // needed for Bresenham int dx_, dy_, incx_, incy_, xpos_, ypos_; int e_, i_, inc1_, inc2_, sizex_; // utility functions int renderPSFile(const char *filename, int frame); // line functions int getRawDataPoint(long delta, double &G); int getRawDataPoint(long delta, double &R, double &G, double &B); int bresinit(int x1, int y1, int x2, int y2); int bresgetnext(void); // the conversion methods void translateForDisplay(bool keepOverlay = false); void convertBINARY(int *imDepth, uchar **outbuf); void convertUINT1(int *imDepth, uchar **outbuf, bool freeBuffers=true, bool interpretRGB=true); void convertUINT1withLUT(int *imDepth, uchar **outbuf, uchar CLUT[][256]); void convertDirectLUT(int *imDepth, uchar **outbuf, uchar CLUT[][256]); void convertINT4withLUT_wraparound(int *imDepth, uchar **outbuf, uchar CLUT[][256]); // rotations void rotate3Dgeneric(rot3dtransf *myrotf, long nbplanepix); #ifdef HAVE_MEMBER_TEMPLATES # ifdef HAVE_TEMPLATE_KEYWORD_QUALIFIER template void convertWithLUT_wraparound(int *imDepth, uchar **outbuf, void *CLUT); template void convert(int *imDepth, uchar **outbuf, bool freeBuffers=true, bool makeChar=true, bool interpretRGB=true, bool minmaxAllSamples=true, bool minmaxAllSlices=true ); template void applyGamma(int *imDepth, uchar **outbuf, double *startX, double *startY, double *endX, double *endY, double *gamma); # else template void convertWithLUT_wraparound(int *imDepth, uchar **outbuf, void *CLUT, T dummy = 0); template void convert(int *imDepth, uchar **outbuf, bool freeBuffers=true, bool makeChar=true, bool interpretRGB=true, bool minmaxAllSamples=true, bool minmaxAllSlices=true, T dummy = 0); template void applyGamma(int *imDepth, uchar **outbuf, double *startX, double *startY, double *endX, double *endY, double *gamma, T dummy = 0); # endif #else // HAVE_MEMBER_TEMPLATES // these will go eventually void convertINT2(int *imDepth, uchar **outbuf); void convertUINT2(int *imDepth, uchar **outbuf); void convertINT4(int *imDepth, uchar **outbuf); void convertUINT4(int *imDepth, uchar **outbuf); void convertDOUBLE(int *imDepth, uchar **outbuf); void applyGamma_UINT2(int *imDepth, uchar **outbuf, double *startX, double *startY, double *endX, double *endY, double *gamma); void applyGamma_INT4(int *imDepth, uchar **outbuf, double *startX, double *startY, double *endX, double *endY, double *gamma); void applyGamma_DBL(int *imDepth, uchar **outbuf, double *startX, double *startY, double *endX, double *endY, double *gamma); #endif // HAVE_MEMBER_TEMPLATES int applyGammaToCurrentImage(void); int applyGammaToCurrentImage(double *x0, double *y0, double *x1, double *y1, double *gammas, uchar *Rmap, uchar *Gmap = 0, uchar *Bmap = 0); void applyGamma_UINT1(int *imDepth, uchar **outbuf, uchar *Rmap, uchar *Gmap, uchar *Bmap); int applyOverlayToCurrentImage(void); }; #endif imview-1.1.9c/imageViewer.cxx0000644000076500007650000030431410265503366016776 0ustar talbottalbot00000000000000/* * $Id: imageViewer.cxx,v 4.22 2005/07/14 15:38:30 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Code for the ImageViewer Class * * Hugues Talbot 27 Oct 1997 * * This is my first attempt at a serious derivation. Don't laugh at * the code... * * This is very complex code, I get lost in there all the time. * * Hugues Talbot 12 Sep 2003: added two more viewing mode, 3 in total: * * - old mode, called `window fits the image', i.e. normally the * window sits tight around the image with no gap. The exceptions are * 1- if the image dimensions are so small that the main menu would * not be visible, so in this case the image is centered in a * minimal-size frame with a white background and 2- if the image is * too big to fit in the screen or if the user shrinks the main window * by hand, which is permitted (expanding the window by dragging the * frame is not). In this case scrollbars are created so that the user * can still access the whole data. Changes of zoom factor obviously * can make the window resize as long as the windows dimensions fit in * the screen and are not too small. A window can be shrunk but not * expanded. I like this mode best but it has been hard to implement * in X11 and is still somewhat shaky sometimes for unknown reasons. * Sometimes imview gets into a weird state with scrollbars in the * middle of the image, but I can never reliably invoke this faulty * mode. Let me know if you can so I can correct it. This is the * imview default mode. * * - `image fits window' mode. There can be no scrollbar, only changes * in dimension of the main window. This is the only mode where the * aspect ratio can be changed interactively. Zooming also changes the * dimension of the window. There is no limit to the size of the main * window. This is the way XV by John Bradley behaves. * * - `window and image decoupled' mode. Zoom operations change the * image dimensions on the one hand, and windows operations change the * window dimensions on the other. If the image is too large for the * window scrollbars are created (and removed if they are no longer * needed). This is the way the GIMP operates (except for the GIMP the * scrollbars are always present). In this mode the window background * when visible is black. * * In short, the first mode is fine as default, but you might want to * use the second for changing the aspect ratio interactively, and the * second mode in fullscreen mode (I'm working on that). * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" // namespace definitions etc. #include #include #include // not used here but necessary for nocase.H #include #include #include #include #include "imview.hxx" #include "imviewWindow.hxx" #include "imageIO.hxx" #include "menubar.hxx" #include "pointfile.hxx" #include "imageViewer.hxx" #include "imageInfo.hxx" #include "spectraBox.hxx" #include "profileBox.hxx" #include "annotatePoints.hxx" #include "my_Image.hxx" #include "nocase.hxx" #include "io/newprefio.hxx" #include "server/interpreter.hxx" // needed external variables extern imviewWindow *mainWindow; extern imViewMenuBar *mainMenuBar; extern pointfile *PtFileMngr; extern imageinfo *imageInfoPanel; extern spectra *spectraPanel; extern spectra *depthProfile; extern profile *profilePanel; extern imprefs *fileprefs; extern annotatept *annotatePointPanel; extern linkmanager *imview_linkmanager; extern int debugIsOn; extern int appMaxWidth, appMaxHeight; extern bool useOffscreenBuff; extern bool hideMainMenu; extern bool fullScreen; extern displaymode displaymodepref; // set by command line before object created... imageViewer::imageViewer(int x, int y, int w, int h, const char *label) : Fl_Group(x,y,w,h,label) { dbgprintf("ImageViewer constructor called with args: %d, %d, %d, %d \n", x, y, w, h); Ox = x; Oy = y; originalWidth = w; originalHeight = h; vposition_ = hposition_ = 0; hscrollbar = 0; vscrollbar = 0; theImage = 0; parentWindow = 0; imageObject = 0; // there is no image yet statusLine = 0; // status line is invisible by default zoomBox = 0; zoomBoxDefined = 0; imageZoomFactor_ = defaultZoomFactor_= 1.0; xZoomFactor_ = yZoomFactor_ = 1.0; minZoomFactor_ = 1.0; nbPointDamage = 0; angleLine = 0; dbgprintf("ResizeInProgress set to false\n"); // resizeInProgress = false; zoomDragInProgress = false; aspectConstrained = false; sizeConstrained = true; lineProfileInProgress = false; pointmode = false; keepProfileLine = false; pmode_ = IMV_POINTER_ZOOM_MODE; dmode_ = displaymodepref; currentPtColour_ = 0; // must call this to close the group end(); } imageViewer::~imageViewer() { dbgprintf("Image Viewer destructor called.\n"); // delete the image Object if need be. zapImageObject(); // always delete the image IO object } void imageViewer::displayCurrentImage(void) { int realMinWidth, realMinHeight; static int oldImageWidth = -1, oldImageHeight = -1; double oldZoomFactor, df; // get rid of the previous image object zapImageObject(); imageObject = new Fl_RGB_Image(theImage->imageData(), theImage->imageWidth(), theImage->imageHeight(), theImage->imageDepth()); oldZoomFactor = zoomFactor(); // this is the zoom factor of the previous image // work out the defaultZoomFactor df = trivmin((double)MINHEIGHT/theImage->imageHeight(), (double)MINWIDTH/theImage->imageWidth()); // if the default zoom factor is smaller than 1.0, ignore it //defaultZoomFactor_ = trivmax(df, 1.0); df = trivmax(df, 1.0); if ((oldImageWidth != theImage->imageWidth()) || (oldImageHeight != theImage->imageHeight())) { // we do not call zoomFactor() here because we don't // want the automatic resize() that goes with it. the // main window will be resized and redrawn at the end // of this function (see below) anyway. if (fullScreen) imageZoomFactor_ = defaultZoomFactor_ = computeMaxZoomFactor(); else imageZoomFactor_ = defaultZoomFactor_ * df; // might be clever? } // on the other hand... minZoomFactor_ = trivmax(1.0/theImage->imageHeight(), 1.0/theImage->imageWidth()); if (zoomFactor() < minZoomFactor_) zoomFactor(minZoomFactor_); dbgprintf("Minimal zoom factor = %g\n", minZoomFactor_); dbgprintf("Default zoom factor = %g\n", defaultZoomFactor_); // resize the parent window if (!parentWindow) parentWindow = (imviewWindow *)parent(); // by now parent ought to have been initialized // resize only if need be, that is: if the zoom factor is 1.0 (expected behaviour) // or if the window is too large for the current image. realMinWidth = trivmin(appMaxWidth,currentImageWidth()); realMinHeight = trivmin(appMaxHeight,currentImageHeight()); sizeConstraints(realMinWidth, realMinHeight); if ((Ox+currentImageWidth() < visibleWidth()) || (Oy+currentImageHeight() < visibleHeight()) || (zoomFactor() == defaultZoomFactor_) || (zoomFactor() == minZoomFactor_)) { // possibly resizing the parent window if (!sizeParent(Ox + realMinWidth, Oy + realMinHeight)) { dbgprintf("Manual redraw call needed\n"); redraw_image(); // then the image will need a manual nudge to be redisplayed } } else { redraw_image(); // here too dbgprintf("Manual redraw call needed here too\n"); } // remember the current image dimensions oldImageWidth = theImage->imageWidth(); oldImageHeight = theImage->imageHeight(); return; } // this method is called when we want to display NO image // the window dimensions are returned to the initialization values int imageViewer::close(void) { if (imageObject) { zapImageObject(); if (parentWindow) { int realMinWidth = trivmin(appMaxWidth, originalWidth); int realMinHeight = trivmin(appMaxHeight, originalHeight); parentWindow->size(trivmax(Ox+originalWidth, MINWIDTH), Oy+originalHeight); sizeParent(Ox + realMinWidth, Oy + realMinHeight); sizeConstraints(realMinWidth, realMinHeight); } redraw(); } return 0; } // resize the image to the minimum of the current displayed width and height // of the _window_ and the width and height of the _image_, if need be... bool imageViewer::resize(void) { int minWidth, minHeight; int realNewWidth, realNewHeight; int wlimit, hlimit; bool retval = false; minWidth = trivmin(w(), currentImageWidth()); minHeight = trivmin(h(), currentImageHeight()); dbgprintf("Called resize(void)\n"); // window size limits depend only on the image and the screen limits wlimit = trivmin(appMaxWidth, currentImageWidth()); wlimit = trivmax(wlimit, MINWIDTH); hlimit = trivmin(appMaxHeight, currentImageHeight()); hlimit = trivmax(hlimit, MINHEIGHT); // if the user asked for too big a resize, we have to resize // the window too... if ((getdisplaymode() == IMV_DISPLAY_WINDOW_FIT_IMG) && parentWindow && (((w() > currentImageWidth()) && (w() > MINWIDTH)) || ((h() > currentImageHeight()) && (h() > MINHEIGHT)))) { sizeConstraints(wlimit, hlimit); realNewWidth = trivmin(appMaxWidth, minWidth); realNewWidth = trivmax(realNewWidth, MINWIDTH); realNewHeight = trivmin(appMaxHeight, minHeight); realNewHeight = trivmax(realNewHeight, MINHEIGHT); if (!sizeParent(Ox + realNewWidth, Oy + realNewHeight)) { dbgprintf("There was no resize but the image will require redrawing\n"); redraw_image(); } // We HAVE to worry about the scrollbars... if (hscrollbar) hscrollbar->resize(x(), y()+realNewHeight-HSLIDER_HEIGHT, realNewWidth-VSLIDER_WIDTH,HSLIDER_HEIGHT); if (vscrollbar) vscrollbar->resize(x()+realNewWidth-VSLIDER_WIDTH, y(), VSLIDER_WIDTH, realNewHeight-HSLIDER_HEIGHT); retval = true; // we did do a further resize to fit the window around the image } else { if (parentWindow) { sizeConstraints(wlimit, hlimit); } // no resize occured, but we still need to redraw the image // dbgprintf("No change in size, but we still require redraw\n"); // THIS REDRAW here is only necessary when doing a zoom without // resizing the window (alt + >, etc). IF doing a zoom with redraw, // (>, etc), this cause a double redraw that should be. Fixing this // is not simple... // redraw_image(); retval = false; } // There was an old omment here saying that we // didn't have to worry about resizing scrollbar. // The point was valid in the past but not since maximum values // for the size of the window have been set, because there // is no guarantee anymore that the window will be tight around // the image... return retval; } // so that we get passed the resize events void imageViewer::resize(int newx, int newy, int neww, int newh) { int minWidth, minHeight; int realNewWidth, realNewHeight; static int forgetNextEvent = 0; static int calls = 0; dbgprintf("imageViewer: Got a resize event: x:%d, y:%d, w:%d, h:%d\n", newx, newy, neww, newh); if (getdisplaymode() == IMV_DISPLAY_WINDOW_FIT_IMG) { calls++; // count the calls if ((calls < 3) && (neww == (SWIDTH-Ox)) && (newh == (SHEIGHT-Oy))) { dbgprintf("Listen, I'm not proud of this, but I can't figure out why FLTK\n"); dbgprintf("wants to resize this window\n"); dbgprintf("to the original size again!!, so I'm ignoring the event, so be it\n"); return; // forget it! } if (!forgetNextEvent) { // for the time being keep the size tight around the image minWidth = trivmin(neww, currentImageWidth()); minHeight = trivmin(newh, currentImageHeight()); realNewWidth = trivmin(appMaxWidth, minWidth); realNewHeight = trivmin(appMaxHeight, minHeight); realNewWidth = trivmax(realNewWidth, MINWIDTH); realNewHeight = trivmax(realNewHeight, MINHEIGHT); if (hscrollbar) hscrollbar->resize(newx, newy+realNewHeight-HSLIDER_HEIGHT, realNewWidth-VSLIDER_WIDTH,HSLIDER_HEIGHT); if (vscrollbar) vscrollbar->resize(newx+realNewWidth-VSLIDER_WIDTH, newy, VSLIDER_WIDTH, realNewHeight-HSLIDER_HEIGHT); // do the base class work as well Fl_Object::resize(newx, newy, realNewWidth, realNewHeight); } else { dbgprintf("Resize event discarded: now returning to normal\n"); forgetNextEvent = 0; } } else if (getdisplaymode() == IMV_DISPLAY_IMG_FIT_WINDOW) { dbgprintf("Stretching to fit\n"); Fl_Object::resize(newx, newy, neww, newh); } else if (getdisplaymode() == IMV_DISPLAY_DECOUPLE_WIN_IMG) { // resize the sliders if (hscrollbar) hscrollbar->resize(newx, newy + newh - HSLIDER_HEIGHT, neww - VSLIDER_WIDTH, HSLIDER_HEIGHT); if (vscrollbar) vscrollbar->resize(newx + neww - VSLIDER_WIDTH, newy, VSLIDER_WIDTH, newh - HSLIDER_HEIGHT); // resize base class too Fl_Object::resize(newx, newy, neww, newh); } else { warnprintf("Resize(non-void) called with unsupported display mode\n"); } // else nothing to do (maybe) return ; } void imageViewer::hposition(int newx) { if (newx == hposition_) return; hposition_ = trivmax(newx, 0); redraw_image(); } void imageViewer::vposition(int newy) { if (newy == vposition_) return; vposition_ = trivmax(newy, 0); redraw_image(); } void imageViewer::pan(int newx, int newy) { if (imageObject) { hposition_ = trivmax((int)(newx * imageZoomFactor_ + 0.5), 0) ; vposition_ = trivmax((int)(newy * imageZoomFactor_ + 0.5), 0) ; redraw_image(); } return; } double imageViewer::setDefaultZoomFactor(double f, bool forward) { defaultZoomFactor_ = f; if (forward && imview_linkmanager) { if (imview_linkmanager->setDefaultZoomFactor(f) > 0) dbgprintf("Remote set default zoom factor %g failed\n", f); } return(zoomFactor(f)); } // if useMinOfBoth is true, the whole image will be visible // if not, the whole screen will be filled with data, but // the image will exceed the screen boundary. // helper function: computes the max zoom // this is the zoom that will let the whole image be shown on screen. double imageViewer::computeMaxZoomFactor(bool useMinOfBoth) { double mxz = (double)(parentWindow->currentDisplayWidth())/(theImage->imageWidth()); double myz = (double)(parentWindow->currentDisplayHeight())/(theImage->imageHeight()); double fz; if (useMinOfBoth) { fz = trivmin(mxz, myz); } else { fz = trivmax(mxz, myz); } return fz; } // actually applies the max zoom and sets it as default zoom factor double imageViewer::applyMaxZoomFactor(bool useMinOfBoth) { defaultZoomFactor_ = computeMaxZoomFactor(useMinOfBoth); return zoomFactor(defaultZoomFactor_); } // changes the zoom factor of the image, and redisplays it double imageViewer::zoomFactor(double f, bool doRedraw, bool forward) { double oldfactor = imageZoomFactor_; double relf = f/oldfactor; if ((getdisplaymode() != IMV_DISPLAY_IMG_FIT_WINDOW) && imageObject && (f != oldfactor)) { // update cursors's posistions hposition_ = trivmax((hposition_ * relf) + ((relf - 1.0)*visibleHeight())/2.0, 0); vposition_ = trivmax((vposition_ * relf) + ((relf - 1.0)*visibleWidth())/2.0, 0); imageZoomFactor_ = trivmax(f,minZoomFactor_); // if resize returns true, the parent window will get resized, // there is no need to call redraw by hand. On the other hand, // if redraw is forced or the window is not redrawn, we should do it. if (!resize() && doRedraw) { dbgprintf("Redraw forced after zoom factor changed\n"); redraw_image(); } if (forward && imview_linkmanager) { if (imview_linkmanager->zoomfactor(f) > 0) dbgprintf("Remote zoom factor %g failed\n", f); } } else { dbgprintf("zoomFactor not updated\n"); } return (imageZoomFactor_); } // zooms to the box defined in the parameters // one of bw or bh can be 0, in which case the // aspect ratio is preserved. double imageViewer::zoomToBox(int bx, int by, int bw, int bh, bool forward) { double xzoom, yzoom; if (((bh > 0) || (bw > 0)) && imageObject) { dbgprintf("Zooming to x=%d, y=%d, w=%d, h= %d\n", bx, by, bw, bh); // corrections if (bx < 0) bx = 0; if (by < 0) by = 0; if (bw >= dataWidth()) bw = dataWidth(); if (bh >= dataHeight()) bh = dataHeight(); // if one of bw or bh is zero, change them so that // the current aspect ratio is unchanged. if (bw == 0) { bw = (int)(bh * ((double)visibleWidth()/visibleHeight()) + 0.5); } else if (bh == 0) { bh = (int)(bw * ((double)visibleHeight()/visibleWidth()) + 0.5); } if (hscrollbar && hscrollbar->visible()) { // horizontal scroll bar is already visible xzoom = (double)visibleWidth()/bw; } else { // scrollbar is not yet visible but will be. double rw = bw + ((double)VSLIDER_WIDTH*bw)/visibleWidth(); xzoom = (double)visibleWidth()/rw; } // same issue as above. if (vscrollbar && vscrollbar->visible()) { yzoom = (double)visibleHeight()/bh; } else { double rh = bh + ((double)HSLIDER_HEIGHT*bh)/visibleHeight(); yzoom = (double)visibleHeight()/rh; } // if the wanted aspect ratio and the current one are too different, // we resize the window to fit the bill if (!aspectConstrained) { // work out the zoom factor imageZoomFactor_ = trivmax(xzoom,yzoom); // but don't make the image wider or taller than the screen! imageZoomFactor_ = trivmin(imageZoomFactor_, (double)(appMaxWidth-Ox)/bw); imageZoomFactor_ = trivmin(imageZoomFactor_, (double)(appMaxHeight-Oy)/bh); hposition_ = trivmax(bx * imageZoomFactor_, 0) ; vposition_ = trivmax(by * imageZoomFactor_, 0) ; // window size limits depend only on the image and the screen limits int wlimit = trivmin(appMaxWidth, currentImageWidth()); wlimit = trivmax(wlimit, MINWIDTH); int hlimit = trivmin(appMaxHeight, currentImageHeight()); hlimit = trivmax(hlimit, MINHEIGHT); sizeConstraints(wlimit, hlimit); // actually size the parent dbgprintf("sizing the Parent from within zoomToBox\n"); sizeParent((int)(Ox + bw*imageZoomFactor_ + VSLIDER_WIDTH + 0.5), (int)(Oy + bh*imageZoomFactor_ + HSLIDER_HEIGHT + 0.5)); dbgprintf("Forcing redraw\n"); redraw_image(); } else { // if zooming in a square way: // work out the zoom factor imageZoomFactor_ = trivmin(xzoom, yzoom); hposition_ = trivmax(bx * imageZoomFactor_, 0) ; vposition_ = trivmax(by * imageZoomFactor_, 0) ; resize(); dbgprintf("Redraw forced after aspectConstrained zoomToBox\n"); redraw_image(); } if (forward && imview_linkmanager) { if (imview_linkmanager->zoombox(bx,by,bw,bh) > 0) // force other connected imviews to do the same dbgprintf("Remote zoombox failed\n"); } } return imageZoomFactor_; } int imageViewer::currentImageWidth(void) { if (imageObject) return ((int)(theImage->imageWidth() * imageZoomFactor_ + 0.5)); else return originalWidth; } int imageViewer::currentImageHeight(void) { if (imageObject) return ((int)(theImage->imageHeight() * imageZoomFactor_ + 0.5)); else return originalHeight; } void imageViewer::redraw_image() { dbgprintf("Redraw_image called\n"); damage(32); // experimental } // now the hard bits void imageViewer::drawScrollbars_decoupled(int imw, int imh, int visibleW, int visibleH) { if (scrollbartype_ != IMV_DISPLAY_DECOUPLE_WIN_IMG) { dbgprintf("In drawScrollbars_decoupled: wrong kind of scrollbars\n"); destroy_scrollbars(); } // create, show or hide horizontal scrollbar if necessary if (imw > visibleW) { if (!hscrollbar) create_hscrollbar_decoupled(); else if (!hscrollbar->visible()) { hscrollbar->show(); } } else { if (hscrollbar && hscrollbar->visible()) { hscrollbar->hide(); } } // create, show or hide vertical scrollbar if necessary if (imh > visibleH) { if (!vscrollbar) create_vscrollbar_decoupled(); else if (!vscrollbar->visible()) { vscrollbar->show(); } } else { if (vscrollbar && vscrollbar->visible()) { vscrollbar->hide(); } } // measure the dimensions of the actual display // area, taking slidebars presence into account // adjust positions if need be if (hposition_ + visibleW > imw) { // hposition is actually false, probably because of a resize event! hposition_ = trivmax(imw - visibleW, 0); } if (vposition_ + visibleH > imh) { // hposition is actually false, probably because of a resize event! vposition_ = trivmax(imh - visibleH, 0); } if (hscrollbar && hscrollbar->visible()) { hscrollbar->scrollvalue((int)(hposition_+0.5), // horizontal position of the window visibleW, // visible width 0, // by definition, horizontal origin of the image imw); // width of the image } if (vscrollbar && vscrollbar->visible()) { vscrollbar->scrollvalue((int)(vposition_ + 0.5), // vertical positin of the window visibleH, // visible height 0, // by definition, vertical origin of the image imh); // height of the image } return; } void imageViewer::drawScrollbars_win_fit_img(int imw, int imh, int &visibleW, int &visibleH) { bool scrollchanged = false; dbgprintf("Draw scrollbars, window-fit-image policy\n"); if (scrollbartype_ != IMV_DISPLAY_WINDOW_FIT_IMG) { dbgprintf("Wrong kind of scrollbar present\n"); destroy_scrollbars(); } // create, show or hide horizontal scrollbar if necessary if (imw > w()) { if (!hscrollbar) create_hscrollbar_win_fit_img(); else if (!hscrollbar->visible()) { dbgprintf("Showing horizontal scrollbar\n"); visibleH -= hscrollbar->h(); hscrollbar->show(); scrollchanged = true; } } else { if (hscrollbar && hscrollbar->visible()) { dbgprintf("Hiding horizontal scrollbar\n"); visibleH += hscrollbar->h(); hscrollbar->hide(); scrollchanged = true; } } // create, show or hide vertical scrollbar if necessary if (imh > h()) { if (!vscrollbar) create_vscrollbar_win_fit_img(); else if (!vscrollbar->visible()) { dbgprintf("Showing vertical scrollbar\n"); visibleW -= vscrollbar->w(); vscrollbar->show(); scrollchanged = true; } } else { if (vscrollbar && vscrollbar->visible()) { dbgprintf("Hiding vertical scrollbar\n"); visibleW += vscrollbar->w(); vscrollbar->hide(); scrollchanged = true; } } if (scrollchanged) dbgprintf("now, VisibleW = %d, VisibleH = %d\n", visibleW, visibleH); else dbgprintf("VisibleW and VisibleH unchanged\n"); // measure the dimensions of the actual display // area, taking slidebars presence into account // adjust positions if need be if (hposition_ + visibleW > imw) { // hposition is actually false, probably because of a resize event! hposition_ = trivmax(imw - visibleW, 0); } if (vposition_ + visibleH > imh) { // hposition is actually false, probably because of a resize event! vposition_ = trivmax(imh - visibleH, 0); } if (hscrollbar && hscrollbar->visible()) { hscrollbar->scrollvalue((int)(hposition_+0.5), // horizontal position of the window visibleW, // visible width 0, // by definition, horizontal origin of the image imw); // width of the image } if (vscrollbar && vscrollbar->visible()) { vscrollbar->scrollvalue((int)(vposition_ + 0.5), // vertical positin of the window visibleH, // visible height 0, // by definition, vertical origin of the image imh); // height of the image } return; } // draw the image when the window size and the image size are // no longer made to match void imageViewer::drawImage_decoupled(int imw, int imh, int imd, bool redrawBackground, bool smooth, int visibleW, int visibleH, int &d) // careful -- r/w { static int oldOx = -1, oldOy = -1, oldw = -1, oldh = -1; dbgprintf(" drawImage_decoupled:\n"); if ((zoomFactor() == 1.0) && useOffscreenBuff) { // we use hand-made double buffering. dbgprintf(" (zoomfactor == 1 && useOffscreenBuff)\n"); if ((imageObject->w() <= appMaxWidth) && (imageObject->h() <= appMaxHeight)) { // this is noticeable faster than // the generic function for any zoom factor // we allow dbgprintf(" imgdims <= appMax\n"); if ((imw >= visibleW) && (imh >= visibleH)) { oldw = -1; // reset the black box condition dbgprintf(" fl_draw_clipped -- imw and h >= visible\n"); fl_draw_clipped(imageObject, Ox, Oy, (int)(hposition_+0.5), (int)(vposition_+0.5), visibleW, visibleH); } else { // center image int newOx = (Ox + visibleW - imw)/2; newOx = trivmax(newOx, Ox); int newOy = (Oy + visibleH - imh)/2; newOy = trivmax(newOy, Oy); int neww = trivmin(imw, visibleW); int newh = trivmin(imh, visibleH); dbgprintf(" imw or h < visible\n"); dbgprintf(" NewOx=%d, newOy=%d\n", newOx, newOy); // draw a black box if necessary if ((newOx != oldOx) || (newOy != oldOy) || (neww != oldw) || (newh != oldh) || redrawBackground || (d != 32)) { dbgprintf(" draw white box, quick fill\n"); fl_color(FL_BLACK); // fill whole window fl_rectf(Ox,Oy,parentWindow->w(),parentWindow->h()); // quick fill //fl_color(FL_WHITE); //fl_rect(newOx-1, newOy-1,imw+2, imh+2); oldOx = newOx; oldOy = newOy; oldw = neww; oldh = newh; } dbgprintf(" fl_draw_clipped\n", newOx, newOy); fl_draw_clipped(imageObject, newOx, newOy, (int)(hposition_+0.5), (int)(vposition_+0.5), neww, newh); d = 0; } } else { dbgprintf(" one of imgdims > appMax\n"); // this is costing far less memory if ((imw >= visibleW) && (imh >= visibleH)) { oldw = -1; // reset the white box condition dbgprintf(" draw_cliped_nobuf, imw & h > visible\n"); fl_draw_clipped_nobuf(imageObject, Ox, Oy, (int)(hposition_+0.5), (int)(vposition_+0.5), visibleW, visibleH); } else { // center image int newOx = (Ox + visibleW - imw)/2; newOx = trivmax(newOx, Ox); int newOy = (Oy + visibleH - imh)/2; newOy = trivmax(newOy, Oy); int neww = trivmin(imw, visibleW); int newh = trivmin(imh, visibleH); dbgprintf(" imw or h <= visible\n"); dbgprintf(" NewOx=%d, newOy=%d\n", newOx, newOy); // draw a white box if necessary if ((newOx != oldOx) || (newOy != oldOy) || (neww != oldw) || (newh != oldh) || redrawBackground || (d != 32)) { dbgprintf(" quick fill (white box)\n"); fl_color(FL_BLACK); // fill whole window fl_rectf(Ox,Oy,parentWindow->w(),parentWindow->h()); // quick fill //fl_color(FL_WHITE); //fl_rect(newOx-1, newOy-1,imw+2, imh+2); oldOx = newOx; oldOy = newOy; oldw = neww; oldh = newh; } dbgprintf(" draw_clipped_nobuf\n"); fl_draw_clipped_nobuf(imageObject, newOx, newOy, (int)(hposition_+0.5), (int)(vposition_+0.5), neww, newh); d = 0; } } } else { dbgprintf(" (zoomfactor != 1 || !useOffscreenBuff)\n"); // this works for all zoom factors > 0.0... if ((imw >= visibleW) && (imh >= visibleH)) { oldw = -1; // reset the white box condition dbgprintf(" fl_draw_zcnb -- imw and h > visible\n"); fl_draw_zcnb(imageObject, Ox, Oy, visibleW, visibleH, (int)(hposition_/zoomFactor()), (int)(vposition_/zoomFactor()), (int)(visibleW/zoomFactor() + 0.5), (int)(visibleH/zoomFactor() + 0.5), smooth); } else { // white box // center the image int newOx = (Ox + visibleW - imw)/2; newOx = trivmax(newOx, Ox); int newOy = (Oy + visibleH - imh)/2; newOy = trivmax(newOy, Oy); int neww = trivmin(imw, visibleW); int newh = trivmin(imh, visibleH); dbgprintf(" imw or h <= visible\n"); // draw a white box if necessary dbgprintf(" NewOx=%d, newOy=%d\n", newOx, newOy); if ((newOx != oldOx) || (newOy != oldOy) || (neww != oldw) || (newh != oldh) || redrawBackground || (d != 32)) { dbgprintf(" draw white box\n"); fl_color(FL_BLACK); // fill whole window fl_rectf(Ox,Oy,parentWindow->w(),parentWindow->h()); // quick fill //fl_color(FL_WHITE); //fl_rect(newOx-1, newOy-1,imw+2, imh+2); oldOx = newOx; oldOy = newOy; oldw = neww; oldh = newh; } dbgprintf(" fl_draw_zcnb\n"); fl_draw_zcnb(imageObject, newOx, newOy, neww, newh, (int)(hposition_/zoomFactor()), (int)(vposition_/zoomFactor()), (int)(neww/zoomFactor() + 0.5), (int)(newh/zoomFactor() + 0.5), smooth); d = 0; } } nbPointDamage = 0; // reset point semaphore // reset the drawn status of lines linking point PtFileMngr->resetLinesStatus(); // reset the drawn status of profile line when we want it sticky if (angleLine && keepProfileLine) angleLine->drawnStatus(0); } // draw an image that fits the window as best we can. void imageViewer::drawImage_win_fit_img(int imw, int imh, int imd, bool redrawBackground, bool smooth, int visibleW, int visibleH, int &d) // careful -- r/w { static int oldOx = -1, oldOy = -1, oldw = -1, oldh = -1; dbgprintf(" drawImage:\n"); if ((zoomFactor() == 1.0) && useOffscreenBuff) { // we use hand-made double buffering. dbgprintf(" (zoomfactor == 1 && useOffscreenBuff)\n"); if ((imageObject->w() <= appMaxWidth) && (imageObject->h() <= appMaxHeight)) { // this is noticeable faster than // the generic function for any zoom factor // we allow dbgprintf(" imgdims <= appMax\n"); if ((imw >= visibleW) && (imh >= visibleH)) { oldw = -1; // reset the white box condition dbgprintf(" fl_draw_clipped -- imw and h >= visible\n"); fl_draw_clipped(imageObject, Ox, Oy, (int)(hposition_+0.5), (int)(vposition_+0.5), visibleW, visibleH); } else { // center image int newOx = Ox + (visibleW - imw)/2; newOx = trivmax(newOx, Ox); int newOy = Oy + (visibleH - imh)/2; newOy = trivmax(newOy, Oy); int neww = trivmin(imw, visibleW); int newh = trivmin(imh, visibleH); dbgprintf(" imw or h < visible\n"); dbgprintf(" NewOx=%d, newOy=%d\n", newOx, newOy); // draw a white box if necessary if ((newOx != oldOx) || (newOy != oldOy) || (neww != oldw) || (newh != oldh) || redrawBackground || (d != 32)) { dbgprintf(" draw white box, quick fill\n"); fl_color(FL_WHITE); fl_rectf(Ox,Oy,w(),h()); // quick fill fl_color(FL_BLACK); fl_rect(newOx-1, newOy-1,imw+2, imh+2); oldOx = newOx; oldOy = newOy; oldw = neww; oldh = newh; } dbgprintf(" fl_draw_clipped\n", newOx, newOy); fl_draw_clipped(imageObject, newOx, newOy, (int)(hposition_+0.5), (int)(vposition_+0.5), neww, newh); d = 0; } } else { dbgprintf(" one of imgdims > appMax\n"); // this is costing far less memory if ((imw >= visibleW) && (imh >= visibleH)) { oldw = -1; // reset the white box condition dbgprintf(" draw_cliped_nobuf, imw & h > visible\n"); fl_draw_clipped_nobuf(imageObject, Ox, Oy, (int)(hposition_+0.5), (int)(vposition_+0.5), visibleW, visibleH); } else { // center image int newOx = Ox + (visibleW - imw)/2; newOx = trivmax(newOx, Ox); int newOy = Oy + (visibleH - imh)/2; newOy = trivmax(newOy, Oy); int neww = trivmin(imw, visibleW); int newh = trivmin(imh, visibleH); dbgprintf(" imw or h <= visible\n"); dbgprintf(" NewOx=%d, newOy=%d\n", newOx, newOy); // draw a white box if necessary if ((newOx != oldOx) || (newOy != oldOy) || (neww != oldw) || (newh != oldh) || redrawBackground || (d != 32)) { dbgprintf(" quick fill (white box)\n"); fl_color(FL_WHITE); fl_rectf(Ox,Oy,w(),h()); // quick fill fl_color(FL_BLACK); fl_rect(newOx-1, newOy-1,imw+2, imh+2); oldOx = newOx; oldOy = newOy; oldw = neww; oldh = newh; } dbgprintf(" draw_clipped_nobuf\n"); fl_draw_clipped_nobuf(imageObject, newOx, newOy, (int)(hposition_+0.5), (int)(vposition_+0.5), neww, newh); d = 0; } } } else { dbgprintf(" (zoomfactor != 1 || !useOffscreenBuff)\n"); // this works for all zoom factors > 0.0... if ((imw >= visibleW) && (imh >= visibleH)) { oldw = -1; // reset the white box condition dbgprintf(" fl_draw_zcnb -- imw and h > visible\n"); fl_draw_zcnb(imageObject, Ox, Oy, visibleW, visibleH, (int)(hposition_/zoomFactor()), (int)(vposition_/zoomFactor()), (int)(visibleW/zoomFactor() + 0.5), (int)(visibleH/zoomFactor() + 0.5), smooth); } else { // white box // center the image int newOx = Ox + (visibleW - imw)/2; newOx = trivmax(newOx, Ox); int newOy = Oy + (visibleH - imh)/2; newOy = trivmax(newOy, Oy); int neww = trivmin(imw, visibleW); int newh = trivmin(imh, visibleH); dbgprintf(" imw or h <= visible\n"); // draw a white box if necessary dbgprintf(" NewOx=%d, newOy=%d\n", newOx, newOy); if ((newOx != oldOx) || (newOy != oldOy) || (neww != oldw) || (newh != oldh) || redrawBackground || (d != 32)) { dbgprintf(" draw white box\n"); fl_color(FL_WHITE); fl_rectf(Ox,Oy,w(),h()); // quick fill fl_color(FL_BLACK); fl_rect(newOx-1, newOy-1,imw+2, imh+2); oldOx = newOx; oldOy = newOy; oldw = neww; oldh = newh; } dbgprintf(" fl_draw_zcnb\n"); fl_draw_zcnb(imageObject, newOx, newOy, neww, newh, (int)(hposition_/zoomFactor()), (int)(vposition_/zoomFactor()), (int)(neww/zoomFactor() + 0.5), (int)(newh/zoomFactor() + 0.5), smooth); d = 0; } } nbPointDamage = 0; // reset point semaphore // reset the drawn status of lines linking point PtFileMngr->resetLinesStatus(); // reset the drawn status of profile line when we want it sticky if (angleLine && keepProfileLine) angleLine->drawnStatus(0); } void imageViewer::draw() { int imw,imh,imd; int i; int d = damage(); bool redrawBackground; bool smooth; if (!parentWindow) // nothing to see return; if (hideMainMenu) { //position(x(), 0); Oy = 0; } else { //position(x(), MENUHEIGHT); Oy = MENUHEIGHT; } dbgprintf("Drawing the image now\n"); if (d == FL_DAMAGE_ALL) { d = 32 ; // 32 redraws absolutely everything... redrawBackground = true; dbgprintf("Damage is FL_DAMAGE_ALL, reduced to 32\n"); } else { redrawBackground = false; } if ((d & 32) || (d & 16) || (d & 8) || (d & 4)) { // get the smooth preference issue sorted out if (fileprefs) smooth = fileprefs->smoothZoomout(); // use the users' pref when available else smooth = false; // by default do not draw smoothly when (un)zooming // redraw parts or all of the image: if (imageObject) { imw = currentImageWidth(); imh = currentImageHeight(); imd = currentImageDepth(); if (getdisplaymode() == IMV_DISPLAY_IMG_FIT_WINDOW) { dbgprintf("Draw to fit windows w=%d, h=%d\n", w(), h()); fl_draw_zcnb(imageObject, Ox, Oy, w(), h(), 0, 0, imw, imh, smooth); xZoomFactor_ = w()/(double)imw; yZoomFactor_ = h()/(double)imh; } else { int visibleW = visibleWidth(); int visibleH = visibleHeight(); dbgprintf("VisibleW = %d, visibleH =%d\n", visibleW, visibleH); if (getdisplaymode() == IMV_DISPLAY_WINDOW_FIT_IMG) drawScrollbars_win_fit_img(imw, imh, visibleW, visibleH); else if (getdisplaymode() == IMV_DISPLAY_DECOUPLE_WIN_IMG) drawScrollbars_decoupled(imw, imh, parentWindow->w(), parentWindow->h()); if (d & 32 || (imw < visibleW) || (imh < visibleH)) { // complete redraw of the image if (getdisplaymode() == IMV_DISPLAY_WINDOW_FIT_IMG) drawImage_win_fit_img(imw, imh, imd, redrawBackground, smooth, visibleW, visibleH, d); else if (getdisplaymode() == IMV_DISPLAY_DECOUPLE_WIN_IMG) drawImage_decoupled(imw, imh, imd, redrawBackground, smooth, parentWindow->w(), parentWindow->h(), d); } if (d & 16) { // only redraws the top of the image (where the information box was) if (zoomFactor() == 1.0) { fl_draw_clipped_nobuf(imageObject, Ox, Oy, (int)(hposition_+0.5), (int)(vposition_+0.5), visibleW, STATUS_HEIGHT); } else if (zoomFactor() > 1.0 ) { fl_draw_zcnb(imageObject, Ox, Oy, visibleW, STATUS_HEIGHT, (int)(hposition_/zoomFactor()), (int)(vposition_/zoomFactor()), (int)(visibleW/zoomFactor() + 0.5), (int)(STATUS_HEIGHT/zoomFactor() + 0.5), smooth); } else { // unfortunately, in this particular situation the zoom is broken. // we need to redraw the whole thing fl_draw_zcnb(imageObject, Ox, Oy, visibleW, visibleH, (int)(hposition_/zoomFactor()), (int)(vposition_/zoomFactor()), (int)(visibleW/zoomFactor() + 0.5), (int)(visibleH/zoomFactor() + 0.5), smooth); } } if (d & 8) { // only redraws the bottom of the image (where the information box was) if (zoomFactor() == 1.0) { fl_draw_clipped_nobuf(imageObject, Ox, Oy+visibleHeight()-STATUS_HEIGHT, (int)(hposition_+0.5), (int)(vposition_+visibleHeight()-STATUS_HEIGHT+0.5), visibleW, STATUS_HEIGHT); } else { fl_draw_zcnb(imageObject, Ox, Oy+visibleHeight()-STATUS_HEIGHT, visibleW, STATUS_HEIGHT, (int)(hposition_/zoomFactor() + 0.5), (int)((vposition_+visibleHeight()-STATUS_HEIGHT)/zoomFactor() +0.5), (int)(visibleW/zoomFactor() + 0.5), (int)(STATUS_HEIGHT/zoomFactor() + 0.5), smooth); } } if (d & 4) { // delete point from pointfiles dbgprintf("Actually deleting point at %d,%d\n", delPtX, delPtY); if (zoomFactor() == 1.0) { fl_draw_clipped_nobuf(imageObject, (int)(Ox - hposition_ + delPtX-4 + 0.5), (int)(Oy - vposition_ + delPtY-4 + 0.5), delPtX - 4, delPtY - 4, 9, 9); } else if (zoomFactor() > 1.0) { int minx, miny; int wWin, hWin; minx = delPtX - 4; miny = delPtY - 4; wWin = 9; hWin = 9; fl_draw_zcnb(imageObject, xOnWindow(minx-0.5), yOnWindow(miny-0.5), (int)(wWin*zoomFactor()+0.5), (int)(hWin*zoomFactor()+0.5), minx, miny, wWin, hWin, smooth); } else { int minx, miny; int wWin, hWin; minx = delPtX - (int)(4/zoomFactor()+0.5); miny = delPtY - (int)(4/zoomFactor()+0.5); wWin = 9; hWin = 9; fl_draw_zcnb(imageObject, xOnWindow(minx-0.5), yOnWindow(miny-0.5), wWin, hWin, minx, miny, (int)(wWin/zoomFactor()+0.5), (int)(hWin/zoomFactor()+0.5), smooth); } nbPointDamage--; } } } // draws the children dbgprintf("Redrawing %d children\a", children()); for (i = 0 ; i < children() ; i ++) { if (child(i)->visible()) { dbgprintf(" %d...", i); child(i)->redraw(); child(i)->draw(); } } dbgprintf(" done\b"); } else if (d & 1) { // only redraw the children that need it //dbgprintf("Damage(1)\n"); dbgprintf("Only redrawing %d children\a", children()); for (i = 0 ; i < children() ; i++) { if (child(i)->visible()) { dbgprintf(" %d...", i); child(i)->redraw(); child(i)->draw(); } } } // update the image information if possible if (imageInfoPanel) imageInfoPanel->update(); return; } // this is now much easier to write since 0.96 int imageViewer::handle(int event) { int retval = 0; static int button = 0; static bool pushedHere = false; // we want to drag the scrollbar only if the push occured in the scrollbar. //dbgprintf("Image Viewer: Got event %d" // " Mouse position: x=%d, y=%d\n", // event, Fl::event_x(), Fl::event_y()); // got to figure out where the scrollbars are. if (vscrollbar && vscrollbar->visible() && (Fl::event_inside(vscrollbar))) { if ((event != FL_PUSH) && pushedHere) { if (event == FL_DRAG) { if (Fl::event_state(FL_BUTTON1)) { handleLeftButtonDragged(); retval = 1; } else if (Fl::event_state(FL_BUTTON2)) { handleMiddleButtonDragged(); retval = 1; } else if (Fl::event_state(FL_BUTTON3)) { // do nothing retval = 1; } } else if (event == FL_RELEASE) { dbgprintf("Release, event state %d\n", Fl::event_state()); // in this instance, Fl::event_state() doesn't help button = Fl::event_button(); if (button == LEFT_BUTTON) { handleLeftButtonReleased(); retval = 1; } else if (button == MIDDLE_BUTTON) { handleMiddleButtonReleased(); retval = 1; } else if (button == RIGHT_BUTTON) { handleRightButtonReleased(); retval = 1; } } } else { // simply returning 0 and hoping for the best will not be suffficient // for the children to handle what they need to handle if (event == FL_PUSH) pushedHere = false; // push event occurs in the scroll bars // the documentation says explicitely to call this: if (Fl_Group::handle(event)) return 1; // verify that no stone has been left unturned //handleLeftButtonReleased(); } } else if (hscrollbar && hscrollbar->visible() && (Fl::event_inside(hscrollbar))) { if ((event != FL_PUSH) && pushedHere) { if (event == FL_DRAG) { if (Fl::event_state(FL_BUTTON1)) { handleLeftButtonDragged(); retval = 1; } else if (Fl::event_state(FL_BUTTON2)) { handleMiddleButtonDragged(); retval = 1; } else if (Fl::event_state(FL_BUTTON3)) { // do nothing retval = 1; } } else if (event == FL_RELEASE) { button = Fl::event_button(); if (button == LEFT_BUTTON) { handleLeftButtonReleased(); retval = 1; } else if (button == MIDDLE_BUTTON) { handleMiddleButtonReleased(); retval = 1; } else if (button == RIGHT_BUTTON) { handleRightButtonReleased(); retval = 1; } } } else { if (event == FL_PUSH) pushedHere = false; // push event occurs in the scroll bars // verify that no stone has been left unturned // the documentation says explicitely to call this: if (Fl_Group::handle(event)) return 1; // verify that no stone has been left unturned //handleLeftButtonReleased(); } } else if (imageObject) { // otherwise there is nothing to do // we have to take care of the event by ourselves switch (event) { case FL_PUSH: //button = Fl::event_button(); pushedHere = true; if (Fl::event_state(FL_BUTTON1)) { handleLeftButtonPushed(); retval = 1; } else if (Fl::event_state(FL_BUTTON2)) { handleMiddleButtonPushed(); retval = 1; } else if (Fl::event_state(FL_BUTTON3)) { // we do nothing, but we handle the event retval = 1; } break; case FL_DRAG: if (Fl::event_state(FL_BUTTON1)) { handleLeftButtonDragged(); retval = 1; } else if (Fl::event_state(FL_BUTTON2)) { handleMiddleButtonDragged(); retval = 1; } else if (Fl::event_state(FL_BUTTON3)) { // we still do nothing, but we expect the release event! retval = 1; } break; case FL_RELEASE: pushedHere = false; button = Fl::event_button(); if (button == LEFT_BUTTON) { handleLeftButtonReleased(); retval = 1; } else if (button == MIDDLE_BUTTON) { handleMiddleButtonReleased(); retval = 1; } else if (button == RIGHT_BUTTON) { handleRightButtonReleased(); retval = 1; } break; case FL_ENTER: // Mouse focus, change the cursor to the local default chg_cursor(MY_CURSOR_DEFAULT); retval = 1; break; case FL_MOVE: { pointermode m = getpointermode(0); if (Fl::event_state(FL_SHIFT) || (m == IMV_POINTER_EDITPT_MODE) || (m == IMV_POINTER_DELPT_MODE) || (m == IMV_POINTER_DELGRP_MODE)) { // inexpensive calculation first int x, y, X, Y; x = Fl::event_x(); y = Fl::event_y(); // make sure we stay in the image if (x < Ox) x = Ox; if (y < Oy) y = Oy; if (x < Ox) x = Ox; if (x >= visibleWidth()+Ox) x = visibleWidth()+Ox -1; if (y < Oy) y = Oy; if (y >= visibleHeight()+Oy) y = visibleHeight()+Oy -1; X = xInImage(x); // convert local coordinates to image ones. Y = yInImage(y); if (Fl::event_state(FL_CTRL) || Fl::event_state(FL_ALT) || (m == IMV_POINTER_EDITPT_MODE) || (m == IMV_POINTER_DELPT_MODE) || (m == IMV_POINTER_DELGRP_MODE)) { // expensive bit here if (PtFileMngr->isValidPoint(X,Y)) { if (Fl::event_state(FL_CTRL) || (m == IMV_POINTER_EDITPT_MODE)) // re-test chg_cursor(MY_CURSOR_INSERT); else chg_cursor(MY_CURSOR_KILL); } else { // not near a valid poing if (m == IMV_POINTER_EDITPT_MODE) chg_cursor(MY_CURSOR_RHAND); // inverted contrast else if ((m == IMV_POINTER_DELPT_MODE) || (m == IMV_POINTER_DELGRP_MODE)) chg_cursor(MY_CURSOR_LHAND); else chg_cursor(MY_CURSOR_DEFAULT); } } } else { // more mundane modes (no need to look if close to a point) switch (m) { case IMV_POINTER_SELECT_MODE: chg_cursor(MY_CURSOR_SELECT); break; case IMV_POINTER_MEASURE_MODE: chg_cursor(MY_CURSOR_MEASURE); break; case IMV_POINTER_ADDPT_MODE: chg_cursor(MY_CURSOR_DOT); break; case IMV_POINTER_DRAWPT_MODE: chg_cursor(MY_CURSOR_DRAW); break; default: chg_cursor(MY_CURSOR_DEFAULT); break; } } } break; case FL_LEAVE: // Return to normal cursor chg_cursor(FL_CURSOR_DEFAULT); retval = 1; break; case FL_FOCUS: dbgprintf("Image viewer has keyboard focus\n"); retval = 1; // we want the focus! break; case FL_UNFOCUS: dbgprintf("Image viewer focus released\n"); retval = 1; // we release the focus break; case FL_SHORTCUT: dbgprintf("Event is a shortcut\n"); case FL_KEYBOARD: // try to handle the event, and if not, send it to the children if ((retval = handleKeyboardEvent()) == 0) retval = Fl_Group::handle(event); break; } } // DnD events which don't depend on any special feature. // switch (event) { // drag and drop case FL_DND_ENTER: // we signal we are ready to take the next events dbgprintf("Ready to accept DnD events\n"); // the cursor changes automatically. retval = 1; break; case FL_DND_DRAG: dbgprintf("Received DnD drag event\n"); // doesn't matter too much retval = 1; break; case FL_DND_LEAVE: dbgprintf("Received DnD leave event\n"); // the cursor changes automatically retval = 1; break; case FL_DND_RELEASE: dbgprintf("Received DnD release event, we signal for the Paste event\n"); // nothing else to do. retval = 1; break; case FL_PASTE: { char textEvent[DFLTSTRLEN]; char *fns[DFLTSTRLEN], *currentstr, *nextstr; int nbim; // we've received a cut-and-paste event dbgprintf("Received a Paste event\n"); strncpy(textEvent, Fl::event_text(), DFLTSTRLEN); dbgprintf("Text = %s\n", textEvent); // one image per line for (nbim = 0, currentstr = textEvent, nextstr = 0 ; nbim < DFLTSTRLEN ; ++nbim, currentstr = nextstr) { fns[nbim] = currentstr; nextstr = strchr(currentstr, '\n'); if ((nextstr == 0) || (*nextstr == '\0')) { ++nbim; break; } else { // replace \n by \0 *nextstr = '\0'; // in-place End-of-String ++nextstr; // go one past the '\n' } } // load all the images into the list, display the last one for (int i = 0 ; i < nbim ; ++i) { dbgprintf("Opening %s", fns[i]); mainMenuBar->addToItemList(fns[i], IMAGE_LIST_ID); } openimage(fns[nbim-1]); retval = 1; break; } } return retval; } // private methods static void hscrollbar_callback(Fl_Object *hs,void *) { int localpos = int(((Fl_Slider *)hs)->value()); //dbgprintf("Horizontal scrollbar callback called, local pos = %d\n", localpos); ((imageViewer *)(hs->parent()))->hposition(localpos); } static void vscrollbar_callback(Fl_Object *vs,void *) { int localpos = int(((Fl_Slider *)vs)->value()); //dbgprintf("Vertical scrollbar callback called, local pos = %d\n", localpos); ((imageViewer *)(vs->parent()))->vposition(localpos); } // returns true if resize does occur bool imageViewer::sizeParent(int sizeX, int sizeY) { static int oldSizeX = -1, oldSizeY = -1; static int realSizeX, realSizeY; bool retval = false; if (getdisplaymode() != IMV_DISPLAY_DECOUPLE_WIN_IMG) { realSizeX = trivmax(sizeX, Ox + MINWIDTH); realSizeY = trivmax(sizeY, Oy + MINHEIGHT); // do the resize only if needed if ((realSizeX != oldSizeX) || (realSizeY != oldSizeY) || (realSizeX != parentWindow->w()) || (realSizeY != parentWindow->h())) { dbgprintf("Resizing parent window to [%d]x[%d]\n", realSizeX, realSizeY); parentWindow->size(realSizeX, realSizeY); oldSizeX = realSizeX; oldSizeY = realSizeY; retval = true; } } return retval; } void imageViewer::setdisplaymode(displaymode m) { dmode_ = m; switch (m) { case IMV_DISPLAY_WINDOW_FIT_IMG: allowSizeConstraints(true); break; default: allowSizeConstraints(false); break; } return; } // allow or disallows size constraints void imageViewer::allowSizeConstraints(bool tf) { if (tf) { sizeConstrained = true; resize(); } else { sizeConstrained = false; // might be dangerous... parentWindow->size_range(MINWIDTH,MINHEIGHT,0,0); } return; } // handles the max/min size constraints void imageViewer::sizeConstraints(int maxwidth, int maxheight) { int windowMaxWidth, windowMaxHeight; int windowMinWidth, windowMinHeight; static int oldMaxWidth = -1, oldMaxHeight = -1; static int oldMinWidth = -1, oldMinHeight = -1; if (getdisplaymode() != IMV_DISPLAY_WINDOW_FIT_IMG) { dbgprintf("Display mode not compatible with constraints\n"); parentWindow->size_range(MINWIDTH,MINHEIGHT,0,0); return; // no constraint here } windowMaxWidth = Ox + maxwidth; windowMaxHeight = Oy + maxheight; windowMinWidth = Ox+MINWIDTH; windowMinHeight = Oy+MINHEIGHT; // now weird things can happen if the max size as given // above are larger than the minimum size, which can // happen if the zoom factor is large and the image quite small... if (windowMaxWidth <= windowMinWidth) { dbgprintf("Rounding error in window width measurement:%d\n", windowMaxWidth); // MinWidth is not all that important as long at the menu can still be seen windowMaxWidth = windowMinWidth + 2; } if (windowMaxHeight <= windowMinHeight) { dbgprintf("Rounding error in window height measurement:%d\n", windowMaxHeight); // minheight is more critical as it is much smaller windowMaxHeight = windowMinHeight + 2; } if ((windowMaxWidth != oldMaxWidth) || (windowMaxHeight != oldMaxHeight) || (windowMinWidth != oldMinWidth) || (windowMinHeight != oldMinHeight)) { // we need to update the limits dbgprintf("Setting up limits to: minw= %d, minh= %d, maxw = %d, minw = %d\n", windowMinWidth, windowMinHeight, windowMaxWidth, windowMaxHeight); parentWindow->size_range(windowMinWidth, windowMinHeight, windowMaxWidth, windowMaxHeight); oldMaxWidth = windowMaxWidth; oldMaxHeight = windowMaxHeight; oldMinWidth = windowMinWidth; oldMinHeight = windowMinHeight; } else { dbgprintf("Windows limits unchanged\n"); } return; } // return the position and dimensions of the subset // of the image currently being displayed. void imageViewer::getCurrentBox(int &bx, int &by, int &bw, int &bh) { // this is now not so bad if (zoomDragInProgress) { bx = dragX; by = dragY; bw = dragW; bh = dragH; } else { if ((currentImageWidth() >= visibleWidth()) && (currentImageHeight() >= visibleHeight())) { bx = (int)(hposition_/zoomFactor()); by = (int)(vposition_/zoomFactor()); bw = (int)(visibleWidth()/zoomFactor() + 0.5); bh = (int)(visibleHeight()/zoomFactor() + 0.5); } else { int neww = trivmin(currentImageWidth(), visibleWidth()); int newh = trivmin(currentImageHeight(), visibleHeight()); bx = (int)(hposition_/zoomFactor()); by = (int)(vposition_/zoomFactor()); bw = (int)(neww/zoomFactor() + 0.5); bh = (int)(newh/zoomFactor() + 0.5); } } return; } void imageViewer::removeLine(void) { keepProfileLine = false; if (angleLine != 0) { // remove the last line parentWindow->make_current(); angleLine->undraw(); remove(angleLine); delete angleLine; angleLine = 0; } return; } // the X and Y position in the image are difficult to // compute from the position of the cursor, because an integer // number of pixels is always displayed, even at very high magnifications. // 18 Jul 1998: this has become even more difficult now that the actual // image may be lost in the middle of the display area at low magnification, // of for small images. // computes the x position in the image given a X position on the window int imageViewer::xInImage(int x) { int imw = currentImageWidth(); int visibleW = visibleWidth(); int newWidth = trivmin(imw, visibleW); int newOx = Ox + (visibleW - imw)/2; newOx = trivmax(newOx, Ox); //double realxf = (double)visibleW/((int)(visibleW/zoomFactor() + 0.5)); double realxf = (double)newWidth/((int)(newWidth/zoomFactor() + 0.5)); return ((int)((x - newOx)/realxf) + (int)(hposition_ / zoomFactor())); } // computes the X position on the window given a x position in the image int imageViewer::xOnWindow(double X) { double realxf = (double)visibleWidth()/((int)(visibleWidth()/zoomFactor() + 0.5)); int woffset = Ox + (visibleWidth() - currentImageWidth())/2; woffset = trivmax(woffset, Ox); return((int)(realxf *((X+0.5) - (int)(hposition_/zoomFactor())) + woffset)); } // Computes the x position in the window given an x position in the window ! inline int imageViewer::xWtoW(int x) { double realxf = (double)visibleWidth()/((int)(visibleWidth()/zoomFactor() + 0.5)); return((int)(realxf * (int)((x - Ox)/realxf)) + Ox); } // adjust a width in the window to fall on an integer number of pixels. inline int imageViewer::adjW(int w) { double realxf = (double)visibleWidth()/((int)(visibleWidth()/zoomFactor() + 0.5)); return((int)(realxf * (int)(w/realxf + 1) + 0.5)); } // computes the y position in the image given a Y position on the window inline int imageViewer::yInImage(int y) { int imh = currentImageHeight(); int visibleH = visibleHeight(); int newHeight = trivmin(imh, visibleH); int newOy = Oy + (visibleH - imh)/2; newOy = trivmax(newOy, Oy); //double realyf = (double)visibleHeight()/((int)(visibleHeight()/zoomFactor() + 0.5)); double realyf = (double)newHeight/((int)(newHeight/zoomFactor() + 0.5)); return ((int)((y - newOy)/realyf) + (int)(vposition_ / zoomFactor())); } // computes the Y position on the window given a y position in the image int imageViewer::yOnWindow(double Y) { double realyf = (double)visibleHeight()/((int)(visibleHeight()/zoomFactor() + 0.5)); int hoffset = Oy + (visibleHeight() - currentImageHeight())/2; hoffset = trivmax(hoffset, Oy); return((int)(realyf *((Y+0.5) - (int)(vposition_/zoomFactor())) + hoffset)); } // computes the y position in the window given a y position in the window ! inline int imageViewer::yWtoW(int y) { double realyf = (double)visibleHeight()/((int)(visibleHeight()/zoomFactor() + 0.5)); return((int)(realyf * (int)((y - Oy)/realyf)) + Oy); } // adjust a height in the window to fall on an integer number of pixels inline int imageViewer::adjH(int h) { double realyf = (double)visibleHeight()/((int)(visibleHeight()/zoomFactor() + 0.5)); return((int)(realyf * (int)(h/realyf + 1) + 0.5)); } inline int imageViewer::wInImage(int w) { double realxf = (double)visibleWidth()/((int)(visibleWidth()/zoomFactor() + 0.5)); return ((int)(w/realxf + 0.5)); } inline int imageViewer::hInImage(int h) { double realyf = (double)visibleHeight()/((int)(visibleHeight()/zoomFactor() + 0.5)); return ((int)(h / realyf + 0.5)); } ///////////////////// /// Left button operations void imageViewer::handleLeftButtonPushed() { int x, y, xs, ys, ws, hs; pointermode currentMode = getpointermode(LEFT_BUTTON); // create the status line x = Fl::event_x(); y = Fl::event_y(); xs = Ox; ws = visibleWidth(); hs = STATUS_HEIGHT; // defined in imageViewer.hxx if (y > visibleHeight()/2) { ys = Oy; } else { ys = Oy+visibleHeight()-STATUS_HEIGHT; } // quick fix to a slightly unusual problem: // previous status line had not been deleted! if (statusLine) { if (statusLine->y() == Oy) damage(16); // redisplay top of the image else damage(8); // redisplay bottom of the image remove(statusLine); delete statusLine; statusLine = 0; } if (currentMode != IMV_POINTER_SELECT_MODE) { statusLine = new Fl_Output(xs, ys, ws, hs, 0); // no label // mode handling switch (currentMode) { case IMV_POINTER_ADDPT_MODE: // invert colours statusLine->color(FL_BLACK); statusLine->textcolor(FL_WHITE); chg_cursor(MY_CURSOR_DOT); break; case IMV_POINTER_DRAWPT_MODE: // invert colours statusLine->color(FL_BLACK); statusLine->textcolor(FL_WHITE); chg_cursor(MY_CURSOR_DRAW); break; case IMV_POINTER_DELPT_MODE: case IMV_POINTER_DELGRP_MODE: // invert colours statusLine->color(FL_BLACK); statusLine->textcolor(FL_WHITE); chg_cursor(MY_CURSOR_KILL); break; case IMV_POINTER_MEASURE_MODE: lineProfileInProgress = true; statusLine->color(FL_BLUE); statusLine->textcolor(FL_YELLOW); chg_cursor(FL_CURSOR_HAND); angleStartX = x; angleStartY = y; break; default: // just change the cursor to a crosshair chg_cursor(MY_CURSOR_CROSS); break; } statusLine->textfont(STATUS_FONT); statusLine->textsize(STATUS_SIZE); add(statusLine); } else { // select mode doesn't require the statusLine, rather, it slows things down. selectBoxX = x; selectBoxY = y; selectBoxDefined = 1; nbFlBoxDamage = 0; chg_cursor(MY_CURSOR_SELECT); } // call `left button dragged' handler // so that the status line appears without having to wiggle the mouse around... handleLeftButtonDragged(); return; } void imageViewer::handleLeftButtonDragged() { int x, y, X, Y, d; const unsigned char *p; unsigned char r, g, b; // it is possible to get there without handleLeftButtonPushed // having been called. This can happen if you push the left button // in one of the scrollbar and drag past its boundary. In this // case this present routine is called, but there never was any statusLine // allocated. if (statusLine) { x = Fl::event_x(); y = Fl::event_y(); // fix up the x and y values: if (x < Ox) x = Ox; if (y < Oy) y = Oy; if (x > visibleWidth() + Ox - 1) x = visibleWidth() + Ox - 1; if (y > visibleHeight() + Oy - 1) y = visibleHeight() + Oy - 1; // which mode are we in switch (getpointermode(LEFT_BUTTON)) { case IMV_POINTER_ADDPT_MODE: statusLine->color(FL_BLACK); statusLine->textcolor(FL_WHITE); chg_cursor(MY_CURSOR_DOT); break; case IMV_POINTER_DRAWPT_MODE: statusLine->color(FL_BLACK); statusLine->textcolor(FL_YELLOW); chg_cursor(MY_CURSOR_DRAW); { // add point pointParams mypp; // initialized with defaults mypp.size=1; mypp.pts=1; mypp.annotated=true; // draw in the current colour, increment colour at break mypp.col=fl_closest_index(currentPtColour_); X = xInImage(x); // convert local coordinates to image ones. Y = yInImage(y); d = imageObject->d(); p = (unsigned char *)(imageObject->data()[0] + d *(X + Y * imageObject->w())); if (d == 3) { PtFileMngr->addPoint(X,Y,theImage->getCurrZpos(), *p, *(p+1), *(p+2), theImage->hasRawData(), // is there more data yet? mypp); } else { PtFileMngr->addPoint(X,Y,theImage->getCurrZpos(), *p, *p, *p, theImage->hasRawData(), // is there more data yet? mypp); } } break; case IMV_POINTER_DELPT_MODE: case IMV_POINTER_DELGRP_MODE: statusLine->color(FL_BLACK); statusLine->textcolor(FL_WHITE); chg_cursor(MY_CURSOR_KILL); break; case IMV_POINTER_MEASURE_MODE: statusLine->color(FL_BLUE); statusLine->textcolor(FL_YELLOW); chg_cursor(FL_CURSOR_HAND); break; case IMV_POINTER_SELECT_MODE: statusLine->color(FL_BLACK); statusLine->textcolor(FL_WHITE); chg_cursor(MY_CURSOR_SELECT); break; default: statusLine->color(FL_WHITE); statusLine->textcolor(FL_BLACK); chg_cursor(MY_CURSOR_CROSS); break; } if (!lineProfileInProgress) { // decide the content of the status line in the pointwise cases X = xInImage(x); // convert local coordinates to image ones. Y = yInImage(y); if (X >= theImage->imageWidth()) X = theImage->imageWidth() - 1; else if (X < 0) X = 0; if (Y >= theImage->imageHeight()) Y = theImage->imageHeight() - 1; else if (Y < 0) Y = 0; d = imageObject->d(); // serious change in FLTK-1.1.x p = (const unsigned char *)imageObject->data()[0] + d *(X + Y * imageObject->w()); if (d == 3) { r = *p; g = *(p+1); b = *(p+2); if (theImage->getCurrImgThickness() == 1) { // no 3-D information sprintf(statusMessage,"x=%d, y=%d, r=%d, g=%d, b=%d %s", X, Y, r, g, b, theImage->getRawDataInfo(X, Y)); } else { sprintf(statusMessage,"x=%d, y=%d, z=%d, r=%d, g=%d, b=%d %s", X, Y, theImage->getCurrZpos(), r, g, b, theImage->getRawDataInfo(X, Y)); } } else { g = b = r = *p; if (theImage->getCurrImgThickness() == 1) { sprintf(statusMessage,"x=%d, y=%d, gl=%d %s", X, Y, r, theImage->getRawDataInfo(X, Y)); } else { sprintf(statusMessage,"x=%d, y=%d, z=%d, gl=%d %s", X, Y, theImage->getCurrZpos(), r, theImage->getRawDataInfo(X, Y)); } } // hyperspectral data if ((theImage->getCurrImgNbSamples() > 1) && spectraPanel && spectraPanel->visible()) { int nb; double *s; dbgprintf("sendind data to spectra panel\n"); s = theImage->getRawDataVector(X,Y,&nb); spectraPanel->setData(s,nb, X, Y); spectraPanel->redraw(); } else { dbgprintf("Nbcomp=%d, spectrapanel=%p, visible=%d\n", theImage->getCurrImgNbComps(), spectraPanel, (spectraPanel) ? spectraPanel->visible():0); } // 3D data depth profile if ((theImage->getCurrImgThickness() > 1) && depthProfile && depthProfile->visible()) { int nb; double *s; dbgprintf("sendind data to depth profile panel\n"); s = theImage->get3DRawDataVector(X, Y, &nb); depthProfile->setData(s,nb, X, Y); depthProfile->redraw(); } } else { // decides the content of the status line in profile mode int X2, Y2; double angle, distance; X = xInImage(x); Y = yInImage(y); X2 = xInImage(angleStartX); Y2 = yInImage(angleStartY); distance = sqrt((double)(X-X2)*(X-X2)+(Y-Y2)*(Y-Y2)); if ((X-X2) > 0) angle = atan((double)(Y2-Y)/(X-X2)) * 180.0/M_PI; else if ((X-X2) < 0) { if (Y <= Y2) angle = (atan((double)(Y2-Y)/(X-X2)) + M_PI) * 180.0/M_PI; else angle = (atan((double)(Y2-Y)/(X-X2)) - M_PI) * 180.0/M_PI; } else if ((Y-Y2) < 0) angle = 90.0; else if ((Y-Y2) > 0) angle = -90; else angle = 0; sprintf(statusMessage, "dist: %7.7g, angle: %7.7g", distance, angle); // remove the old line if (angleLine != 0) { // remove the last line parentWindow->make_current(); angleLine->undraw(); remove(angleLine); delete angleLine; angleLine = 0; } // actually draw a line angleLine = new imline(X2, Y2, X, Y, STYLE_XOR, 0x1b2dc3a4); add(angleLine); // display the profile if (profilePanel && profilePanel->visible()) { dbgprintf("Sending data to the profile panel\n"); int nb; double *red = 0, *green = 0, *blue = 0; theImage->getLineDataVectors(X2,Y2,X,Y,red,green,blue,nb); profilePanel->setData(red,green,blue,nb,X2,Y2,X,Y); profilePanel->redraw(); if (red != 0) delete[] red; if (green != 0) delete[] green; if (blue != 0) delete[] blue; } } statusLine->value((const char *)statusMessage); damage(1); // just redraw the children } if (selectBoxDefined && (nbFlBoxDamage == 0)) { x = Fl::event_x(); y = Fl::event_y(); if (x > visibleWidth() + Ox - 1) x = visibleWidth() + Ox - 1; if (y > visibleHeight() + Oy - 1) y = visibleHeight() + Oy - 1; selectBoxWidth = x - selectBoxX; selectBoxHeight = y - selectBoxY; // delete the old selectBox if (selectBox != 0) { parentWindow->make_current(); fl_overlay_clear(); } // create a new one if possible if ((selectBoxWidth > 0) && (selectBoxHeight > 0)) { selectBox = 1; parentWindow->make_current(); fl_overlay_rect(selectBoxX, selectBoxY, selectBoxWidth, selectBoxHeight); } } return; } void imageViewer::handleLeftButtonReleased() { // see discussion in handleLeftButtonDragged // about when this present routine can be called without // statusLine having been initialized... pointermode m = getpointermode(LEFT_BUTTON); if (statusLine) { // if (Fl::event_state(FL_SHIFT) || pointmode) { if ((m == IMV_POINTER_DELPT_MODE) || (m == IMV_POINTER_DELGRP_MODE) || (m == IMV_POINTER_ADDPT_MODE) || (m == IMV_POINTER_EDITPT_MODE) || (m == IMV_POINTER_DRAWPT_MODE)) { int x, y, X, Y, d; const unsigned char *p; x = Fl::event_x(); y = Fl::event_y(); // make sure we stay in the image if (x < Ox) x = Ox; if (y < Oy) y = Oy; if (x < Ox) x = Ox; if (x >= visibleWidth()+Ox) x = visibleWidth()+Ox -1; if (y < Oy) y = Oy; if (y >= visibleHeight()+Oy) y = visibleHeight()+Oy -1; X = xInImage(x); // convert local coordinates to image ones. Y = yInImage(y); d = imageObject->d(); // serious change in FLTK-1.1.x p = (unsigned char *)(imageObject->data()[0] + d *(X + Y * imageObject->w())); //if (Fl::event_state(FL_ALT)) { // delete point if (m == IMV_POINTER_DELPT_MODE) { PtFileMngr->rmPoint(X,Y); //} else if (Fl::event_state(FL_CTRL)) { // annotate point } else if (m == IMV_POINTER_DELGRP_MODE) { PtFileMngr->rmPointGroup(X,Y); } else if (m == IMV_POINTER_EDITPT_MODE) { if (PtFileMngr->isValidPoint(X,Y)) showAnnotatePanel(X,Y); // point annotation } else if (m == IMV_POINTER_DRAWPT_MODE) { dbgprintf("Break point entered\n"); parentWindow->make_current(); // we are drawing! assert(currentPtColour_ < MAX_FL_COLOURS); // blue is for a start PtFileMngr->addBreak(true, STYLE_FILLED_COLOUR, fl_closest_index(currentPtColour_++)); // increment colour currentPtColour_ %= MAX_FL_COLOURS; } else { // add point if (d == 3) { PtFileMngr->addPoint(X,Y,theImage->getCurrZpos(), *p, *(p+1), *(p+2), theImage->hasRawData()); // is there more data yet? } else { PtFileMngr->addPoint(X,Y,theImage->getCurrZpos(), *p, *p, *p, theImage->hasRawData()); // is there more data yet? } //if (debugIsOn) { // // draw a quick circle // parentWindow->make_current(); // fl_circle(x,y,3); //} } } if (lineProfileInProgress) { // remove the existing line if needed and wanted if (angleLine != 0 && !keepProfileLine) { // remove the last line parentWindow->make_current(); angleLine->undraw(); remove(angleLine); delete angleLine; angleLine = 0; } lineProfileInProgress=false; } // change the cursor back to the local default chg_cursor(MY_CURSOR_DEFAULT); // what do we need to redraw? if (statusLine->y() == Oy) damage(16); // top of the image else damage(8); // bottom of the image remove(statusLine); delete statusLine; statusLine = 0; } if (selectBoxDefined && selectBox) { int X,Y,W,H; parentWindow->make_current(); fl_overlay_clear(); selectBoxDefined = 0; selectBox = 0; // select points X = xInImage(selectBoxX); Y = yInImage(selectBoxY); W = wInImage(selectBoxWidth); H = hInImage(selectBoxHeight); if (Fl::event_state(FL_SHIFT)) { PtFileMngr->selectPoints(X,Y,W,H, PT_SELECT_RM); } else if (Fl::event_state(FL_CTRL)) { PtFileMngr->selectPoints(X,Y,W,H, PT_SELECT_INVERT); } else PtFileMngr->selectPoints(X,Y,W,H, PT_SELECT_ADD); damage(1); // redraw the children } return; } //////////////////////////////////// /// Middle button operations void imageViewer::handleMiddleButtonPushed() { int x, y; x = Fl::event_x(); y = Fl::event_y(); zoomBoxRatio = (double)visibleHeight()/visibleWidth(); zoomBoxX = x; zoomBoxY = y; zoomBoxDefined = 1; nbFlBoxDamage = 0; chg_cursor(MY_CURSOR_ZOOMBOX); return; } void imageViewer::handleMiddleButtonDragged() { int x, y; // like for handleLeftButtonDragged, it is possible to come // here without handleMiddleButtonPushed having been called... if (zoomBoxDefined && (nbFlBoxDamage == 0)) { x = Fl::event_x(); y = Fl::event_y(); if (x > visibleWidth() + Ox - 1) x = visibleWidth() + Ox - 1; if (y > visibleHeight() + Oy - 1) y = visibleHeight() + Oy - 1; zoomBoxWidth = x - zoomBoxX; zoomBoxHeight = y - zoomBoxY; // shift_down inverts the current state aspectConstrained = (fileprefs->mouseZoomType() == ZOOM_CONSTRAINED); if (Fl::event_state(FL_SHIFT)) aspectConstrained=!aspectConstrained; // ^ doesn't work for some reason dbgprintf("Aspect ratio is %s constrained\n", aspectConstrained ? "":"NOT"); if (aspectConstrained) { // revisit this to enforce the current aspect ratio zoomBoxWidth = trivmin(zoomBoxWidth, (int)(zoomBoxHeight / zoomBoxRatio + 0.5)); zoomBoxHeight = trivmin(zoomBoxHeight, (int)(zoomBoxWidth * zoomBoxRatio + 0.5)); } // delete the old zoomBox if need be if (zoomBox != 0) { parentWindow->make_current(); fl_overlay_clear(); } // create a new one if possible if ((zoomBoxWidth > 0 && zoomBoxHeight > 0)) { double xzoom, yzoom, zf; int bw, bh; double rw, rh; zoomBox = 1; parentWindow->make_current(); zoomDragInProgress = true; dragX = xInImage(zoomBoxX); dragY = yInImage(zoomBoxY); dbgprintf("DragX = %d, DragY = %d\n", dragX, dragY); /* CAREFUL: same formulae as in zoomToBox */ /* dragW = wInImage(zoomBoxWidth)+1; */ bw = wInImage(zoomBoxWidth)+1; bh = hInImage(zoomBoxHeight)+1; if (hscrollbar && hscrollbar->visible()) { xzoom = (double)visibleWidth()/bw; } else { rw = bw + ((double)VSLIDER_WIDTH*bw)/visibleWidth(); xzoom = (double)visibleWidth()/rw; } /* dragH = hInImage(zoomBoxHeight)+1; */ if (vscrollbar && vscrollbar->visible()) { yzoom = (double)visibleHeight()/(hInImage(zoomBoxHeight)+1); } else { rh = bh + ((double)HSLIDER_HEIGHT*bh)/visibleHeight(); yzoom = (double)visibleHeight()/rh; } dbgprintf("xzoom: %g, yzoom:%g\n", xzoom, yzoom); if (!aspectConstrained) { zf = trivmax(xzoom, yzoom); zf = trivmin(zf, (double)(appMaxWidth-Ox)/bw); zf = trivmin(zf, (double)(appMaxHeight-Oy)/bh); if (vscrollbar && vscrollbar->visible()) { dragW = (int)(visibleWidth()/xzoom + 0.5); } else { dragW = (int)((visibleWidth()-VSLIDER_WIDTH)/xzoom + 0.5); } if (hscrollbar && hscrollbar->visible()) { dragH = (int)(visibleHeight()/yzoom + 0.5); } else { dragH = (int)((visibleHeight()-HSLIDER_HEIGHT)/yzoom + 0.5); } #ifdef IMVIEW_USES_DBLBUF // using the window overlay feature now parentWindow->setZoomSelRect(xWtoW(zoomBoxX), yWtoW(zoomBoxY), (int)(dragW * zoomFactor()), // adjW(zoomBoxWidth), (int)(dragH * zoomFactor())); parentWindow->redraw_overlay(); #else fl_overlay_rect(xWtoW(zoomBoxX), yWtoW(zoomBoxY), (int)(dragW * zoomFactor()), // adjW(zoomBoxWidth), (int)(dragH * zoomFactor())); // adjH(zoomBoxHeight)); #endif } else { zf = trivmin(xzoom, yzoom); /* this is just too hard... */ if (vscrollbar && vscrollbar->visible()) { dragW = (int)(visibleWidth()/zf + 0.5); } else { dragW = (int)((visibleWidth()-VSLIDER_WIDTH)/zf + 0.5); } if (hscrollbar && hscrollbar->visible()) { dragH = (int)(visibleHeight()/zf + 0.5); } else { dragH = (int)((visibleHeight()-HSLIDER_HEIGHT)/zf + 0.5); } #ifdef IMVIEW_USES_DBLBUF // using the window overlay feature now parentWindow->setZoomSelRect(xWtoW(zoomBoxX), yWtoW(zoomBoxY), (int)(dragW * zoomFactor()), // adjW(zoomBoxWidth), (int)(dragH * zoomFactor())); parentWindow->redraw_overlay(); #else // this is the old handcrafted rectangle fl_overlay_rect(xWtoW(zoomBoxX), yWtoW(zoomBoxY), (int)(dragW * zoomFactor()), // adjW(zoomBoxWidth), (int)(dragH * zoomFactor())); // adjH(zoomBoxHeight)); #endif } if (imageInfoPanel) imageInfoPanel->update(); } } else if (nbFlBoxDamage > 1) { errprintf("FlBox damage = %d, how can this happen?\n", nbFlBoxDamage); } return; } void imageViewer::handleMiddleButtonReleased() { if (zoomBoxDefined && zoomBox) { #ifdef IMVIEW_USES_DBLBUF parentWindow->setZoomSelRect(0, 0, -1, // adjW(zoomBoxWidth), -1); parentWindow->redraw_overlay(); #else parentWindow->make_current(); fl_overlay_clear(); #endif zoomBoxDefined = 0; zoomBox = 0; zoomDragInProgress = false; // now zooms: zoomToBox(xInImage(zoomBoxX), yInImage(zoomBoxY), wInImage(zoomBoxWidth)+1, hInImage(zoomBoxHeight)+1); } // in any case, back to local default chg_cursor(MY_CURSOR_DEFAULT); return; } void imageViewer::handleRightButtonReleased() { pointermode m = getpointermode(RIGHT_BUTTON); if (Fl::event_state(FL_SHIFT) || (m == IMV_POINTER_ADDPT_MODE)) { dbgprintf("Break point entered\n"); parentWindow->make_current(); // we are drawing! PtFileMngr->addBreak(); } else { // unzoom back to normal zoomFactor(defaultZoomFactor_, true, true); // maybe redraw } return; } void imageViewer::deletePoint(int atX, int atY) { delPtX = atX; delPtY = atY; dbgprintf("About to delete point at (%d,%d)\n", atX, atY); nbPointDamage++; if (nbPointDamage <= 1) damage(4); // minimal damage else { damage(32); // calling the big boy to clear the crap } return; } void imageViewer::create_hscrollbar_win_fit_img() { dbgprintf("Horizontal scrollbar created\n"); hscrollbar = new Fl_Scrollbar(x(), y() + h() - HSLIDER_HEIGHT, w() - VSLIDER_WIDTH, HSLIDER_HEIGHT, 0); hscrollbar->type(FL_HORIZONTAL); hscrollbar->callback(hscrollbar_callback); hscrollbar->box(FL_DOWN_BOX); add(hscrollbar); scrollbartype_ = IMV_DISPLAY_WINDOW_FIT_IMG; return; } void imageViewer::create_vscrollbar_win_fit_img() { dbgprintf("Vertical scrollbar created\n"); vscrollbar = new Fl_Scrollbar(x() + w() - VSLIDER_WIDTH, y(), VSLIDER_WIDTH, h()- HSLIDER_HEIGHT, 0); vscrollbar->type(FL_VERTICAL); vscrollbar->callback(vscrollbar_callback); vscrollbar->box(FL_DOWN_BOX); add(vscrollbar); scrollbartype_ = IMV_DISPLAY_WINDOW_FIT_IMG; return; } void imageViewer::create_hscrollbar_decoupled() { dbgprintf("Horizontal decoupled scrollbar created\n"); hscrollbar = new Fl_Scrollbar(x(), y() + h() - HSLIDER_HEIGHT, w() - VSLIDER_WIDTH, HSLIDER_HEIGHT, 0); hscrollbar->type(FL_HORIZONTAL); hscrollbar->callback(hscrollbar_callback); hscrollbar->box(FL_DOWN_BOX); add(hscrollbar); scrollbartype_ = IMV_DISPLAY_DECOUPLE_WIN_IMG; return; } void imageViewer::create_vscrollbar_decoupled() { dbgprintf("Vertical decoupled scrollbar created\n"); vscrollbar = new Fl_Scrollbar(x() + w() - VSLIDER_WIDTH, y(), VSLIDER_WIDTH, h()- HSLIDER_HEIGHT, 0); vscrollbar->type(FL_VERTICAL); vscrollbar->callback(vscrollbar_callback); vscrollbar->box(FL_DOWN_BOX); add(vscrollbar); scrollbartype_ = IMV_DISPLAY_DECOUPLE_WIN_IMG; return; } void imageViewer::destroy_scrollbars() { // incorrect kind of scrollbar was used.. if (hscrollbar) { dbgprintf("Destroying horizontal scrollbar\n"); remove(hscrollbar); delete(hscrollbar); hscrollbar=0; } if (vscrollbar) { dbgprintf("Destroying vertical scrollbar\n"); remove(vscrollbar); delete(vscrollbar); vscrollbar = 0; } return; } // re-coloring doesn't work on all X displays. Abandon idea void imageViewer::chg_cursor(Fl_Cursor newCursor, bool invert) { static Fl_Cursor currentCursor = FL_CURSOR_NONE; if (parentWindow && (newCursor != currentCursor)) { parentWindow->make_current(); if (invert) { dbgprintf("INverted cursor\n"); fl_cursor(newCursor, FL_WHITE, FL_BLACK); } else { fl_cursor(newCursor, FL_BLACK, FL_WHITE); } currentCursor = newCursor; // changing cursor flashes the screen on some displays } } int imageViewer::visibleWidth(void) { int vw = w(); if (vscrollbar && vscrollbar->visible()) { vw -= VSLIDER_WIDTH; } vw = trivmax(vw, 1); // vw must always be > 0 return vw; } int imageViewer::visibleHeight(void) { int vh = h(); if (hscrollbar && hscrollbar->visible()) { vh -= HSLIDER_HEIGHT; } vh = trivmax(vh, 1); return vh; } inline void imageViewer::zapImageObject(void) { if (imageObject) { freeOffScreenPixmap(imageObject); delete imageObject; imageObject = 0; } } void imageViewer::showAnnotatePanel(int X, int Y) { dbgprintf("Annotate panel\n"); if (annotatePointPanel == 0) { dbgprintf("Panel created\n"); annotatePointPanel = new annotatept; annotatept_panel(*annotatePointPanel); // standard init annotatePointPanel->setDefaults(); } // show the panel annotatePointPanel->setXY(X,Y); // get the annotation stuff from the nearest point annotatePointPanel->getPointParams(); // finally show the panel annotatePointPanel->show(); // the return callback from the panel will set the annotation. return; } pointermode imageViewer::getpointermode(int button) { pointermode retval = pmode_; if (pmode_ == IMV_POINTER_ZOOM_MODE) { // lots of modifiers there if (button == LEFT_BUTTON) { if (Fl::event_state(FL_SHIFT) || pointmode) if (Fl::event_state(FL_ALT)) retval = IMV_POINTER_DELPT_MODE; else if (Fl::event_state(FL_CTRL)) retval = IMV_POINTER_EDITPT_MODE; else retval = IMV_POINTER_ADDPT_MODE; else if (Fl::event_state(FL_CTRL)) retval = IMV_POINTER_MEASURE_MODE; } } return retval; } imview-1.1.9c/imageViewer.hxx0000644000076500007650000002563010632004152016767 0ustar talbottalbot00000000000000/* * $Id: imageViewer.hxx,v 4.7 2007/06/07 13:30:18 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The ImageViewer Class * Basically an image class that can be opened, closed, and saved * to-from files. * * Hugues Talbot 27 Oct 1997 * * This is my first attempt at a serious derivation. Don't laugh at * the code... * *-----------------------------------------------------------------------*/ #ifndef IMAGEVIEWER_H #define IMAGEVIEWER_H #ifndef Fl_Object_H #include #endif #include #include #include #include #include #include #include #include #include #include #include "imlines.hxx" #include "imviewWindow.hxx" // some useful defines #define VSLIDER_WIDTH 15 #define HSLIDER_HEIGHT 15 #define STATUS_HEIGHT 21 #define STATUS_FONT 8 #define STATUS_SIZE 14 #define LEFT_BUTTON 1 #define MIDDLE_BUTTON 2 #define RIGHT_BUTTON 3 #ifdef WIN32 # define MY_CURSOR_RIGHTARROW FL_CURSOR_DEFAULT// used to be 2 # define MY_CURSOR_ZOOMBOX FL_CURSOR_NWSE # define MY_CURSOR_CROSS FL_CURSOR_CROSS # define MY_CURSOR_DOT FL_CURSOR_HAND # define MY_CURSOR_KILL FL_CURSOR_HELP # define MY_CURSOR_LHAND FL_CURSOR_HAND # define MY_CURSOR_RHAND FL_CURSOR_HAND # define MY_CURSOR_MEASURE FL_CURSOR_MOVE # define MY_CURSOR_DRAW FL_CURSOR_ARROW # define MY_CURSOR_SELECT FL_CURSOR_NWSE # define MY_CURSOR_DEFAULT FL_CURSOR_DEFAULT # define MY_CURSOR_INSERT FL_CURSOR_INSERT #else /* the cursors with numerical values are not in Enumeration.H */ # define MY_CURSOR_RIGHTARROW FL_DEFAULT_CURSOR// used to be 2 # define MY_CURSOR_ZOOMBOX FL_CURSOR_SE # define MY_CURSOR_CROSS (Fl_Cursor)18 # define MY_CURSOR_DOT (Fl_Cursor)25 # define MY_CURSOR_KILL (Fl_Cursor)45 # define MY_CURSOR_LHAND (Fl_Cursor)30 # define MY_CURSOR_RHAND FL_CURSOR_HAND # define MY_CURSOR_MEASURE (Fl_Cursor)5 # define MY_CURSOR_DRAW (Fl_Cursor)44 # define MY_CURSOR_SELECT (Fl_Cursor)40 # define MY_CURSOR_DEFAULT (Fl_Cursor)2 // this is the default for this application # define MY_CURSOR_INSERT FL_CURSOR_INSERT #endif // pointer (mouse) mode typedef enum { IMV_POINTER_ZOOM_MODE = 0, IMV_POINTER_SELECT_MODE, IMV_POINTER_ADDPT_MODE, IMV_POINTER_DRAWPT_MODE, IMV_POINTER_DELPT_MODE, IMV_POINTER_DELGRP_MODE, IMV_POINTER_EDITPT_MODE, IMV_POINTER_MEASURE_MODE } pointermode; // display mode typedef enum { IMV_DISPLAY_WINDOW_FIT_IMG = 0, // the window follows the image size if zoomed in an out (within screen limits) IMV_DISPLAY_IMG_FIT_WINDOW, // the image is made to always fit the window. Arbitrary aspect ratios are fine, zoom is disabled IMV_DISPLAY_DECOUPLE_WIN_IMG // window and image are decoupled. Image is centered in window if smaller. } displaymode; class imageViewer: public Fl_Group { public: imageViewer(int x, int y, int w, int h, const char *label=0); ~imageViewer(); void setImageIO(imageIO *IO) {theImage = IO;} void displayCurrentImage(void); int close(void); // resize handling void resetDisplay(bool doRedraw=true, bool forward=true); // defined in keyboard.cxx bool resize(void); void resize(int newx, int newy, int neww, int newz); void vposition(int newy); // changes the position of the image with respect to the window. void hposition(int newx); void pan(int newx, int newy); double vposition(void) {return vposition_;} double hposition(void) {return hposition_;} // handles the zoom factor double zoomFactor(void) { return (imageZoomFactor_); } double xZoomFactor(void) { return xZoomFactor_;} double yZoomFactor(void) { return yZoomFactor_;} double zoomFactor(double f, bool doRedraw=true, bool forward=true); double setDefaultZoomFactor(double f, bool forward=true); double getDefaultZoomFactor(void) {return defaultZoomFactor_;} double getMinZoomFactor(void) {return minZoomFactor_;} void getCurrentBox(int &bx, int &by, int &bw, int &bh); double applyDefaultZoomFactor(void) {return zoomFactor(defaultZoomFactor_);} double applyMaxZoomFactor(bool useSmallerOne=true); double zoomToBox(int bx, int by, int bw, int bh, bool forward=true); // a handy couple of functions int currentImageWidth(void); int currentImageHeight(void); int currentImageDepth(void) {return (theImage->imageDepth());} int dataWidth(void) {return theImage->imageWidth();} int dataHeight(void) {return theImage->imageHeight();} // this HAS to be implemented void draw(); // event handling method int handle(int event); // these need to be public int yOnWindow(double Y); int xOnWindow(double X); int visibleWidth(); // returns the visible width of the object int visibleHeight(); // same for height // point processing void setPointMode(bool m) {pointmode = m;} void deletePoint(int x, int y); void setPointAnnotation(void); void setPtColourIndex(int i) {currentPtColour_ = i;} // preference void drawSmooth(int x) {drawSmooth_ = x;} int drawSmooth(void) {return drawSmooth_;} // useful for gamma handling void redraw_image(); // line profile stuff void keepLine() { keepProfileLine = true;} void removeLine(); void setpointermode(pointermode m) {pmode_ = m;} void setdisplaymode(displaymode m); // a bit too complex to put here displaymode getdisplaymode(void) {return dmode_;} // getpointermode is private void allowSizeConstraints(bool tf); // fullscreen bool toggle_fullscreen(void); // toggle on-and-off, returns status private: // private variables Fl_RGB_Image *imageObject; imageIO *theImage; Fl_Scrollbar *hscrollbar, *vscrollbar; imviewWindow *parentWindow; Fl_Output *statusLine; // normally invisible status line, but can pop up sometimes imline *angleLine; double zoomBoxRatio; int zoomBox, selectBox; // We use this box to indicate where to zoom char statusMessage[100]; // status message int drawSmooth_; // should we smooth when zooming in or out? int Ox, Oy; // origins of the image viewer double vposition_, hposition_; // position of the window w. r. to the image int objectWidth, objectHeight; int zoomBoxDefined, zoomBoxX, zoomBoxY, zoomBoxWidth, zoomBoxHeight; int selectBoxDefined, selectBoxX, selectBoxY, selectBoxWidth, selectBoxHeight; int oldBoxX, oldBoxY, oldBoxW, oldBoxH; double imageZoomFactor_, minZoomFactor_, defaultZoomFactor_, xZoomFactor_, yZoomFactor_; int originalWidth, originalHeight; // used when no image is visible int nbFlBoxDamage, nbPointDamage; // trivial semaphores int delPtX, delPtY; // coordinates of the next point to be deleted int dragX, dragY, dragW, dragH; int angleStartX, angleStartY; bool pointmode, zoomDragInProgress, aspectConstrained, sizeConstrained; bool resizeInProgress; bool lineProfileInProgress, keepProfileLine; pointermode pmode_; displaymode dmode_, scrollbartype_; int currentPtColour_; // colour of lines and points private: // private methods double computeMaxZoomFactor(bool usemin=true); // scrollbar stuff void create_hscrollbar_win_fit_img(); void create_vscrollbar_win_fit_img(); void create_hscrollbar_decoupled(); void create_vscrollbar_decoupled(); void destroy_scrollbars(); // sub-draw methods void drawScrollbars_decoupled(int imw, int imh, int vw, int vh); void drawImage_decoupled(int imw, int imh, int imd, bool redrawbk, bool smooth, int visibleW, int visibleH, int &d); void drawScrollbars_win_fit_img(int imw, int imh, int &vw, int &vh); void drawImage_win_fit_img(int imw, int imh, int imd, bool redrawbk, bool smooth, int visibleW, int visibleH, int &d); // these handles the size constraints bool sizeParent(int sizeX, int sizeY); void sizeConstraints(int minw, int minh); // this handles cursor changes void chg_cursor(Fl_Cursor newCursor, bool invert=false); // these functions transform coordinates from // the window referential to the image one, and // vice-versa. inline int xInImage(int x); inline int yInImage(int y); inline int wInImage(int w); inline int hInImage(int h); // adjustment functions inline int xWtoW(int x); inline int yWtoW(int y); inline int adjW(int w); inline int adjH(int h); // keyboard handling int handleKeyboardEvent(void); // Button handling methods void handleLeftButtonPushed(); void handleLeftButtonDragged(); void handleLeftButtonReleased(); void handleMiddleButtonPushed(); void handleMiddleButtonDragged(); void handleMiddleButtonReleased(); void handleRightButtonReleased(); // imageObject handling inline void zapImageObject(void); // point annotation void showAnnotatePanel(int X, int Y); pointermode getpointermode(int button); // the mode is in fact computed }; #endif // IMAGEVIEWER_H imview-1.1.9c/imcfg.h.in0000644000076500007650000001200110720351523015626 0ustar talbottalbot00000000000000/* config.h.in. Generated automatically from configure.in by autoheader. */ /* Hacked by hand by Hugues Talbot 8 Aug 2000 */ /* Guards */ #ifndef CONFIG_H #define CONFIG_H /* these are my own! Hugues Talbot 7 Aug 2000 */ #if defined(WIN32) && !defined(__CYGWIN__) # define WIN32_NOTCYGWIN 1 #else # undef WIN32_NOTCYGWIN #endif /* imview version */ #define IMVIEW_MAJOR 0 #define IMVIEW_MINOR 0 #define IMVIEW_MICRO 0 /* Define if using double-buffering */ #undef IMVIEW_USES_DBLBUF /* Define if you have the Magick library (-lMagick). */ #undef HAVE_MAGICK /* Define if if ImageMagick uses the new exception structure */ #undef MAGICK_USES_REASON /* Define if if ImageMagick uses InitializeMagick */ #undef MAGICK_USES_INIT /* Define if ImageMagick requires extra reference to exceptions in arguments */ #undef MAGICK_NEEDS_MORE_EXCEPTION /* define is accept() uses socklen_t */ #undef ACCEPT_USES_SOCKLEN_T /* define if you have libz, the compression library */ #undef HAVE_LIBZ /* Define if you have the jpeg library (-ljpeg). */ #undef HAVE_JPEG /* define if you have the png library (-lpng) */ #undef HAVE_PNG /* Define if you have the pthread library (-lpthread). */ #undef HAVE_PTHREADS /* Define if we only really have DEC threads, precursors to pthreads */ #undef HAVE_DECTHREADS /* Define if you have the tiff library (-ltiff). */ #undef HAVE_TIFF /* Define if PINK extensions are on */ #undef HAVE_PINK_PGM_EXTENSIONS /* Define if you want to use the Native file browser (recommended) */ #undef HAVE_NATIVE_CHOOSER /* define if you have the Unix SYSV IPC */ #undef HAVE_SYSV_IPC /* define if you have the Unix POSIX IPC */ #undef HAVE_POSIX_IPC /* when using POSIX IPC, can we specify a path under /tmp or is it implicit? */ #undef POSIX_IPC_PREFIX /* Define if you have the GL library (-lGL). */ #undef HAVE_GL /* define if your multiple-screen system supports xinerama -- a way to merge screens seamlessly */ #undef HAVE_XINERAMA /* stupid C++ ANSI compatibility issues */ /* define if your compiler supports class member templates */ #undef HAVE_MEMBER_TEMPLATES /* define if one can have function template without a template argument */ #undef HAVE_TEMPLATE_KEYWORD_QUALIFIER /* define if the compiler supports templates as template arguments */ #undef HAVE_TEMPLATES_AS_TEMPLATE_ARGUMENTS /* define if the compiler supports default template parameters */ #undef HAVE_DEFAULT_TEMPLATE_PARAMETERS /* define if the compiler knows about standard char traits */ #undef HAVE_STANDARD_CHAR_TRAITS /* define if your compiler rejects array casts in templates */ #undef HAVE_TEMPLATE_CAST_ARRAY /* CAREFUL, for these the *VALUE* is used, not the definition! */ /* define if you have scandir */ #define HAVE_SCANDIR 0 /* define if you have snprintf */ #define HAVE_SNPRINTF 0 /* define if you have vsnprintf */ #define HAVE_VSNPRINTF 0 /* sleep functions */ #undef HAVE_USLEEP #undef HAVE_NANOSLEEP /* Define the installation path */ #undef PrefPath /* these were generated by autoheader (I think...) */ /* Define to empty if the keyword does not work. */ #undef const /* Define as the return type of signal handlers (int or void). */ #undef RETSIGTYPE /* Define if the setvbuf function takes the buffering type as its second argument and the buffer pointer as the third, as on System V before release 3. */ #undef SETVBUF_REVERSED /* Define to `unsigned' if doesn't define. */ #undef size_t /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define if your declares struct tm. */ #undef TM_IN_SYS_TIME /* Define if you have the getcwd function. */ #undef HAVE_GETCWD /* Define if you have the select function. */ #undef HAVE_SELECT /* Define if you have the socket function. */ #undef HAVE_SOCKET /* Define if you have the strdup function. */ #undef HAVE_STRDUP /* Define if you have the strerror function. */ #undef HAVE_STRERROR /* Define if you have the strstr function. */ #undef HAVE_STRSTR /* Define if you have the strtol function. */ #undef HAVE_STRTOL /* Define if you have the uname function. */ #undef HAVE_UNAME /* Define if you have the header file. */ #undef HAVE_DIRENT_H /* Define if you have the header file. */ #undef HAVE_FCNTL_H /* Define if you have the header file. */ #undef HAVE_LIMITS_H /* Define if you have the header file. */ #undef HAVE_MALLOC_H /* Define if you have the header file. */ #undef HAVE_NDIR_H /* Define if you have the header file. */ #undef HAVE_SYS_DIR_H /* Define if you have the header file. */ #undef HAVE_SYS_NDIR_H /* Define if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define if you have the header file. */ #undef HAVE_UNISTD_H /* Define if you don't have vprintf but do have _doprnt. */ #undef HAVE_DOPRNT /* Define if you have the vprintf function. */ #undef HAVE_VPRINTF #endif // CONFIG_H imview-1.1.9c/imdebug.cxx0000644000076500007650000002536110025524234016137 0ustar talbottalbot00000000000000/* * $Id: imdebug.cxx,v 4.1 2004/03/16 07:11:24 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * This file contains debugging code. * Essentially a trivial replacement for printf that will actually output * messages to the standard output only if a global debugging variable is * set to 1. * * Hugues Talbot 5 Jan 1998 * *-----------------------------------------------------------------------*/ #include #include #include #include #include #include #include #include "imview.hxx" #include "StatusBox.hxx" #ifdef HAVE_PTHREADS # include "server/semaphore.hxx" #endif #include "machine.hxx" #include "imunistd.h" extern int debugIsOn; extern int stopDebug; extern int serverDebug; extern Semaphore access_debug, access_error; #define BUFSIZE 1000 static FILE *outfile = 0; // these debugging routines are trickier than it seems // Let's explain the context: under Unix there is always // a console available (where to print messages, etc). Under // win32 this is not necessarily the case, hence the need for // a GUI solution, provided by the StatusBox. This is nice, but // now observe the IM_STATUS message. This brings up a nice window // the first time it is called, and in doing so (a show()), further // debugging messages spring forth. However the IM_STATUS is within // the protected area, and therefore a deadlock ensues! This seems // to occur _only_ under windows, but the problem is genuine. // But the GUI is precisely what the semaphores are there to protect, // so now, while in the protected area, further messages are ignored // debugIsOn is set to false. We will almost certainly lose some // debugging messages, but that can't be helped. int dbgprintf(const char * msg,...) { char strarg[BUFSIZE+1]; char mess[BUFSIZE+24]; int ret = 0, msglen; va_list args; static bool overflow = false; if (debugIsOn && (msg[0] != '\0')) { semaphore_down(&access_debug); overflow = true; debugIsOn = 0; // silence all messages im_va_start(args,msg); msglen = strlen(msg); assert(msglen > 0); // I have seen this happen if (msg[msglen-1] == '\n') { snprintf(strarg, BUFSIZE, DEBUGPROMPT "%s", msg); } // default WIN32 printf is not that good. // neither is the FLTK-replacement for (v)snprintf. #if defined(WIN32_NOTCYGWIN) || (HAVE_SNPRINTF == 0) char newmess[BUFSIZE]; strncpy(newmess,msg, BUFSIZE); newmess[BUFSIZE-1] = '\0'; msglen = trivmin(BUFSIZE-1, msglen); if (newmess[msglen-1] == '\a') { newmess[msglen-1] = '\0'; // shorten the string snprintf(strarg, BUFSIZE, DEBUGPROMPT "%s ", newmess); // FLTK's replacement will cope with this } else if (newmess[msglen-1] == '\b') { newmess[msglen-1] = '\0'; // shorten the string snprintf(strarg, BUFSIZE, "%s\n", newmess); // FLTK's replacement will cope with this } #else else if (msg[msglen-1] == '\a') { snprintf(strarg, BUFSIZE, DEBUGPROMPT "%.*s ",msglen-1, msg); } else if (msg[msglen-1] == '\b') { snprintf(strarg, BUFSIZE, "%.*s\n", msglen-1, msg); } #endif else { snprintf(strarg, BUFSIZE, "%s", msg); } //ret = vfprintf(stderr,strarg,args); ret = vsnprintf(mess, BUFSIZE+24, strarg, args); if (outfile == 0) { #ifdef WIN32_NOTCYGWIN outfile = fopen("c:/temp/imbugs.txt", "w"); #else outfile = fopen("/tmp/imbugs.txt", "w"); #endif } if (outfile != 0) { fprintf(outfile, mess); fflush(outfile); /* slow, but WHO CARES!! */ } IM_STATUS(mess); va_end(args); debugIsOn = 1; // enable messages again overflow = false; semaphore_up(&access_debug); if (stopDebug) { getchar(); } } else if (overflow) { // simply printf the message, this is debugging the debugging process... // we are assuming that printf is thread-safe. im_va_start(args,msg); msglen = strlen(msg); if ((msg[msglen-1] == '\n') || (msg[msglen-1] == '\a')) { snprintf(strarg, BUFSIZE, "lost message: %s", msg); } else if (msg[msglen-1] == '\b') { snprintf(strarg, BUFSIZE, "%s\n", msg); } vprintf(strarg, args); va_end(args); // we are only doing it for dbgprintf at this stage to get a feel of how much is lost... } return ret; } /* same thing, except it doesn't stop for char input, and prints a slightly different message */ int srv_dbgprintf(const char * msg,...) { char strarg[BUFSIZE]; char mess[BUFSIZE+24]; int ret = 0, msglen; va_list args; // if (debugIsOn) { // im_va_start(args, msg); // vfprintf(stderr, msg, args); // return 0; // } if (debugIsOn) { semaphore_down(&access_debug); debugIsOn = 0; // ignore further messages, ha. im_va_start(args,msg); msglen = strlen(msg); if (msg[msglen-1] == '\n') { snprintf(strarg, BUFSIZE, SRVDBGPRMPT "%s", msg); } #ifdef WIN32_NOTCYGWIN // far messier char newmess[BUFSIZE]; strncpy(newmess,msg, BUFSIZE); newmess[BUFSIZE-1] = '\0'; msglen = trivmin(BUFSIZE-1, msglen); if (newmess[msglen-1] == '\a') { newmess[msglen-1] = '\0'; // shorten the string snprintf(strarg, BUFSIZE, SRVDBGPRMPT "%s ", newmess); } else if (newmess[msglen-1] == '\b') { newmess[msglen-1] = '\0'; // shorten the string snprintf(strarg, BUFSIZE, "%s\n", newmess); } #else else if (msg[msglen-1] == '\a') { snprintf(strarg, BUFSIZE, SRVDBGPRMPT "%.*s ",msglen-1, msg); } else if (msg[msglen-1] == '\b') { snprintf(strarg, BUFSIZE, "%.*s\n", msglen-1, msg); } #endif else { snprintf(strarg, BUFSIZE, "%s", msg); } //ret = vfprintf(stderr,strarg,args); ret = vsnprintf(mess, BUFSIZE+24, strarg, args); if (outfile == 0) { #ifdef WIN32_NOTCYGWIN outfile = fopen("c:/temp/imbugs.txt", "w"); #else outfile = fopen("/tmp/imbugs.txt", "w"); #endif } if (outfile != 0) { fprintf(outfile, mess); fflush(outfile); /* slow, but WHO CARES!! */ } IM_STATUS(mess); va_end(args); debugIsOn = 1; semaphore_up(&access_debug); } return ret; } /* same thing, except it doesn't stop for char input, and prints a slightly different message */ int srv_internal_dbgprintf(const char * msg,...) { char strarg[BUFSIZE]; char mess[BUFSIZE+24]; int ret = 0, msglen; va_list args; if (serverDebug) { semaphore_down(&access_debug); serverDebug = 0; // ignore further messages, ha! im_va_start(args,msg); msglen = strlen(msg); if (msg[msglen-1] == '\n') { snprintf(strarg, BUFSIZE, SRVIDBGPRMPT "%s", msg); } #ifdef WIN32_NOTCYGWIN char newmess[BUFSIZE]; strncpy(newmess,msg, BUFSIZE); newmess[BUFSIZE-1] = '\0'; msglen = trivmin(BUFSIZE-1, msglen); if (newmess[msglen-1] == '\a') { newmess[msglen-1] = '\0'; // shorten the string snprintf(strarg, BUFSIZE, SRVIDBGPRMPT "%s ", newmess); } else if (newmess[msglen-1] == '\b') { newmess[msglen-1] = '\0'; // shorten the string snprintf(strarg, BUFSIZE, "%s\n", newmess); } #else else if (msg[msglen-1] == '\a') { snprintf(strarg, BUFSIZE, SRVIDBGPRMPT "%.*s ",msglen-1, msg); } else if (msg[msglen-1] == '\b') { snprintf(strarg, BUFSIZE, "%.*s\n", msglen-1, msg); } #endif else { snprintf(strarg, BUFSIZE, "%s", msg); } //ret = vfprintf(stderr,strarg,args); ret = vsnprintf(mess, BUFSIZE+24, strarg, args); IM_STATUS(mess); va_end(args); serverDebug = 1; semaphore_up(&access_debug); } return ret; } /* protected printf for the server */ int srv_printf(const char * msg,...) { int ret = 0; va_list args; semaphore_down(&access_debug); im_va_start(args,msg); ret = vprintf(msg,args); va_end(args); fflush(stdout); semaphore_up(&access_debug); return ret; } // this will actually print an error on the standard output stream // as well as on the error console int stderrprintf(const char * msg,...) { char strarg[BUFSIZE]; char mess[BUFSIZE+24]; int ret = 0; va_list args; semaphore_down(&access_error); im_va_start(args,msg); snprintf(strarg, BUFSIZE, ERRORPROMPT "%s", msg); //ret = vfprintf(stderr,strarg,args); ret = vsnprintf(mess, BUFSIZE+24, strarg, args); IM_ERROR(mess); // on the error/warning console fprintf(stderr, mess); // on the std error stream va_end(args); semaphore_up(&access_error); return ret; } // This will pop up an error dialog int errprintf(const char * msg,...) { char strarg[BUFSIZE]; int ret = 0; va_list args; semaphore_down(&access_error); im_va_start(args,msg); ret = vsnprintf(strarg, BUFSIZE, msg,args); va_end(args); fl_alert(strarg); // this can block for quite a long time! semaphore_up(&access_error); return ret; } // This will show up in the status box int warnprintf(const char * msg,...) { char strarg[BUFSIZE]; char mess[BUFSIZE+24]; int i, j, ret = 0; va_list args; semaphore_down(&access_error); im_va_start(args,msg); // separate the lines IM_WARNING("Warning:\n"); vsnprintf(strarg, BUFSIZE, msg, args); for (i=0, j= 0; ((i < BUFSIZE) && (strarg[i] != '\0')); i++, j++) { mess[j] = strarg[i]; if (strarg[i] == '\n') { mess[j+1] = '\0'; // OK due to +24 IM_WARNING(mess); j = -1; // j++ gets executed } } IM_WARNING("\n"); va_end(args); semaphore_up(&access_error); return ret; } imview-1.1.9c/imDrawPoint.cxx0000644000076500007650000000426110060025161016746 0ustar talbottalbot00000000000000/* * $Id: imDrawPoint.cxx,v 4.2 2004/06/04 07:53:21 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Used to draw points using X * * Bill forgot to do those. * * Hugues Talbot 7 Apr 1998 * * *-----------------------------------------------------------------------*/ #include #include #include // draws one point using the current colour void im_point(int x, int y) { #ifdef WIN32 SetPixel(fl_gc, x, y, fl_RGB()); #elif defined(MACOSX_CARBON) MoveTo(x, y); Line(0, 0); #else XDrawPoint(fl_display, fl_window, fl_gc, x, y); #endif } imview-1.1.9c/imDrawPoint.hxx0000644000076500007650000000354707653236462017007 0ustar talbottalbot00000000000000/* * $Id: imDrawPoint.hxx,v 4.0 2003/04/28 14:39:46 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Simplissime functions here * * Hugues Talbot 7 Apr 1998 * *-----------------------------------------------------------------------*/ void im_point(int x, int y); imview-1.1.9c/imlines.cxx0000644000076500007650000002143110066236730016163 0ustar talbottalbot00000000000000/* * $Id: imlines.cxx,v 4.3 2004/06/23 08:22:48 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * imlines.C * * This file contains code to draw line objects that remember what * was under them when they first got drawn. Not such an easy matter... * * Hugues Talbot 4 Apr 1998 * *-----------------------------------------------------------------------*/ #include "imview.hxx" #include "imlines.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "imDrawPoint.hxx" extern imageViewer *mainViewer; extern imageIO *IOBlackBox; // default constructor imline::imline(void) : Fl_Object(0,0,0,0,0) { firstdrawn_ = true; xorval_ = DEFAULT_XOR_FG; selected_ = false; linecolour_ = FL_WHITE; } // normal destructor // erase line imline::~imline(void) { dbgprintf("imline destructor called\n"); // is this really needed? //undraw(); } // copy constructor imline::imline(const imline &l) : Fl_Object(l.x1_, l.y1_, abs(l.x2_-l.x1_), abs(l.y2_-l.y1_), 0) { x1_ = l.x1_; x2_ = l.x2_; y1_ = l.y1_; y2_ = l.y2_; style_ = l.style_; firstdrawn_ = l.firstdrawn_; xorval_ = l.xorval_; selected_ = l.selected_; linecolour_ = l.linecolour_; // what about the pointqueue? // at this point it is normally empty: no need to copy it... return; } // a real line imline::imline(int x1, int y1, int x2, int y2, linestyle style, int xorval, Fl_Color linecolour) : Fl_Object(x1, y1, abs(x2-x1+1), abs(y2-y1+1), 0) { x1_ = x1; y1_ = y1; x2_ = x2; y2_ = y2; style_ = style; firstdrawn_ = true; xorval_ = xorval; selected_ = false; linecolour_ = linecolour; // sanity check if (x1_ < 0) x1_ = 0; if (x1_ >= IOBlackBox->imageWidth()) x1_ = IOBlackBox->imageWidth()-1; if (x2_ < 0) x2_ = 0; if (x2_ >= IOBlackBox->imageWidth()) x2_ = IOBlackBox->imageWidth()-1; if (y1_ < 0) y1_ = 0; if (y1_ >= IOBlackBox->imageHeight()) y1_ = IOBlackBox->imageHeight()-1; if (y2_ < 0) y2_ = 0; if (y2_ >= IOBlackBox->imageHeight()) y2_ = IOBlackBox->imageHeight()-1; dbgprintf("imline being defined\n"); if (style_ == STYLE_SPARSE_COLOUR) { // enqueue the image data int delta= bresinit(); impoint aPoint; do { // this is not too elegant here. We rely on the structure of imdata // Bjarne would scream! int id = IOBlackBox->imageDepth(); if (id != 1) { uchar *dp; dp = IOBlackBox->imageData() + id * delta; aPoint.R = *dp; aPoint.G = *(dp+1); aPoint.B = *(dp+2); } else { aPoint.R = aPoint.G = aPoint.B = *(IOBlackBox->imageData() + delta); } // enqueue this point pointqueue.push_back(aPoint); } while ((delta = bresgetnext()) > 0); } } // I wonder if this is the thing to do... void imline::draw_xorline(void) { int truex1 = mainViewer->xOnWindow(x1_); int truex2 = mainViewer->xOnWindow(x2_); int truey1 = mainViewer->yOnWindow(y1_); int truey2 = mainViewer->yOnWindow(y2_); #ifdef WIN32 int old = SetROP2(fl_gc, R2_NOT); fl_line(truex1, truey1, truex2, truey2); SetROP2(fl_gc, old); #elif defined(MACOSX_CARBON) PenMode( patXor ); fl_line(truex1, truey1, truex2, truey2); PenMode( patCopy ); #else XSetFunction(fl_display, fl_gc, GXxor); XSetForeground(fl_display, fl_gc, xorval_); XDrawLine(fl_display, fl_window, fl_gc, truex1, truey1, truex2, truey2); XSetFunction(fl_display, fl_gc, GXcopy); #endif } void imline::draw_filledLine(void) { int truex1 = mainViewer->xOnWindow(x1_); int truex2 = mainViewer->xOnWindow(x2_); int truey1 = mainViewer->yOnWindow(y1_); int truey2 = mainViewer->yOnWindow(y2_); fl_line(truex1, truey1, truex2, truey2); } void imline::draw_BWLine(void) { int truex1 = mainViewer->xOnWindow(x1_); int truex2 = mainViewer->xOnWindow(x2_); int truey1 = mainViewer->yOnWindow(y1_); int truey2 = mainViewer->yOnWindow(y2_); // at least one of the following lines should // always be visible no matter what the orientation // of the line. if (selected()) fl_color(FL_RED); else fl_color(FL_BLACK); fl_line(truex1+1, truey1+1, truex2+1, truey2+1); fl_line(truex1-1, truey1, truex2-1, truey2); // the white should be written after so that is // is also always visible if (selected()) fl_color(FL_GREEN); else fl_color(FL_WHITE); fl_line(truex1, truey1, truex2, truey2); } void imline::draw(void) { // define a clipping path fl_push_no_clip(); fl_clip(mainViewer->x(), mainViewer->y(), mainViewer->visibleWidth(), mainViewer->visibleHeight()); if (style_ == STYLE_SPARSE_COLOUR) { fl_color(linecolour_); // just draw all the points one by one int delta = bresinit(); do { im_point(mainViewer->xOnWindow(xpos_), mainViewer->yOnWindow(ypos_)); } while ((delta = bresgetnext()) > 0); //fl_pop_clip(); } else if (style_ == STYLE_XOR) { draw_xorline(); // between the known points. if (firstdrawn_) { firstdrawn_ = false; } else { draw_xorline(); // the first draw had erased the line... } } else if (style_ == STYLE_FILLED_COLOUR) { fl_color(linecolour_); draw_filledLine(); } else { draw_BWLine(); } // undefine the clipping path fl_pop_clip(); fl_pop_clip(); return; } void imline::undraw(void) { // check that there is something to erase if (!firstdrawn_) { fl_push_no_clip(); fl_clip(mainViewer->x(), mainViewer->y(), mainViewer->visibleWidth(), mainViewer->visibleHeight()); if (style_ == STYLE_SPARSE_COLOUR) { // empty the queue int delta = bresinit(); impoint aPoint; do { if (!pointqueue.empty()) { aPoint = pointqueue.front(); fl_color(aPoint.R, aPoint.G, aPoint.B); im_point(mainViewer->xOnWindow(xpos_), mainViewer->yOnWindow(ypos_)); // delete this point now. pointqueue.pop_front(); } } while ((delta = bresgetnext()) > 0); } else if (style_ == STYLE_XOR) { // this is simple: dbgprintf("Erasing line between (%d,%d) and (%d,%d)\n", x1_, y1_, x2_, y2_); draw_xorline(); // between the known points. } fl_pop_clip(); fl_pop_clip(); } return; } // the well-known Bresenham algorithm in a flexible incarnation int imline::bresinit(void) { sizex_ = IOBlackBox->imageWidth(); dx_ = x2_ - x1_; dy_ = y2_ - y1_; if (dx_ < 0) dx_ = -dx_; if (dy_ < 0) dy_ = -dy_; if (x2_ < x1_) incx_ = -1; else incx_ = 1; if (y2_ < y1_) incy_ = -1; else incy_ = 1; xpos_ = x1_; ypos_ = y1_; if (dx_ > dy_) { e_ = 2*dy_ - dx_; inc1_ = 2*(dy_-dx_); inc2_ = 2*dy_; } else { e_ = 2*dx_ - dy_; inc1_ = 2*(dx_-dy_); inc2_ = 2*dx_; } i_ = 0; return (xpos_ + ypos_ * sizex_); } int imline::bresgetnext(void) { if (dx_ > dy_) { if (++i_ >= dx_) return -1; else { if (e_ >= 0) { ypos_ += incy_; e_ += inc1_; } else e_ += inc2_; xpos_ += incx_; return (xpos_ + ypos_ * sizex_); } } else { if (++i_ >= dy_) return -1; else { if (e_ >= 0) { xpos_ += incx_; e_ += inc1_; } else e_ += inc2_; ypos_ += incy_; return (xpos_ + ypos_ * sizex_); } } } imview-1.1.9c/imlines.hxx0000644000076500007650000000774510066324230016175 0ustar talbottalbot00000000000000/* * $Id: imlines.hxx,v 4.2 2004/06/23 15:58:16 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * the imline class * * This class draws lines that can be easily erased on any background, * because they remember what was under them when they were first * drawn. * * Hugues Talbot 4 Apr 1998 * *-----------------------------------------------------------------------*/ #ifndef IMLINES_H #define IMLINES_H #ifndef Fl_Object_H #include #endif #include #include #include #include #include //#include // the STL queue container // cannot be used with gcc 2.7.2... #include #include "imnmspc.hxx" // contains namespace definition, if needed using std::list; #define DEFAULT_XOR_FG 0xffffeffe typedef enum { STYLE_XOR = 0, // do not use, causes havoc with redraws STYLE_SPARSE_COLOUR, STYLE_FILLED_COLOUR, STYLE_FILLED_BW, STYLE_MAX } linestyle; struct impoint { unsigned char R, G, B; // colour values }; class imline:public Fl_Object { public: imline(void); imline(const imline &l); // copy constructor... imline(int x1, int y1, int x2, int y2, linestyle style=STYLE_XOR, int xorval=DEFAULT_XOR_FG, Fl_Color linecolour=FL_WHITE); ~imline(void); void draw(void); void undraw(void); void drawnStatus(int newstatus) { firstdrawn_ = (newstatus == 0); } bool drawnStatus(void) { return firstdrawn_; } void defaultXorValue(int xorval) {xorval_ = xorval;} void getExtremities(int &x1, int &y1, int &x2, int &y2) { x1 = x1_; y1 = y1_; x2 = x2_; y2 = y2_; } void select(bool v=true) {selected_ = v;} bool selected(void) const {return selected_;} void setcolour(Fl_Color c) {linecolour_ = c;} private: int x1_, y1_, x2_, y2_; int style_; bool firstdrawn_; list pointqueue; // bresenham int incx_, incy_, inc1_, inc2_, sizex_; int dx_, dy_, i_, e_; int xpos_, ypos_; void draw_xorline(void); void draw_filledLine(void); void draw_BWLine(void); int bresinit(void); int bresgetnext(void); // xor function int xorval_ ; bool selected_; // joins two selected points // colour Fl_Color linecolour_; }; #endif // IMLINES_H imview-1.1.9c/imnmspc.hxx0000644000076500007650000000422407660203536016203 0ustar talbottalbot00000000000000/* * $Id: imnmspc.hxx,v 4.1 2003/05/13 14:55:26 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * For those compilers that require the namespace definition. * At the moment, this only counts MSVC++ * *-----------------------------------------------------------------------*/ #ifndef IMNAMESPACE_H #define IMNAMESPACE_H #if defined(_MSC_VER) // Visual C++ namespace std { // empty here } using namespace std; // suppress warning about identifier being too long to be debugged... #pragma warning(disable:4786) #endif // _MSC_VER #endif // IMNAMESPACE_H imview-1.1.9c/imtransform.cxx0000644000076500007650000004604410632004152017061 0ustar talbottalbot00000000000000/* * $Id: imtransform.cxx,v 4.3 2007/06/07 13:30:18 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * imtransform.C * * This file contains code to tranform the raw data in place * e.g: Rotations, shears, etc. * * This is a harder jobs than it seems, because we'll want to * remember the transforms. * * Hugues Talbot * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" // namespace etc #include #include #include #include #include "imunistd.h" #include "imview.hxx" #include "pointfile.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" extern pointfile *PtFileMngr; extern imageIO *IOBlackBox; // this method rotates the buffers by 90 to the right // must also work on 3d, multispectral images // Multicomponent or time series are handled somewhere else void imageIO::rotateRight() { if (imdata != 0) { // do we have an image? if (overlay) { // we still need to rotate the overlay if present unsigned char *p, *q; int x, y; dbgprintf("Rotating the overlay to the right\n"); p = overlay; if (ovlspp == 1) { q = new uchar[currImgWidth * currImgHeight]; for (y = 0 ; y < currImgHeight ; y++) for (x = 0 ; x < currImgWidth ; x++) q[(currImgHeight-y-1)+ currImgHeight*x] = *p++; } else { // ovlspp == 3 q = new uchar[3 * currImgWidth * currImgHeight]; for (y = 0 ; y < currImgHeight ; y++) for (x = 0 ; x < currImgWidth ; x++) { int idx = 3 * ((currImgHeight-y-1)+ currImgHeight*x); q[idx++] = *p++; q[idx++] = *p++; q[idx] = *p++; } } delete[] overlay; overlay = q; } if (currBuffp != 0) { // this is going to be much slower than below int sz=typeSize(currPixType); unsigned char *p, *q; int i, x, y, z, swp; void **ncurrBuffp = 0; if (dontFreeBuffers) { // its a lot more complicated ncurrBuffp = (void **)malloc(currImgNbSamples * sizeof(void*)); if (ncurrBuffp == 0) errprintf("This image can't be rotated due to memory problems\n"); } for (i = 0 ; i < currImgNbSamples ; i++) { p = (uchar *)currBuffp[i]; // the currBuffps are malloced, not newed if ((q = (uchar *) malloc(currImgWidth * currImgHeight * currImgThickness * sz *sizeof(char))) != NULL) { for (z = 0 ; z < currImgThickness ; z++) { for (y = 0 ; y < currImgHeight ; y++) { for (x = 0 ; x < currImgWidth ; x++) { memcpy(q + sz*(currImgHeight*currImgWidth*z + ((currImgHeight-y-1)+currImgHeight*x)), p, sz); p += sz; } } } if (!dontFreeBuffers) { free(currBuffp[i]); currBuffp[i] = q; } else { ncurrBuffp[i] = q; // save to a different buffer } } else { int l; errprintf("Not enough memory to rotate image\n"); if (dontFreeBuffers) { for (l = 0 ; l < i ; l++) free(ncurrBuffp[l]); free(ncurrBuffp); } // nothing further can be done for the other case // as the images have been rotated already. return; } } swp = currImgWidth; currImgWidth = currImgHeight; currImgHeight = swp; if (dontFreeBuffers) { currBuffp = ncurrBuffp; // don't worry, currBuffp is not lost. dontFreeBuffers = false; // these new buffers, we can free. } } else { // much simpler case unsigned char *p, *q; int x, y, c, swp; // we only need to rotate the display buffer. dbgprintf("2D CHAR image: only rotating the display buffer\n"); p = imdata; // on the other hand, imdata is newed, not malloced! q = new uchar[currImgWidth * currImgHeight * currImgNbSamples]; for (y = 0 ; y < currImgHeight ; y++) for (x = 0 ; x < currImgWidth ; x++) for (c = 0 ; c < currImgNbSamples ; c++) q[currImgNbSamples * ((currImgHeight-y-1)+currImgHeight*x) + c] = *p++; delete[] imdata; // this gets rid of the old buffer imdata = q; // swaps height and width of the buffer swp = currImgWidth; currImgWidth = currImgHeight; currImgHeight = swp; } // rotate the points, if any PtFileMngr->rotate90m(); } } // This method rotates the buffers by 90 to the left // must also work on 3d multispectral images. void imageIO::rotateLeft() { if (imdata != 0) { if (overlay) { unsigned char *p, *q; int x, y; dbgprintf("Rotating the overlay to the left\n"); p = overlay; if (ovlspp == 1) { q = new uchar[currImgWidth * currImgHeight]; for (y = 0 ; y < currImgHeight ; y++) for (x = 0 ; x < currImgWidth ; x++) q[y + currImgHeight*(currImgWidth-x-1)] = *p++; } else { //ovlspp == 3 q = new uchar[3 * currImgWidth * currImgHeight]; for (y = 0 ; y < currImgHeight ; y++) for (x = 0 ; x < currImgWidth ; x++) { int idx = 3 * (y + currImgHeight*(currImgWidth-x-1)); q[idx++] = *p++; q[idx++] = *p++; q[idx] = *p++; } } delete[] overlay; overlay = q; } if (currBuffp != 0) { // this is going to be much slower than below int sz=typeSize(currPixType); unsigned char *p, *q; int i, x, y, z, swp; void **ncurrBuffp = 0; if (dontFreeBuffers) { // its a lot more complicated ncurrBuffp = (void **)malloc(currImgNbSamples * sizeof(void*)); if (ncurrBuffp == 0) errprintf("This image can't be rotated due to memory problems\n"); } for (i = 0 ; i < currImgNbSamples ; i++) { p = (uchar *)currBuffp[i]; // the currBuffps are malloced, not newed if ((q = (uchar *) malloc(currImgWidth * currImgHeight * currImgThickness * sz)) != NULL) { for (z = 0 ; z < currImgThickness ; z++) { for (y = 0 ; y < currImgHeight ; y++) { for (x = 0 ; x < currImgWidth ; x++) { memcpy(q + sz*(currImgHeight*currImgWidth*z + (y + currImgHeight*(currImgWidth-x-1))), p, sz); p += sz; } } } if (!dontFreeBuffers) { free(currBuffp[i]); currBuffp[i] = q; } else { ncurrBuffp[i] = q; // save to a different buffer } } else { int l; errprintf("Not enough memory to rotate image\n"); if (dontFreeBuffers) { for (l = 0 ; l < i ; l++) free(ncurrBuffp[l]); free(ncurrBuffp); } // nothing further can be done for the other case // as the images have been rotated already. return; } } swp = currImgWidth; currImgWidth = currImgHeight; currImgHeight = swp; if (dontFreeBuffers) { currBuffp = ncurrBuffp; // don't worry, currBuffp is not lost. dontFreeBuffers = false; // these new buffers, we can free. } } else { unsigned char *p, *q; int x, y, c, swp; // we only need to rotate the display buffer. dbgprintf("2D CHAR image: only rotating the display buffer\n"); p = imdata; // on the other hand, imdata is newed, not malloced! q = new uchar[currImgWidth * currImgHeight * currImgNbSamples]; for (y = 0 ; y < currImgHeight ; y++) for (x = 0 ; x < currImgWidth ; x++) for (c = 0 ; c < currImgNbSamples ; c++) q[currImgNbSamples * (y + currImgHeight*(currImgWidth-x-1)) + c] = *p++; delete[] imdata; // this gets rid of the old buffer imdata = q; // swaps height and width of the buffer swp = currImgWidth; currImgWidth = currImgHeight; currImgHeight = swp; } // rotate the points, if any PtFileMngr->rotate90p(); } } // This method rotates the buffers by 180 degree. It is very efficient. // must also work on 3d multispectral images. void imageIO::rotate180() { if (imdata != 0) { if (overlay) { unsigned char *p, *q, swp; dbgprintf("Rotating the overlay 180 degrees\n"); p = overlay; if (ovlspp == 1) { q = p + currImgHeight*currImgWidth - 1; while (p < q) { swp = *p; *p++ =*q; *q-- = swp; } } else { // ovlspp == 3 q = p + 3 * currImgHeight*currImgWidth - 3; while (p < q) { // R swp = *p; *p++ =*q; *q++ = swp; // G swp = *p; *p++ =*q; *q++ = swp; // B swp = *p; *p++ =*q; *q = swp; // q -= 5; // would be 6 if we had done *q++ 2 lines earlier... } } // in place rotation } if (currBuffp != 0) { // this is going to be much slower than below int sz=typeSize(currPixType); unsigned char *p, *q, swp; int i, z, c; // no buffer reallocation here! for (i = 0 ; i < currImgNbSamples ; i++) { for (z = 0 ; z < currImgThickness ; z++) { p = (uchar *)currBuffp[i] + currImgWidth * currImgHeight * sz * z; q = p + (currImgHeight*currImgWidth - 1) * sz; while (p < q) { for (c = 0 ; c < sz ; c++) { swp = *p; *p++ =*q; *q++ = swp; } q -= 2*sz; } } } } else { unsigned char *p, *q, swp; int c; // we only need to rotate the display buffer. dbgprintf("2D CHAR image: only rotating the display buffer\n"); p = imdata; // no buffer reallocation here! q = p + (currImgHeight*currImgWidth - 1) * currImgNbSamples; while (p < q) { for (c = 0 ; c < currImgNbSamples ; c++) { swp = *p; *p++ =*q; *q++ = swp; } q -= 2*currImgNbSamples; } } } } // This method performs an horizontal flip. It is very efficient. // must also work on 3d multispectral images. void imageIO::fliph() { if (imdata != 0) { if (overlay) { unsigned char *p, *q, *swp; int y; swp = new uchar[ovlspp * currImgWidth]; p = overlay; q = p + ovlspp * currImgWidth * (currImgHeight - 1); dbgprintf("Flipping the overlay buffer horizontally\n"); for (y = 0 ; y < currImgHeight/2 ; y++) { memcpy(swp, p, ovlspp * currImgWidth); memcpy(p, q, ovlspp * currImgWidth); memcpy(q, swp, ovlspp * currImgWidth); p += ovlspp * currImgWidth; q -= ovlspp * currImgWidth; } delete[] swp; } if (currBuffp != 0) { // this is going to be much slower than below int sz=typeSize(currPixType); unsigned char *p, *q, *swp; int i, y, z; // this is just a temp buffer, it can be newed. swp = new uchar[currImgWidth*sz]; for (i = 0 ; i < currImgNbSamples ; i++) { for (z = 0 ; z < currImgThickness ; z++) { p = (uchar *)currBuffp[i] + currImgWidth * currImgHeight * sz * z; q = p + ((currImgHeight-1)*currImgWidth) * sz; for (y = 0 ; y < currImgHeight/2 ; y++) { memcpy(swp, p, currImgWidth*sz); memcpy(p, q, currImgWidth*sz); memcpy(q, swp, currImgWidth*sz); p += currImgWidth*sz; q -= currImgWidth*sz; } } } // swap buffer life ends here delete[] swp; } else { unsigned char *p, *q, *swp; int y; // we only need to rotate the display buffer. dbgprintf("2D CHAR image: only flipping horizontally the display buffer\n"); p = imdata; q = p + (currImgWidth * (currImgHeight - 1)) * currImgNbSamples; // same story as above with respect to temp buff. swp = new uchar[currImgWidth*currImgNbSamples]; for (y = 0 ; y < currImgHeight/2 ; y++) { memcpy(swp, p, currImgWidth*currImgNbSamples); memcpy(p, q, currImgWidth*currImgNbSamples); memcpy(q, swp, currImgWidth*currImgNbSamples); p += currImgWidth*currImgNbSamples; q -= currImgWidth*currImgNbSamples; } delete[] swp; } // flip the points PtFileMngr->fliph(); } } // This method performs a ver flip. It is not as efficient as the previous one // must also work on 3d multispectral images. void imageIO::flipv() { if (imdata != 0) { if (overlay) { unsigned char *p, *q, swp; int x, y; dbgprintf("Flipping the overlay buffer vertically\n"); if (ovlspp == 1) { for (y = 0 ; y < currImgHeight ; y++) { p = overlay + currImgWidth * y; q = p + (currImgWidth-1); for (x = 0 ; x < currImgWidth/2 ; x++) { swp = *p; *p++ = *q; *q-- = swp; } } } else { // == 3 for (y = 0 ; y < currImgHeight ; y++) { p = overlay + 3 * currImgWidth * y; q = p + 3 * (currImgWidth - 1); for (x = 0 ; x < currImgWidth/2 ; x++) { // R swp = *p; *p++ = *q; *q++ = swp; // G swp = *p; *p++ = *q; *q++ = swp; // B swp = *p; *p = *q; *q = swp; // inc q -= 5; // we only did 2 `++'s } } } } if (currBuffp != 0) { // this is going to be much slower than below int sz=typeSize(currPixType); unsigned char *p, *q, swp; int i, x, y, z, c; for (i = 0 ; i < currImgNbSamples ; i++) { for (z = 0 ; z < currImgThickness ; z++) { for (y = 0 ; y < currImgHeight ; y++) { p = (uchar *)currBuffp[i] + currImgWidth * sz * (currImgHeight * z + y); q = p + (currImgWidth-1) * sz; for (x = 0 ; x < currImgWidth/2 ; x++) { for (c = 0 ; c < sz; c++) { swp = *p; *p++ = *q; *q++ = swp; } q -= 2*sz; } } } } } else { unsigned char *p, *q, swp; int x, y, c; // we only need to rotate the display buffer. dbgprintf("2D CHAR image: only flipping vertically the display buffer\n"); for (y = 0 ; y < currImgHeight ; y++) { p = imdata + currImgWidth * y * currImgNbSamples; q = p + (currImgWidth-1) * currImgNbSamples; for (x = 0 ; x < currImgWidth/2 ; x++) { for (c = 0 ; c < currImgNbSamples; c++) { swp = *p; *p++ = *q; *q++ = swp; } q -= 2*currImgNbSamples; } } } // flip the points PtFileMngr->flipv(); } } // all the 3D rotation are more or less the same (optimization are impossible) // This is what happens when you can't rely on templates... #define rotinnerloop(P,Q,R) \ do { for (z = 0 ; z < currImgThickness ; z++) { \ for (y = 0 ; y < currImgHeight ; y++) { \ for (x = 0 ; x < currImgWidth ; x++) { \ *((Q) + R(x,y,z)) = *(P)++; \ } \ } \ } } while (0) void imageIO::rotate3Dgeneric(rot3dtransf *myrotf, long nbplanepix) { int sz=typeSize(currPixType); unsigned char *p, *q; int i, x, y, z; void **ncurrBuffp = 0; assert(currBuffp != 0); if (dontFreeBuffers) { // things are a little more complicated ncurrBuffp = (void **)malloc(currImgNbSamples * sizeof(void*)); if (ncurrBuffp == 0) errprintf("This image can't be rotated due to memory problems\n"); } for (i = 0 ; i < currImgNbSamples ; i++) { p = (uchar *)currBuffp[i]; // the currBuffps are malloced, not newed if ((q = (uchar *) malloc(currImgWidth * currImgHeight * currImgThickness * sz *sizeof(char))) != NULL) { switch (sz) { case 1: rotinnerloop(p,q,myrotf); break; case 2: { short *ps, *qs; ps = (short*)p; qs = (short*)q; rotinnerloop(ps,qs,myrotf); } break; case 4: { int *pi, *qi; pi = (int*)p; qi = (int*)q; rotinnerloop(pi,qi,myrotf); } break; case 8: { double *pd, *qd; pd = (double*)p; qd = (double*)q; rotinnerloop(pd,qd,myrotf); } break; default: errprintf("Unhandled pixel type in 3D rotation\n"); break; } if (!dontFreeBuffers) { free(currBuffp[i]); currBuffp[i] = q; } else { ncurrBuffp[i] = q; // save to a different buffer } } else { int l; errprintf("Not enough memory to rotate image\n"); if (dontFreeBuffers) { for (l = 0 ; l < i ; l++) free(ncurrBuffp[l]); free(ncurrBuffp); } // nothing further can be done for the other case // as the images have been rotated already. return; } } if (dontFreeBuffers) { currBuffp = ncurrBuffp; // don't worry, currBuffp is not lost. dontFreeBuffers = false; // these new buffers, we can free. } // Rotate the overlay if present if (overlay) { // no optimization is possible dbgprintf("Rotating the overlay up (in the 3D sense)\n"); unsigned char *p, *q; int x, y; p = overlay; if (ovlspp == 1) { q = new uchar[currImgWidth * currImgHeight]; for (z = 0 ; z < currImgThickness ; ++z) for (y = 0 ; y < currImgHeight ; ++y) for (x = 0 ; x < currImgWidth ; ++x) q[myrotf(x,y,z)] = *p++; } else { //ovlspp == 3 q = new uchar[3 * currImgWidth * currImgHeight]; for (z = 0 ; z < currImgThickness ; ++z) { for (y = 0 ; y < currImgHeight ; ++y) { for (x = 0 ; x < currImgWidth ; ++x) { int idx = 3 * (myrotf(x,y,z)); q[idx++] = *p++; q[idx++] = *p++; q[idx] = *p++; } } } } delete[] overlay; overlay = q; } } // this method rotates the buffers by 90 degree `up' // This *only* works on 3D image. // must also work multispectral images // Multicomponent or time series are handled somewhere else static long transf_rot_3d_up(int x, int y, int z) { return ((IOBlackBox->imageHeight()-y-1) * IOBlackBox->imageWidth() * IOBlackBox->imageThickness() + z * IOBlackBox->imageWidth() + x); } void imageIO::rotate3Dup() { if (imdata != 0) { int swp; long nbplanepix = IOBlackBox->imageWidth() * IOBlackBox->imageThickness(); rotate3Dgeneric(transf_rot_3d_up, nbplanepix); // swapping Y and Z swp = currImgHeight; currImgHeight = currImgThickness; currImgThickness = swp; // not sure this is correct... swp = yOffset; yOffset = zOffset; zOffset = swp; // to be safe currZpos = 0; // rotate the points, if any PtFileMngr->rotate3dup(); } } static long transf_rot_3d_down(int x, int y, int z) { return (y * IOBlackBox->imageWidth() * IOBlackBox->imageThickness() + (IOBlackBox->imageThickness() - z -1) * IOBlackBox->imageWidth() + x); } void imageIO::rotate3Ddown() { if (imdata != 0) { int swp; long nbplanepix = IOBlackBox->imageWidth() * IOBlackBox->imageThickness(); rotate3Dgeneric(transf_rot_3d_down, nbplanepix); // swapping Y and Z swp = currImgHeight; currImgHeight = currImgThickness; currImgThickness = swp; // not sure this is correct... swp = yOffset; yOffset = zOffset; zOffset = swp; // to be safe currZpos = 0; // rotate the points, if any PtFileMngr->rotate3ddown(); } } imview-1.1.9c/imtranslate.cxx0000644000076500007650000042371410720351523017053 0ustar talbottalbot00000000000000/* * $Id: imtranslate.cxx,v 4.7 2007/11/19 18:17:55 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * imtranslate.C * * This file contains code to translate raw image data into * viewable pixmaps * * This is a simple job, yet requires a bit of abstraction. * * Hugues Talbot 21 Jan 1998 * * Actually at present this is a complete mess Hugues Talbot 26 Feb 2001 * *-----------------------------------------------------------------------*/ #include #include #include #include #include "imunistd.h" #include #include #include "imview.hxx" #include "imviewWindow.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "menubar.hxx" #include "nocase.hxx" #include "io/newprefio.hxx" // application components extern imageViewer *mainViewer; extern imviewWindow *mainWindow; extern imprefs *fileprefs; extern imViewMenuBar *mainMenuBar; // other naughty global variables extern char appName[]; // this is needed to change the window's title extern int applyTransferToAll; extern bool lutWraparound; extern int makeImageCharIfFits; extern int RGBdisplaysRGB; extern int fitCharOverAllSamples; extern int fitCharOverAllSlices; extern unsigned char FL_COLOURS[][3]; // this function return a static char pointer to a buffer // giving information on the underlying data. // This is only intended for `casual' data inspection (data box on image) // for complete information on the data, you must use the next function // (same name, but with a zpos third argument char *imageIO::getRawDataInfo(int xpos, int ypos) { static char returnInfo1[512], returnInfo2[256], buff[128]; int zpos; // not an argument here int maxComp; // maximum number of samples to display, if present long zoff; // in this function, zpos is not given, we take the current position as the default zpos = currZpos; zoff = buffZOffset; // maximum nb of samples to display maxComp = trivmin(3, currImgNbSamples); // pixtype-independent information if ((xOffset != 0) || (yOffset != 0) || (zOffset != 0)) { if (currImgThickness > 1) { // we are pedantic only if need be sprintf(returnInfo1, " (X=%d, Y=%d, Z=%d) ", xpos+xOffset, ypos+yOffset, zpos+zOffset); } else { // only display the 3-D info if needed sprintf(returnInfo1, " (X=%d, Y=%d) ", xpos+xOffset, ypos+yOffset); } } else { returnInfo1[0] = '\0'; } switch (currPixType) { case IM_BINARY: sprintf(returnInfo2," ", !(*(imdata + zoff + currImgWidth*ypos + xpos) != 0)); break; case IM_UINT1: case IM_INT1: returnInfo2[0] = '\0'; // default: no colourmap if (!currImgHasCLUT && (currBuffp != 0)) { // hmmm... && (currImgNbSamples > 1)) { int i; if (currComp < 2) { sprintf(returnInfo2, " (%d)", currImgNbSamples); strcat(returnInfo2, buff); } else strcat(returnInfo2, ">"); } else if (currComp < currImgNbSamples-maxComp+1) { sprintf(returnInfo2, " (%d)", *((uchar *)currBuffp[currComp-1] + zoff + currImgWidth*ypos + xpos), *((uchar *)currBuffp[currComp] + zoff + currImgWidth*ypos + xpos), *((uchar *)currBuffp[currComp+1] + zoff + currImgWidth*ypos + xpos), currImgNbSamples); } else { sprintf(returnInfo2, " (%d)", *((uchar *)currBuffp[currImgNbSamples-3] + zoff + currImgWidth*ypos + xpos), *((uchar *)currBuffp[currImgNbSamples-2] + zoff + currImgWidth*ypos + xpos), *((uchar *)currBuffp[currImgNbSamples-1] + zoff + currImgWidth*ypos + xpos), currImgNbSamples); } } else if (currImgHasCLUT && (currBuffp != 0) && (currBuffp[currComp] != 0)) { sprintf(returnInfo2, " ", *((uchar *)currBuffp[currComp] + zoff + currImgWidth*ypos + xpos)); } break; case IM_INT2: if (currBuffp != 0) { int i; if (currComp < 2) { sprintf(returnInfo2, " (%d)", currImgNbSamples); strcat(returnInfo2, buff); } else strcat(returnInfo2, ">"); } else if (currComp < currImgNbSamples-maxComp+1) { sprintf(returnInfo2, " (%d)", *((short *)currBuffp[currComp-1] + zoff + currImgWidth*ypos + xpos), *((short *)currBuffp[currComp] + zoff + currImgWidth*ypos + xpos), *((short *)currBuffp[currComp+1] + zoff + currImgWidth*ypos + xpos), currImgNbSamples); } else { sprintf(returnInfo2, " (%d)", *((short *)currBuffp[currImgNbSamples-3] + zoff + currImgWidth*ypos + xpos), *((short *)currBuffp[currImgNbSamples-2] + zoff + currImgWidth*ypos + xpos), *((short *)currBuffp[currImgNbSamples-1] + zoff + currImgWidth*ypos + xpos), currImgNbSamples); } } else { sprintf(returnInfo2, " "); } break; case IM_UINT2: if (currBuffp != 0) { int i; if (currComp < 2) { sprintf(returnInfo2, " (%d)", currImgNbSamples); strcat(returnInfo2, buff); } else strcat(returnInfo2, ">"); } else if (currComp < currImgNbSamples-maxComp+1) { sprintf(returnInfo2, " (%d)", *((unsigned short *)currBuffp[currComp-1] + zoff + currImgWidth*ypos + xpos), *((unsigned short *)currBuffp[currComp] + zoff + currImgWidth*ypos + xpos), *((unsigned short *)currBuffp[currComp+1] + zoff + currImgWidth*ypos + xpos), currImgNbSamples); } else { sprintf(returnInfo2, " (%d)", *((unsigned short *)currBuffp[currImgNbSamples-3] + zoff + currImgWidth*ypos + xpos), *((unsigned short *)currBuffp[currImgNbSamples-2] + zoff + currImgWidth*ypos + xpos), *((unsigned short *)currBuffp[currImgNbSamples-1] + zoff + currImgWidth*ypos + xpos), currImgNbSamples); } } else { sprintf(returnInfo2, " "); } break; case IM_INT4: case IM_UINT4: if (!currImgHasCLUT) { if (currBuffp != 0) { int i; if (currComp < 2) { sprintf(returnInfo2, " (%d)", currImgNbSamples); strcat(returnInfo2, buff); } else strcat(returnInfo2, ">"); } else if (currComp < currImgNbSamples-maxComp+1) { sprintf(returnInfo2, " (%d)", *((int *)currBuffp[currComp-1] + zoff + currImgWidth*ypos + xpos), *((int *)currBuffp[currComp] + zoff + currImgWidth*ypos + xpos), *((int *)currBuffp[currComp+1] + zoff + currImgWidth*ypos + xpos), currImgNbSamples); } else { sprintf(returnInfo2, " (%d)", *((int *)currBuffp[currImgNbSamples-3] + zoff + currImgWidth*ypos + xpos), *((int *)currBuffp[currImgNbSamples-2] + zoff + currImgWidth*ypos + xpos), *((int *)currBuffp[currImgNbSamples-1] + zoff + currImgWidth*ypos + xpos), currImgNbSamples); } } else { sprintf(returnInfo2, " "); } } else if ((currBuffp != 0) && (currBuffp[currComp] != 0)) { int val = *((int *)currBuffp[currComp] + zoff + currImgWidth*ypos + xpos); sprintf(returnInfo2, " ", val,val % 256); } else { sprintf(returnInfo2, " "); } break; case IM_FLOAT: if (currBuffp != 0) { int i; if (currComp < 2) { sprintf(returnInfo2, " (%d)", currImgNbSamples); strcat(returnInfo2, buff); } else strcat(returnInfo2, ">"); } else if (currComp < currImgNbSamples-maxComp+1) { sprintf(returnInfo2, " (%d)", *((float *)currBuffp[currComp-1] + zoff + currImgWidth*ypos + xpos), *((float *)currBuffp[currComp] + zoff + currImgWidth*ypos + xpos), *((float *)currBuffp[currComp+1] + zoff + currImgWidth*ypos + xpos), currImgNbSamples); } else { sprintf(returnInfo2, " (%d)", *((float *)currBuffp[currImgNbSamples-3] + zoff + currImgWidth*ypos + xpos), *((float *)currBuffp[currImgNbSamples-2] + zoff + currImgWidth*ypos + xpos), *((float *)currBuffp[currImgNbSamples-1] + zoff + currImgWidth*ypos + xpos), currImgNbSamples); } } else { sprintf(returnInfo2, " "); } break; case IM_DOUBLE: if (currBuffp != 0) { int i; if (currComp < 2) { sprintf(returnInfo2, " (%d)", currImgNbSamples); strcat(returnInfo2, buff); } else strcat(returnInfo2, ">"); } else if (currComp < currImgNbSamples-maxComp+1) { sprintf(returnInfo2, " (%d)", *((double *)currBuffp[currComp-1] + zoff + currImgWidth*ypos + xpos), *((double *)currBuffp[currComp] + zoff + currImgWidth*ypos + xpos), *((double *)currBuffp[currComp+1] + zoff + currImgWidth*ypos + xpos), currImgNbSamples); } else { sprintf(returnInfo2, " (%d)", *((double *)currBuffp[currImgNbSamples-3] + zoff + currImgWidth*ypos + xpos), *((double *)currBuffp[currImgNbSamples-2] + zoff + currImgWidth*ypos + xpos), *((double *)currBuffp[currImgNbSamples-1] + zoff + currImgWidth*ypos + xpos), currImgNbSamples); } } else { sprintf(returnInfo2, " "); } break; default: sprintf(returnInfo2, " "); // this means error, of course break; } return strcat(returnInfo1, returnInfo2); } // This version returns as much information as possible, even when redundant // this function should not be called to decide whether raw information // is present or not. Call the `hasRawData' function for that... char *imageIO::getRawDataInfo(int xpos, int ypos, int zpos) { static char *returnInfo1 = 0, *returnInfo2 = 0, buff[128]; long zoff; if (zpos < 0) zpos = 0; if (zpos >= currImgThickness) zpos = currImgThickness-1; zoff = zpos * (currImgWidth*currImgHeight); if (returnInfo1 != 0) { delete[] returnInfo1; delete[] returnInfo2; } returnInfo1 = new char[currImgNbSamples * 30 + 40]; // 30 chars per sample should be enough... returnInfo2 = new char[currImgNbSamples * 30]; // pixtype-independent information sprintf(returnInfo1, " %4d %4d %4d ", xpos, ypos, zpos); // pixtype-depend information switch (currPixType) { case IM_BINARY: sprintf(returnInfo2," %2d BIN %4d ", 1, (*(imdata + zoff + currImgWidth*ypos + xpos) == 0)); if ((currBuffp != 0) && (currBuffp[0] != 0)) { sprintf(returnInfo2, " %2d BIN %4d", currImgNbSamples, (*((uchar *)currBuffp[0] + zoff + currImgWidth*ypos + xpos) == 0)); for (int i = 1 ; i < currImgNbSamples; i++) { sprintf(buff, " %4d", (*((uchar *)currBuffp[i] + zoff + currImgWidth*ypos + xpos) == 0)); strcat(returnInfo2, buff); } } else { if (currImgNbSamples == 1) sprintf(returnInfo2," %2d BIN %4d ", 1, (*(imdata + currImgWidth*ypos + xpos) == 0)); else if (currImgNbSamples == 3) { uchar *xp; xp = imdata + 3 * (currImgWidth*ypos + xpos); sprintf(returnInfo2," %2d BIN %4d %4d %4d", 3, (*xp == 0), (*(xp+1) == 0), (*(xp+2) == 0)); } else { sprintf(returnInfo2," %2d BIN ???", currImgNbSamples); // this is an error, of course } } break; case IM_UINT1: case IM_INT1: if (currImgHasCLUT && (currBuffp != 0) && (currBuffp[0] != 0)) { sprintf(returnInfo2, " %2d LUT %4d ", 1, *((uchar *)currBuffp[0] + zoff + currImgWidth*ypos + xpos)); } else { if ((currBuffp != 0) && (currBuffp[0] != 0)) { sprintf(returnInfo2, " %2d CHR %4d", currImgNbSamples, *((uchar *)currBuffp[0] + zoff + currImgWidth*ypos + xpos)); for (int i = 1 ; i < currImgNbSamples; i++) { sprintf(buff, " %4d", *((uchar *)currBuffp[i] + zoff + currImgWidth*ypos + xpos)); strcat(returnInfo2, buff); } } else { if (currImgNbSamples == 1) sprintf(returnInfo2," %2d CHR %4d ", 1, *(imdata + currImgWidth*ypos + xpos)); else if (currImgNbSamples == 3) { uchar *xp; xp = imdata + 3 * (currImgWidth*ypos + xpos); sprintf(returnInfo2," %2d CHR %4d %4d %4d", 3, *xp, *(xp+1), *(xp+2)); } else { sprintf(returnInfo2," %2d CHR ???", currImgNbSamples); // this is an error, of course } } } break; case IM_INT2: if (currBuffp != 0) { sprintf(returnInfo2, " %2d SHT %4d", currImgNbSamples, *((short *)currBuffp[0] + zoff + currImgWidth*ypos + xpos)); for (int i = 1 ; i < currImgNbSamples ; i++) { sprintf(buff, " %4d", *((short *)currBuffp[i] + zoff + currImgWidth*ypos + xpos)); strcat(returnInfo2, buff); } } else { sprintf(returnInfo2, " 0 SHT ??? "); } break; case IM_UINT2: if (currBuffp != 0) { sprintf(returnInfo2, " %2d UST %4d", currImgNbSamples, *((unsigned short *)currBuffp[0] + zoff + currImgWidth*ypos + xpos)); for (int i = 1 ; i < currImgNbSamples ; i++) { sprintf(buff, " %4d", *((unsigned short *)currBuffp[i] + zoff + currImgWidth*ypos + xpos)); strcat(returnInfo2, buff); } } else { sprintf(returnInfo2, " 0 UST ??? "); } break; case IM_INT4: case IM_UINT4: if (currImgHasCLUT && (currBuffp != 0) && (currBuffp[0] != 0)) { int val = *((int *)currBuffp[0] + zoff + currImgWidth*ypos + xpos); sprintf(returnInfo2, " %2d LUT %4d %4d ", 2, val, val % 256 ); } else if ((currBuffp != 0) && (currBuffp[0] != 0)) { sprintf(returnInfo2, " %2d INT %4d", currImgNbSamples, *((int *)currBuffp[0] + zoff + currImgWidth*ypos + xpos)); for (int i = 1 ; i < currImgNbSamples ; i++) { sprintf(buff, " %4d", *((int *)currBuffp[i] + zoff + currImgWidth*ypos + xpos)); strcat(returnInfo2, buff); } } else { sprintf(returnInfo2, " 0 INT ??? "); } break; case IM_FLOAT: if (currBuffp != 0) { sprintf(returnInfo2, " %2d FLT %f", currImgNbSamples, *((float *)currBuffp[0] + zoff + currImgWidth*ypos + xpos)); for (int i = 1 ; i < currImgNbSamples ; i++) { sprintf(buff, " %f", *((float *)currBuffp[i] + zoff + currImgWidth*ypos + xpos)); strcat(returnInfo2, buff); } } else { sprintf(returnInfo2, " 0 FLT ??? "); } break; case IM_DOUBLE: if (currBuffp != 0) { sprintf(returnInfo2, " %2d DBL %f", currImgNbSamples, *((double *)currBuffp[0] + zoff + currImgWidth*ypos + xpos)); for (int i = 1 ; i < currImgNbSamples ; i++) { sprintf(buff, " %f", *((double *)currBuffp[i] + zoff + currImgWidth*ypos + xpos)); strcat(returnInfo2, buff); } } else { sprintf(returnInfo2, " 0 DBL ??? "); } break; default: sprintf(returnInfo2, " 0 ERR !"); // this means error, of course break; } return strcat(returnInfo1, returnInfo2); } // return the data in vector form to display as a spectrum double *imageIO::getRawDataVector(int xpos, int ypos, int *nb) { int zpos, zoff; static double *returnInfo = 0; zpos = currZpos; if (zpos < 0) zpos = 0; if (zpos >= currImgThickness) zpos = currImgThickness-1; zoff = zpos * (currImgWidth*currImgHeight); if (returnInfo != 0) { delete[] returnInfo; } returnInfo = new double[currImgNbSamples]; *nb = currImgNbSamples; switch (currPixType) { case IM_BINARY: case IM_UINT1: case IM_INT1: if ((currBuffp != 0) && (currBuffp[0] != 0)) { for (int i = 0 ; i < currImgNbSamples; i++) returnInfo[i] = (double) *((uchar *)currBuffp[i] + zoff + currImgWidth*ypos + xpos); } else { if (currImgNbSamples == 1) returnInfo[0] = (double) *(imdata + currImgWidth*ypos + xpos); else if (currImgNbSamples == 3) { uchar *xp; xp = imdata + 3 * (currImgWidth*ypos + xpos); returnInfo[0] = (double) *xp; returnInfo[1] = (double) *(xp+1); returnInfo[2] = (double) *(xp+2); } } break; case IM_INT2: if (currBuffp != 0) { for (int i = 0 ; i < currImgNbSamples ; i++) returnInfo[i] = (double) *((short *)currBuffp[i] + zoff + currImgWidth*ypos + xpos); } break; case IM_UINT2: if (currBuffp != 0) { for (int i = 0 ; i < currImgNbSamples ; i++) returnInfo[i] = (double) *((unsigned short *)currBuffp[i] + zoff + currImgWidth*ypos + xpos); } break; case IM_INT4: case IM_UINT4: if (currBuffp != 0) { for (int i = 0 ; i < currImgNbSamples ; i++) returnInfo[i] = (double) *((int *)currBuffp[i] + zoff + currImgWidth*ypos + xpos); } break; case IM_FLOAT: if (currBuffp != 0) { for (int i = 0 ; i < currImgNbSamples ; i++) returnInfo[i] = (double) *((float *)currBuffp[i] + zoff + currImgWidth*ypos + xpos); } break; case IM_DOUBLE: if (currBuffp != 0) { for (int i = 0 ; i < currImgNbSamples ; i++) returnInfo[i] = *((double *)currBuffp[i] + zoff + currImgWidth*ypos + xpos); } break; default: for (int i = 0 ; i < currImgNbSamples ; i++) returnInfo[i] = 0.0; break; } return returnInfo; } int imageIO::getRawDataPoint(long delta, double &GL) { double dummyG, dummyB; return(getRawDataPoint(delta, GL, dummyG, dummyB)); } int imageIO::getRawDataPoint(long delta, double &R, double &G, double &B) { int retval = 0; if (currBuffp != 0) { // in this function, zpos is not given, we take the current position as the default int zoff = buffZOffset; if ((imspp == 1) || (currImgNbSamples != 3) || (!RGBdisplaysRGB)) { // colour LUT or Overlay a possibility switch (currPixType) { case IM_BINARY: case IM_UINT1: R = G = B = (double)(*((char *)currBuffp[currComp] + zoff + delta)); break; case IM_INT2: R = G = B = (double)(*((short *)currBuffp[currComp] + zoff + delta)); break; case IM_UINT2: R = G = B = (double)(*((unsigned short *)currBuffp[currComp] + zoff + delta)); break; case IM_INT4: R = G = B = (double)(*((int *)currBuffp[currComp] + zoff + delta)); break; case IM_FLOAT: R = G = B = (double)(*((float *)currBuffp[currComp] + zoff + delta)); break; case IM_DOUBLE: R = G = B = (double)(*((double *)currBuffp[currComp] + zoff + delta)); break; default: retval = 1; break; } } else { // we assume exactly 3 components, meaning RGB data (not always true) assert(currImgNbSamples == 3); switch (currPixType) { case IM_BINARY: case IM_UINT1: R = (double)(*((char *)currBuffp[0] + zoff + delta)); G = (double)(*((char *)currBuffp[1] + zoff + delta)); B = (double)(*((char *)currBuffp[2] + zoff + delta)); break; case IM_INT2: R = (double)(*((short *)currBuffp[0] + zoff + delta)); G = (double)(*((short *)currBuffp[1] + zoff + delta)); B = (double)(*((short *)currBuffp[3] + zoff + delta)); break; case IM_UINT2: R = (double)(*((unsigned short *)currBuffp[0] + zoff + delta)); G = (double)(*((unsigned short *)currBuffp[1] + zoff + delta)); B = (double)(*((unsigned short *)currBuffp[2] + zoff + delta)); break; case IM_INT4: R = (double)(*((int *)currBuffp[0] + zoff + delta)); G = (double)(*((int *)currBuffp[1] + zoff + delta)); B = (double)(*((int *)currBuffp[2] + zoff + delta)); break; case IM_FLOAT: R = (double)(*((float *)currBuffp[0] + zoff + delta)); G = (double)(*((float *)currBuffp[1] + zoff + delta)); B = (double)(*((float *)currBuffp[2] + zoff + delta)); break; case IM_DOUBLE: R = (double)(*((double *)currBuffp[0] + zoff + delta)); R = (double)(*((double *)currBuffp[1] + zoff + delta)); R = (double)(*((double *)currBuffp[2] + zoff + delta)); break; default: retval = 1; break; } } } else { if (imspp == 1) { G = B = R = imdata[delta]; } else { R = imdata[delta * 3]; G = imdata[delta * 3 + 1]; B = imdata[delta * 3 + 2]; } } return retval; } // Same as above, but image is really 3D, pretending it's hyperspectral. // This is a hack for the sake of my colleagues who can't be bothered // fixing things when they are broken. I HATE this. // Note: This is all because Z-IMAGE handles hyperspectral images // like a pig, although it had been designed from the start // to do better than that. // Hugues Talbot 31 Dec 1998 // To be fair, this might prove to be useful in the end... // return the data in vector form to display as a spectrum double *imageIO::get3DRawDataVector(int xpos, int ypos, int *nb) { int cpos, zoff; static double *returnInfo = 0; // we'll use the currently displayed component cpos = currComp; if (cpos < 0) cpos = 0; if (cpos >= currImgNbSamples) cpos = currImgNbSamples-1; zoff = currImgWidth*currImgHeight; if (returnInfo != 0) { delete[] returnInfo; } returnInfo = new double[currImgThickness]; *nb = currImgThickness; switch (currPixType) { case IM_BINARY: case IM_UINT1: case IM_INT1: if ((currBuffp != 0) && (currBuffp[cpos] != 0)) { for (int i = 0 ; i < currImgThickness; i++) returnInfo[i] = (double) *((uchar *)currBuffp[cpos] + zoff*i + currImgWidth*ypos + xpos); } else { if (currImgNbSamples == 1) for (int i = 0 ; i < currImgThickness; i++) returnInfo[i] = (double) *(imdata + zoff*i + currImgWidth*ypos + xpos); else if (currImgNbSamples == 3) { uchar *xp; xp = imdata + 3 * (currImgWidth*ypos + xpos); for (int i = 0 ; i < currImgThickness; i++) returnInfo[i] = (double) *(imdata + 3 * (zoff*i + currImgWidth*ypos + xpos) + cpos); } } break; case IM_INT2: if ((currBuffp != 0) && (currBuffp[cpos] != 0)) { for (int i = 0 ; i < currImgThickness ; i++) returnInfo[i] = (double) *((short *)currBuffp[cpos] + zoff*i + currImgWidth*ypos + xpos); } break; case IM_UINT2: if ((currBuffp != 0) && (currBuffp[cpos] != 0)) { for (int i = 0 ; i < currImgThickness ; i++) returnInfo[i] = (double) *((unsigned short *)currBuffp[cpos] + zoff*i + currImgWidth*ypos + xpos); } break; case IM_INT4: case IM_UINT4: if ((currBuffp != 0) && (currBuffp[cpos] != 0)) { for (int i = 0 ; i < currImgThickness ; i++) returnInfo[i] = (double) *((int *)currBuffp[cpos] + zoff*i + currImgWidth*ypos + xpos); } break; case IM_FLOAT: if ((currBuffp != 0) && (currBuffp[cpos] != 0)) { for (int i = 0 ; i < currImgThickness ; i++) returnInfo[i] = (double) *((float *)currBuffp[cpos] + zoff*i + currImgWidth*ypos + xpos); } break; case IM_DOUBLE: if ((currBuffp != 0) && (currBuffp[cpos] != 0)) { for (int i = 0 ; i < currImgThickness ; i++) returnInfo[i] = *((double *)currBuffp[cpos] + zoff*i + currImgWidth*ypos + xpos); } break; default: for (int i = 0 ; i < currImgThickness ; i++) returnInfo[i] = 0.0; break; } return returnInfo; } // helps to decide whether current image has more data than meet the eye. int imageIO::hasRawData(void) { int retval = 0; if ((xOffset != 0) || (yOffset != 0) || (zOffset != 0) || (currImgThickness > 1)) { retval = 1; } else if ((currBuffp != 0) && (currBuffp[0] != 0)) { retval = 2; } return retval; } // returns the content of the image along the // bresenham line given by its start and end points. // allocates the buffers! void imageIO::getLineDataVectors(int X2, int Y2, int X, int Y, double *&red, double *&green, double *&blue, int &nb) { int delta, i; // sanity check, X2 and Y2 are assumed OK if (X >= imageWidth()) X = imageWidth() - 1; if (X < 0) X = 0; if (Y >= imageHeight()) Y = imageHeight() - 1; if (Y < 0) Y = 0; nb = trivmax(abs(X2-X), abs(Y2-Y)); nb = trivmax(nb, 1); // at least one value is returned. if (imspp == 1) { red = new double[nb]; green = blue = 0; delta = bresinit(X2,Y2,X,Y); i = 0; do { getRawDataPoint(delta, red[i]) ; ++i; } while ((delta = bresgetnext())> 0 && (i < nb)); } else { red = new double[nb]; green = new double[nb]; blue = new double[nb]; delta = bresinit(X2,Y2,X,Y); i = 0; do { getRawDataPoint(delta, red[i], green[i], blue[i]); ++i; } while ((delta = bresgetnext())> 0 && (i < nb)); } if (i != nb) { dbgprintf("Adjusting profile vector length from %d to %d\n", nb, i); nb = i; } return; } // the well-known Bresenham algorithm in a flexible incarnation int imageIO::bresinit(int x1_, int y1_, int x2_, int y2_) { sizex_ = imageWidth(); dx_ = x2_ - x1_; dy_ = y2_ - y1_; if (dx_ < 0) dx_ = -dx_; if (dy_ < 0) dy_ = -dy_; if (x2_ < x1_) incx_ = -1; else incx_ = 1; if (y2_ < y1_) incy_ = -1; else incy_ = 1; xpos_ = x1_; ypos_ = y1_; if (dx_ > dy_) { e_ = 2*dy_ - dx_; inc1_ = 2*(dy_-dx_); inc2_ = 2*dy_; } else { e_ = 2*dx_ - dy_; inc1_ = 2*(dx_-dy_); inc2_ = 2*dx_; } i_ = 0; return (xpos_ + ypos_ * sizex_); } int imageIO::bresgetnext(void) { if (dx_ > dy_) { if (++i_ >= dx_) return -1; else { if (e_ >= 0) { ypos_ += incy_; e_ += inc1_; } else e_ += inc2_; xpos_ += incx_; return (xpos_ + ypos_ * sizex_); } } else { if (++i_ >= dy_) return -1; else { if (e_ >= 0) { xpos_ += incx_; e_ += inc1_; } else e_ += inc2_; ypos_ += incy_; return (xpos_ + ypos_ * sizex_); } } } void imageIO::translateForDisplay(bool keepOverlay) { uchar *newbuf; int newspp; bool freeBuffers = !keepOverlay; bool makeChar = (makeImageCharIfFits > 0); bool interpretRGB = (RGBdisplaysRGB > 0); bool minmaxAllSamples = (fitCharOverAllSamples > 0); bool minmaxAllSlices = (fitCharOverAllSlices > 0); dbgprintf("Image is [%d]x[%d]x[%d]\n", currImgWidth, currImgHeight, currImgThickness); if (currBuffp != 0) { // translation is required switch (currPixType) { case IM_BINARY: convertBINARY(&newspp, &newbuf); break; case IM_INT1: // this is dodgy case IM_UINT1: convertUINT1(&newspp, &newbuf, freeBuffers, interpretRGB); break; // the template convert function has more features #ifdef HAVE_MEMBER_TEMPLATES case IM_INT2: convert(&newspp, &newbuf, freeBuffers, makeChar, interpretRGB, minmaxAllSamples, minmaxAllSlices); break; case IM_UINT2: convert(&newspp, &newbuf, freeBuffers, makeChar, interpretRGB, minmaxAllSamples, minmaxAllSlices); break; case IM_INT4: convert(&newspp, &newbuf, freeBuffers, makeChar, interpretRGB, minmaxAllSamples, minmaxAllSlices); break; case IM_UINT4: convert(&newspp, &newbuf, freeBuffers, makeChar, interpretRGB, minmaxAllSamples, minmaxAllSlices); break; case IM_FLOAT: convert(&newspp, &newbuf, freeBuffers, false, interpretRGB, minmaxAllSamples, minmaxAllSlices); break; case IM_DOUBLE: convert(&newspp, &newbuf, freeBuffers, false, interpretRGB, minmaxAllSamples, minmaxAllSlices); break; #else // more restricted set of transforms with fewer features case IM_INT2: convertINT2(&newspp, &newbuf); break; case IM_UINT2: convertUINT2(&newspp, &newbuf); break; case IM_INT4: convertINT4(&newspp, &newbuf); break; case IM_UINT4: convertUINT4(&newspp, &newbuf); break; case IM_DOUBLE: convertDOUBLE(&newspp, &newbuf); break; #endif default: errprintf("imtranslate: format as yet unsupported, type=%s\n", typeName(currPixType)); freeCurrentBuffers(); // fake buffer to get through this tough point newbuf = new uchar[currImgWidth*currImgHeight]; newspp = 1; break; } if (newbuf != 0) { delete[] imdata; imdata = newbuf; // if (!keepOverlay) { // delete[] overlay; // overlay = 0; // } imspp = newspp; } } else { // no translation required imspp = currImgNbSamples; } } // THis applies the clut that has been saved int imageIO::applyCurrentCLUT(void) { if (currImgHasCLUT) return applyCLUTtoCurrentImage(currImgCLUTPath); else return 0; // not an error, but do nothing. } // there are 2 strategies to apply a CLUT, it could be either // on the raw data, or on the converted 8 bit data. // The former can only be applied on a subset of data: // - char // - int // - single spectra images (it creates RGB images) // the latter can be applied to any kind of data and an // arbitrary multispectral image (but not already RGB!) // The only advandage of the former is that when applying // a region-type CLUT on a labelled (int) image, neighboring regions // will have different colours, which is highly desirable for // identification purposes. // // This function now performs both, with a switch to decide // which strategy should be considered // // Hugues Talbot 3 Jul 1999 // // this function applies a LUT to an already-read single-sample image int imageIO::applyCLUTtoCurrentImage(const char *CLUTpath, bool useRaw) { int retval = 0; uchar *olddata ; int olddepth; uchar theCLUT[3][256]; // this is indispensable olddata = imdata; olddepth = imspp; dbgprintf("Applying CLUT %s to current image\n", CLUTpath); if (lutWraparound) { dbgprintf("Applying CLUT on Raw data, if possible\n"); if (currImgNbSamples == 1) { // then we can do something... dbgprintf("Expected number of samples: 1\n"); // fill up the return data as best we can currImgHasCLUT = false; currImgCLUTPath = 0; if (currBuffp == 0) { // the raw data buffer has been freed, therefore datatype should be char if ((currPixType != IM_BINARY) && (currPixType != IM_UINT1) && (currPixType != IM_INT1)) { errprintf("Raw data not present, yet image is of type %d (%s): this is a bug\n", currPixType, typeName(currPixType)); retval = 1; } else { dbgprintf("Recycling the old data\n"); if ((currBuffp = (void **)malloc(sizeof(void *))) == 0) { errprintf("ApplyCLUTtoCurrentImage: not enough memory!\n"); retval = 2; } else if ((currBuffp[0] = (uchar *)malloc(currImgWidth*currImgHeight*sizeof(uchar))) == 0) { free(currBuffp); currBuffp = 0; errprintf("ApplyCLUTtoCurrentImage: not enough memory!\n"); retval = 3; } else { memcpy(currBuffp[0], imdata, currImgWidth*currImgHeight*sizeof(uchar)); } } } // a new currBuffp may just have been allocated... if ((currBuffp != 0) && (currBuffp[0] != 0)) { dbgprintf("Current image is [%d]x[%d]x[%d]\n", currImgWidth, currImgHeight, currImgThickness); // read the CLUT in if (checkForClut(CLUTpath, 0, theCLUT)) { switch (currPixType) { case IM_BINARY: case IM_UINT1: case IM_INT1: dbgprintf("Current pixeltype is binary or char\n"); convertUINT1withLUT(&imspp, &imdata, theCLUT); currImgHasCLUT = true; // current image is shown with colourmap currImgCLUTPath = CLUTpath; break; case IM_INT4: case IM_UINT4: dbgprintf("Current pixeltype is int\n"); convertINT4withLUT_wraparound(&imspp, &imdata, theCLUT); currImgHasCLUT = true; currImgCLUTPath = CLUTpath; break; #ifdef HAVE_MEMBER_TEMPLATES case IM_INT2: dbgprintf("Current pixeltype is short\n"); convertWithLUT_wraparound(&imspp, &imdata, theCLUT); currImgHasCLUT = true; currImgCLUTPath = CLUTpath; break; case IM_UINT2: dbgprintf("Current pixeltype is unsigned short\n"); convertWithLUT_wraparound(&imspp, &imdata, theCLUT); currImgHasCLUT = true; currImgCLUTPath = CLUTpath; break; case IM_FLOAT: dbgprintf("Current pixeltype is float\n"); convertWithLUT_wraparound(&imspp, &imdata, theCLUT); currImgHasCLUT = true; currImgCLUTPath = CLUTpath; break; case IM_DOUBLE: dbgprintf("Current pixeltype is double\n"); convertWithLUT_wraparound(&imspp, &imdata, theCLUT); currImgHasCLUT = true; currImgCLUTPath = CLUTpath; break; default: errprintf("Colour maps cannot be applied to type %d (%s)\n", currPixType, typeName(currPixType)); retval = 4; break; #else default: errprintf("Colour maps cannot be applied to type %d (%s)\n", currPixType, typeName(currPixType)); retval = 4; break; #endif } } else { errprintf("Colour LUT %s couldn't be read\n", CLUTpath); retval = 5; } } else { if (currBuffp) { errprintf("Pointer to raw data lost: this is a bug\n"); retval = 6; } } } else { errprintf("Cannot apply Colour LUT to image with %d samples\n", currImgNbSamples); retval = 7; } } else { uchar *newData; // we need this to avoid circular references dbgprintf("Applying CLUT on imdata buffer, if possible\n"); if ((imspp != 1) && !currImgHasCLUT){ errprintf("The image is currently displayed as an RGB image,\n" "applying a CLUT to an RGB image is impossible"); } else { if ( (imspp != 1) && currImgHasCLUT) { // the RGB problem is due to a pre-applied CLUT // revert to grey-level first translateForDisplay(); // this can obviously creates a new imdata if (imdata != olddata) { // the current olddata is now invalid (points to old imdata, no longer // the present imdata). The old imdata has already been freed! olddata = imdata; } } saveToRawBuffers(true); // save original data to raw buffers if necessary if (checkForClut(CLUTpath, 0, theCLUT)) { convertDirectLUT(&imspp, &newData, theCLUT); currImgHasCLUT = true; // current image is shown with colourmap currImgCLUTPath = CLUTpath; imdata = newData; } else { currImgHasCLUT = false; currImgCLUTPath = 0; } } } if (imdata != 0 && imdata != olddata) { delete[] olddata; delete[] overlay; overlay = 0; olddata = 0; // ? } else { imdata = olddata; imspp = olddepth; } //if (applyTransferToAll) // applyGammaToCurrentImage(); // this means reuse predefined gamma if present return retval; } #if 0 // this function applies a look-up table to an existing image // gamma is applied on the data about to be displayed... // Hugues Talbot 4 Mar 1999: this is a bit confusing: // if reset is true, map is 0 // delete the old buffer and return // if reset is false and map is 0: // apply the old map to the new image // if reset is false and map is non-null: // store the new map and apply it to the new image. // // Default is reset = false, map = 0. int imageIO::oldapplyGammaToCurrentImage(bool reset, uchar *map) { int retval = 0; static uchar *olddata = 0; static uchar *oldmap = 0; uchar *p, *q, *end; long nbpix; if (imdata != 0) { if (reset) { if (olddata) { delete[] olddata; olddata = 0; } return retval; } nbpix = currImgWidth * currImgHeight * imspp; if (olddata == 0) { // this is the first time: we allocate & copy the data olddata = new uchar[nbpix]; memcpy(olddata, imdata, nbpix); } // we apply the gamma p = olddata; q = imdata; end = p + nbpix; if (map != 0) { while (p!=end) { *q++ = map[*p++]; } oldmap = map; } else if (oldmap != 0) { while (p!=end) { *q++ = oldmap[*p++]; } } // else nothing gets changed } return retval; } #endif // // To save space, when reading in RGB or GL images, // the raw buffers (currBuffp) are not used. // we need them again when we muck around with the // data, such as imposing a gamma, etc. // This saves back the `imdata' data to the raw buffers. // The one argument tells this function to use only // one buffer for grey images if possible. If the // data is colour RGB 3 buffers will be used anyway, // but even for grey images we might want to save the // data in 3 buffers, for example when imposing a // tranform on the red channel and not the others. The // input might be Grey but the output will be colour... // / // Hope this makes sense. Hugues Talbot 29 May 1999 int imageIO::saveToRawBuffers(bool keepGreyIfPossible) { int retval = 0; if (currBuffp == 0) { // the data is not already in the raw buffers. if (imspp == 1) { if (keepGreyIfPossible) { // the transformation remains grey-level // the raw data buffer has been freed, therefore datatype should be char if ((currPixType != IM_BINARY) && (currPixType != IM_UINT1) && (currPixType != IM_INT1)) { errprintf("Raw data not present, yet image is of type %d (%s): this is a bug\n", currPixType, typeName(currPixType)); retval = 1; } else { dbgprintf("Saving the old data to cuffBuffp\n"); if ((currBuffp = (void **)malloc(sizeof(void *))) == 0) { errprintf("saveToRawBuffers: not enough memory!\n"); retval = 2; } else if ((currBuffp[0] = (uchar *)malloc(currImgWidth*currImgHeight*sizeof(uchar))) == 0) { free(currBuffp); currBuffp = 0; errprintf("saveToRawBuffers: not enough memory!\n"); retval = 3; } else { memcpy(currBuffp[0], imdata, currImgWidth*currImgHeight*sizeof(uchar)); dontFreeBuffers = false; // we _can_ free these buffers! } } } else { // the output image will not be grey-level anymore! // the raw data buffer has been freed, therefore datatype should be char if ((currPixType != IM_BINARY) && (currPixType != IM_UINT1) && (currPixType != IM_INT1)) { errprintf("Raw data not present, yet image is of type %d (%s): this is a bug\n", currPixType, typeName(currPixType)); retval = 1; } else { dbgprintf("Saving the old data to cuffBuffp AS COLOUR !\n"); if ((currBuffp = (void **)malloc(3*sizeof(void *))) == 0) { errprintf("saveToRawBuffers: not enough memory!\n"); retval = 2; } else if ((currBuffp[0] = (uchar *)malloc(currImgWidth*currImgHeight*sizeof(uchar))) == 0) { free(currBuffp); currBuffp = 0; errprintf("saveToRawBuffers: not enough memory for first component!\n"); retval = 3; } else if ((currBuffp[1] = (uchar *)malloc(currImgWidth*currImgHeight*sizeof(uchar))) == 0) { free(currBuffp[0]); free(currBuffp); currBuffp = 0; errprintf("saveToRawBuffers: not enough memory for second component!\n"); retval = 3; } else if ((currBuffp[2] = (uchar *)malloc(currImgWidth*currImgHeight*sizeof(uchar))) == 0) { free(currBuffp[1]); free(currBuffp[0]); free(currBuffp); currBuffp = 0; errprintf("saveToRawBuffers: not enough memory for third component!\n"); retval = 3; } else { memcpy(currBuffp[0], imdata, currImgWidth*currImgHeight*sizeof(uchar)); memcpy(currBuffp[1], imdata, currImgWidth*currImgHeight*sizeof(uchar)); memcpy(currBuffp[2], imdata, currImgWidth*currImgHeight*sizeof(uchar)); imspp = 3; currImgNbSamples = 3; dontFreeBuffers = false; // these buffers _can_ be freed } } } } else if (imspp == 3) { // the raw data buffer has been freed, therefore datatype should be char if ((currPixType != IM_BINARY) && (currPixType != IM_UINT1) && (currPixType != IM_INT1)) { errprintf("Raw data not present, yet image is of type %d (%s): this is a bug\n", currPixType, typeName(currPixType)); retval = 1; } else { dbgprintf("Saving the old data to currBuffp\n"); if ((currBuffp = (void **)malloc(3*sizeof(void *))) == 0) { errprintf("saveToRawBuffers: not enough memory!\n"); retval = 2; } else if ((currBuffp[0] = (uchar *)malloc(currImgWidth*currImgHeight*sizeof(uchar))) == 0) { free(currBuffp); currBuffp = 0; errprintf("saveToRawBuffers: not enough memory for first component!\n"); retval = 3; } else if ((currBuffp[1] = (uchar *)malloc(currImgWidth*currImgHeight*sizeof(uchar))) == 0) { free(currBuffp[0]); free(currBuffp); currBuffp = 0; errprintf("saveToRawBuffers: not enough memory for second component!\n"); retval = 3; } else if ((currBuffp[2] = (uchar *)malloc(currImgWidth*currImgHeight*sizeof(uchar))) == 0) { free(currBuffp[1]); free(currBuffp[0]); free(currBuffp); currBuffp = 0; errprintf("saveToRawBuffers: not enough memory for third component!\n"); retval = 3; } else { int i, j; uchar *p = imdata; // actually saving the data for (i = 0, j = 0 ; i < currImgWidth*currImgHeight ; i++) { ((uchar *)currBuffp[0])[j] = *p++; ((uchar *)currBuffp[1])[j] = *p++; ((uchar *)currBuffp[2])[j] = *p++; ++j; } dontFreeBuffers = false; // these buffers _can_ be freed } } } } // if (currBuffp == 0) ... : else nothing to do. return retval; } // this function saves the gamma parameters so we // can call the `applyGamma' function without needing // to know them. Pretty obvious stuff. void imageIO::saveGammaParameters(double *x0, double *y0, double *x1, double *y1, double *gammas, uchar *Rmap, uchar *Gmap, uchar *Bmap) { int i; for (i = 0 ; i < 3 ; i++) { mx0[i] = x0[i]; my0[i] = y0[i]; mx1[i] = x1[i]; my1[i] = y1[i]; mgammas[i] = gammas[i]; } if (Gmap && Bmap) { for (i = 0 ; i < 256 ; i++) { mRmap[i] = Rmap[i]; mGmap[i] = Gmap[i]; mBmap[i] = Bmap[i]; } hasGmap = true; } else { for (i = 0 ; i < 256 ; i++) mRmap[i] = Rmap[i]; hasGmap = false; } return; } // This function is the same as the next one. // It only applies a gamma that has been saved before. int imageIO::applyGammaToCurrentImage(void) { if (mgammas[0] != -1.0) { // there is a gamma to worry about // relay the call if (hasGmap) return applyGammaToCurrentImage(mx0, my0, mx1, my1, mgammas, mRmap, mGmap, mBmap); else return applyGammaToCurrentImage(mx0, my0, mx1, my1, mgammas, mRmap, 0, 0); } else { // just make up a new imdata with correct data in translateForDisplay(); } return 0; } int imageIO::applyGammaToCurrentImage(double *x0, double *y0, double *x1, double *y1, double *gammas, uchar *Rmap, uchar *Gmap, uchar *Bmap) { int retval = 0; uchar *olddata; int olddepth, newdepth; // fill up the return data as best we can olddata = imdata; olddepth = imspp; currImgHasGamma = false; dbgprintf("Applying transfer function (gamma) transform to current image\n"); if ( (Gmap == 0) || (Bmap == 0)) { saveToRawBuffers(true); // try to keep the image grey-level } else { saveToRawBuffers(false); // we have to assume the 3 maps will be different, and the output will be RGB } // after this very complicated point, saveGammaParameters(x0, y0, x1, y1, gammas, Rmap, Gmap, Bmap); // a new currBuffp may just have been allocated... if ((currBuffp != 0) && (currBuffp[0] != 0)) { dbgprintf("Current image is [%d]x[%d]x[%d]\n", currImgWidth, currImgHeight, currImgThickness); // read the CLUT in switch (currPixType) { case IM_BINARY: case IM_UINT1: case IM_INT1: dbgprintf("Current image is binary or char\n"); applyGamma_UINT1(&newdepth, &imdata, Rmap, Gmap, Bmap); currImgHasGamma = true; // current image is shown with colourmap break; #ifdef HAVE_MEMBER_TEMPLATES case IM_INT2: dbgprintf("Current image is short\n"); applyGamma(&newdepth, &imdata, x0, y0, x1, y1, gammas); currImgHasGamma = true; break; case IM_UINT2: dbgprintf("Current image is unsigned short\n"); applyGamma(&newdepth, &imdata, x0, y0, x1, y1, gammas); currImgHasGamma = true; break; case IM_INT4: dbgprintf("Current image is int\n"); applyGamma(&newdepth, &imdata, x0, y0, x1, y1, gammas); currImgHasGamma = true; break; case IM_UINT4: dbgprintf("Current image is unsigned int\n"); applyGamma(&newdepth, &imdata, x0, y0, x1, y1, gammas); currImgHasGamma = true; break; case IM_FLOAT: dbgprintf("Current image is float\n"); applyGamma(&newdepth, &imdata, x0, y0, x1, y1, gammas); currImgHasGamma = true; break; case IM_DOUBLE: dbgprintf("Current image is double\n"); applyGamma(&newdepth, &imdata, x0, y0, x1, y1, gammas); currImgHasGamma = true; break; default: errprintf("Gamma cannot currently be applied to type %d (%s)\n" "Complain to the developers, this is intolerable!", currPixType, typeName(currPixType)); retval = 5; break; #else // not HAVE_MEMBER_TEMPLATES case IM_INT4: case IM_UINT4: dbgprintf("Current image is int\n"); applyGamma_INT4(&newdepth, &imdata, x0, y0, x1, y1, gammas); currImgHasGamma = true; break; case IM_DOUBLE: dbgprintf("Current image is DOUBLE\n"); applyGamma_DBL(&newdepth, &imdata, x0, y0, x1, y1, gammas); currImgHasGamma = true; break; default: static bool warnOnce = false; if (!warnOnce) { errprintf("Gamma cannot currently be applied to type %d (%s)\n" "because this version of Imview was not compiled with\n" "an ISO C++ compliant compiler, contact the developers\n" "with your platform details!", currPixType, typeName(currPixType)); warnOnce = true; } retval = 5; break; #endif } } else { if (currBuffp) { errprintf("Pointer to raw data lost: this is a bug\n"); retval = 6; } } if (imdata != 0 && imdata != olddata) { dbgprintf("A new buffer was allocated, destroying the old imdata\n"); delete[] olddata; //delete[] overlay; imspp = newdepth; //overlay = 0; olddata = 0; } else { dbgprintf("Something went wrong or imdata was recycled, keeping it\n"); imdata = olddata; imspp = olddepth; } // this is EXPERIMENTAL // applyCurrentCLUT(); // if present... return retval; } // we have a special function for the UINT1 case, because we stretch from 0 to 255, // not from \val to maxval, as is the case for all the other data types, // also the UINT1 case is by far the most common, and this function is faster than // the general case. void imageIO::applyGamma_UINT1(int *imDepth, uchar **outbuf, uchar *Rmap, uchar *Gmap, uchar *Bmap) { uchar *p, *q, *end; uchar *qR, *qG, *qB; int newDepth; dbgprintf("Applying gamma to UINT1 image\n"); if (currImgNbSamples == 3) { dbgprintf("Image with 3 samples, treating as RGB\n"); newDepth = 3; // allocate new memory dbgprintf("Allocating a new buffer\n"); *outbuf = new uchar[3*currImgWidth*currImgHeight]; p = *outbuf; end = *outbuf + 3*currImgWidth * currImgHeight; qR = (uchar *)(currBuffp[0]) + buffZOffset; qG = (uchar *)(currBuffp[1]) + buffZOffset; qB = (uchar *)(currBuffp[2]) + buffZOffset; // we assume that Rmap is not null! assert(Rmap != 0); if ((Gmap != 0) && (Bmap != 0)) { while (p < end) { *p++ = Rmap[*qR++]; *p++ = Gmap[*qG++]; *p++ = Bmap[*qB++]; } } else { // we apply the same first map to everybody while (p < end) { *p++ = Rmap[*qR++]; *p++ = Rmap[*qG++]; *p++ = Rmap[*qB++]; } } } else { dbgprintf("Image with %d samples, processing sample %d\n", currImgNbSamples, currComp); newDepth = 1; dbgprintf("Allocating a new buffer\n"); *outbuf = new uchar[currImgWidth*currImgHeight]; p = *outbuf; end = *outbuf + currImgWidth * currImgHeight; q = (uchar *)(currBuffp[currComp]) + buffZOffset; // only the first map is relevant assert(Rmap != 0); while (p < end) { *p++ = Rmap[*q++]; } } // only now change *imDepth, because it often points to imspp! *imDepth = newDepth; return; } #ifdef HAVE_MEMBER_TEMPLATES #ifdef HAVE_TEMPLATE_KEYWORD_QUALIFIER template void imageIO::applyGamma(int *imDepth, uchar **outbuf, double *startX, double *startY, double *endX, double *endY, double *gamma) #else template void imageIO::applyGamma(int *imDepth, uchar **outbuf, double *startX, double *startY, double *endX, double *endY, double *gamma, T dummy) #endif { uchar *p, h0; int i, newDepth; T *q, *iend; T minval, maxval; T lowthresh, highthresh; double w0, w1; dbgprintf("Applying gamma to image with data size: %d\n", sizeof(T)); if (currImgNbSamples == 3) { dbgprintf("Image with 3 samples, treating as RGB\n"); newDepth = 3; dbgprintf("Allocating a new buffer\n"); *outbuf = new uchar[3*currImgWidth*currImgHeight]; // find global min and max now. minval = *((T *)(currBuffp[0]) + buffZOffset); maxval = minval; for (i = 0 ; i < 3 ; i++) { q = (T *)(currBuffp[i]) + buffZOffset; iend = q + currImgWidth * currImgHeight; while (q < iend) { if (*q < minval) minval = *q; if (*q > maxval) maxval = *q; ++q; } } // apply tranformation // negative or positive contrast? for (i = 0 ; i < 3 ; i++) { if (startY[i] > endY[i]) { // negative h0 = (uchar)(255 * (startY[i] - endY[i])); w0 = (maxval-minval); lowthresh = (T)(minval + w0 * startX[i]); highthresh = (T)(minval + w0 * endX[i]); w1 = highthresh - lowthresh; q = (T *)(currBuffp[i]) + buffZOffset; iend = q + currImgWidth * currImgHeight; p = *outbuf + i; while (q < iend) { if (*q <= lowthresh) { *p = 255; } else if (*q >= highthresh) { *p = 0; } else { *p = (uchar)(startY[i]*255 - h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[i])); } ++q; p += 3; } } else { // positive h0 = (uchar)(255 * (endY[i] - startY[i])); w0 = (maxval-minval); lowthresh = (T)(minval + w0 * startX[i]); highthresh = (T)(minval + w0 * endX[i]); w1 = highthresh - lowthresh; q = (T *)(currBuffp[i]) + buffZOffset; iend = q + currImgWidth * currImgHeight; p = *outbuf + i; while (q < iend) { if (*q <= lowthresh) { *p = 0; } else if (*q >= highthresh) { *p = 255; } else { *p = (uchar)(startY[i]*255 + h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[i])); } ++q; p += 3; } } } } else { dbgprintf("Image with %d samples, processing sample %d\n", currImgNbSamples, currComp); newDepth = 1; dbgprintf("Allocating a new buffer\n"); *outbuf = new uchar[currImgWidth*currImgHeight]; // find global min and max now. minval = *((T *)(currBuffp[currComp]) + buffZOffset); maxval = minval; q = (T *)(currBuffp[currComp]) + buffZOffset; iend = q + currImgWidth * currImgHeight; // only the red-channel transform is relevant while (q < iend) { if (*q < minval) minval = *q; if (*q > maxval) maxval = *q; ++q; } dbgprintf("Found minimum = %d, maximum = %d\n", minval, maxval); // apply tranformation // negative or positive contrast? if (startY[0] > endY[0]) { // negative h0 = (uchar)(255 * (startY[0] - endY[0])); w0 = (maxval-minval); lowthresh = (T)(minval + w0 * startX[0]); highthresh = (T)(minval + w0 * endX[0]); w1 = highthresh - lowthresh; q = (T *)(currBuffp[currComp]) + buffZOffset; iend = q + currImgWidth * currImgHeight; p = *outbuf; while (q < iend) { if (*q <= lowthresh) { *p = 255; } else if (*q >= highthresh) { *p = 0; } else { *p = (uchar)(startY[0]*255 - h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[0])); } ++q; ++p; } } else { // positive h0 = (uchar)(255 * (endY[0] - startY[0])); w0 = (maxval-minval); lowthresh = (T)(minval + w0 * startX[0]); highthresh = (T)(minval + w0 * endX[0]); w1 = highthresh - lowthresh; q = (T *)(currBuffp[currComp]) + buffZOffset; iend = q + currImgWidth * currImgHeight; p = *outbuf; while (q < iend) { if (*q <= lowthresh) { *p = 0; } else if (*q >= highthresh) { *p = 255; } else { *p = (uchar)(startY[0]*255 + h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[0])); } ++q; ++p; } } } // only now update *imDepth, which often points to imspp! *imDepth = newDepth; return; } #else // not HAVE_MEMBER_TEMPLATES // I'm doing this because USHORT is actually important for // SPOT, and MSVC++ 6.0 does not have enough template // support. void imageIO::applyGamma_UINT2(int *imDepth, uchar **outbuf, double *startX, double *startY, double *endX, double *endY, double *gamma) { uchar *p, h0; int i; ushort *q, *dend; ushort minval, maxval; ushort lowthresh, highthresh, w0, w1; int newDepth; dbgprintf("Applying gamma to USHORT image\n"); if (currImgNbSamples == 3) { dbgprintf("Image with 3 samples, treating as RGB\n"); newDepth = 3; dbgprintf("Allocating a new buffer\n"); *outbuf = new uchar[3*currImgWidth*currImgHeight]; // find global min and max now. minval = USHRT_MAX; maxval = 0; // yes we know that for (i = 0 ; i < 3 ; i++) { q = (ushort *)(currBuffp[i]) + buffZOffset; dend = q + currImgWidth * currImgHeight; while (q < dend) { if (*q < minval) minval = *q; if (*q > maxval) maxval = *q; ++q; } } // apply tranformation // negative or positive contrast? for (i = 0 ; i < 3 ; i++) { if (startY[i] > endY[i]) { // negative h0 = (uchar)(255 * (startY[i] - endY[i])); w0 = (maxval-minval); lowthresh = minval + w0 * startX[i]; highthresh = minval + w0 * endX[i]; w1 = highthresh - lowthresh; q = (ushort *)(currBuffp[i]) + buffZOffset; dend = q + currImgWidth * currImgHeight; p = *outbuf + i; while (q < dend) { if (*q <= lowthresh) { *p = 255; } else if (*q >= highthresh) { *p = 0; } else { *p = (uchar)(startY[i]*255 - h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[i])); } ++q; p += 3; } } else { // positive h0 = (uchar)(255 * (endY[i] - startY[i])); w0 = (maxval-minval); lowthresh = minval + w0 * startX[i]; highthresh = minval + w0 * endX[i]; w1 = highthresh - lowthresh; q = (ushort *)(currBuffp[i]) + buffZOffset; dend = q + currImgWidth * currImgHeight; p = *outbuf + i; while (q < dend) { if (*q <= lowthresh) { *p = 0; } else if (*q >= highthresh) { *p = 255; } else { *p = (uchar)(startY[i]*255 + h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[i])); } ++q; p += 3; } } } } else { dbgprintf("Image with %d samples, processing sample %d\n", currImgNbSamples, currComp); newDepth = 1; dbgprintf("Allocating a new buffer\n"); *outbuf = new uchar[currImgWidth*currImgHeight]; // find global min and max now. minval = USHRT_MAX; maxval = 0; q = (ushort *)(currBuffp[currComp]) + buffZOffset; dend = q + currImgWidth * currImgHeight; // only the red-channel transform is relevant while (q < dend) { if (*q < minval) minval = *q; if (*q > maxval) maxval = *q; ++q; } // apply tranformation // negative or positive contrast? if (startY[0] > endY[0]) { // negative h0 = (uchar)(255 * (startY[0] - endY[0])); w0 = (maxval-minval); lowthresh = minval + w0 * startX[0]; highthresh = minval + w0 * endX[0]; w1 = highthresh - lowthresh; q = (ushort *)(currBuffp[currComp]) + buffZOffset; dend = q + currImgWidth * currImgHeight; p = *outbuf; while (q < dend) { if (*q <= lowthresh) { *p = 255; } else if (*q >= highthresh) { *p = 0; } else { *p = (uchar)(startY[0]*255 - h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[0])); } ++q; ++p; } } else { // positive h0 = (uchar)(255 * (endY[0] - startY[0])); w0 = (maxval-minval); lowthresh = minval + w0 * startX[0]; highthresh = minval + w0 * endX[0]; w1 = highthresh - lowthresh; q = (ushort *)(currBuffp[currComp]) + buffZOffset; dend = q + currImgWidth * currImgHeight; p = *outbuf; while (q < dend) { if (*q <= lowthresh) { *p = 0; } else if (*q >= highthresh) { *p = 255; } else { *p = (uchar)(startY[0]*255 + h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[0])); } ++q; ++p; } } } // only now update *imDepth, as it points to imspp most of the time *imDepth = newDepth; return; } // // No loss of precision here, as far as we can avoid it. // Hugues Talbot 27 Jun 1999 void imageIO::applyGamma_INT4(int *imDepth, uchar **outbuf, double *startX, double *startY, double *endX, double *endY, double *gamma) { uchar *p, h0; int *q, *iend; int minval, maxval, i; int lowthresh, highthresh, w0, w1; int newDepth; dbgprintf("Applying gamma to INT4 image\n"); if (currImgNbSamples == 3) { dbgprintf("Image with 3 samples, treating as RGB\n"); newDepth = 3; dbgprintf("Allocating a new buffer\n"); *outbuf = new uchar[3*currImgWidth*currImgHeight]; // find global min and max now. minval = INT_MAX; maxval = INT_MIN; for (i = 0 ; i < 3 ; i++) { q = (int *)(currBuffp[i]) + buffZOffset; iend = q + currImgWidth * currImgHeight; while (q < iend) { if (*q < minval) minval = *q; if (*q > maxval) maxval = *q; ++q; } } // apply tranformation // negative or positive contrast? for (i = 0 ; i < 3 ; i++) { if (startY[i] > endY[i]) { // negative h0 = (uchar)(255 * (startY[i] - endY[i])); w0 = (maxval-minval); lowthresh = (int)(minval + w0 * startX[i]); highthresh = (int)(minval + w0 * endX[i]); w1 = highthresh - lowthresh; q = (int *)(currBuffp[i]) + buffZOffset; iend = q + currImgWidth * currImgHeight; p = *outbuf + i; while (q < iend) { if (*q <= lowthresh) { *p = 255; } else if (*q >= highthresh) { *p = 0; } else { *p = (uchar)(startY[i]*255 - h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[i])); } ++q; p += 3; } } else { // positive h0 = (uchar)(255 * (endY[i] - startY[i])); w0 = (maxval-minval); lowthresh = (int)(minval + w0 * startX[i]); highthresh = (int)(minval + w0 * endX[i]); w1 = highthresh - lowthresh; q = (int *)(currBuffp[i]) + buffZOffset; iend = q + currImgWidth * currImgHeight; p = *outbuf + i; while (q < iend) { if (*q <= lowthresh) { *p = 0; } else if (*q >= highthresh) { *p = 255; } else { *p = (uchar)(startY[i]*255 + h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[i])); } ++q; p += 3; } } } } else { dbgprintf("Image with %d samples, processing sample %d\n", currImgNbSamples, currComp); newDepth = 1; dbgprintf("Allocating a new buffer\n"); *outbuf = new uchar[currImgWidth*currImgHeight]; // find global min and max now. minval = INT_MAX; maxval = INT_MIN; q = (int *)(currBuffp[currComp]) + buffZOffset; iend = q + currImgWidth * currImgHeight; // only the red-channel transform is relevant while (q < iend) { if (*q < minval) minval = *q; if (*q > maxval) maxval = *q; ++q; } // apply tranformation // negative or positive contrast? if (startY[0] > endY[0]) { // negative h0 = (uchar)(255 * (startY[0] - endY[0])); w0 = (maxval-minval); lowthresh = (int)(minval + w0 * startX[0]); highthresh = (int)(minval + w0 * endX[0]); w1 = highthresh - lowthresh; q = (int *)(currBuffp[currComp]) + buffZOffset; iend = q + currImgWidth * currImgHeight; p = *outbuf; while (q < iend) { if (*q <= lowthresh) { *p = 255; } else if (*q >= highthresh) { *p = 0; } else { *p = (uchar)(startY[0]*255 - h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[0])); } ++q; ++p; } } else { // positive h0 = (uchar)(255 * (endY[0] - startY[0])); w0 = (maxval-minval); lowthresh = (int)(minval + w0 * startX[0]); highthresh = (int)(minval + w0 * endX[0]); w1 = highthresh - lowthresh; q = (int *)(currBuffp[currComp]) + buffZOffset; iend = q + currImgWidth * currImgHeight; p = *outbuf; while (q < iend) { if (*q <= lowthresh) { *p = 0; } else if (*q >= highthresh) { *p = 255; } else { *p = (uchar)(startY[0]*255 + h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[0])); } ++q; ++p; } } } // only now update *imDepth, which often points to imspp! *imDepth = newDepth; return; } // // No loss of precision here, as far as we can avoid it. // Hugues Talbot 27 Jun 1999 void imageIO::applyGamma_DBL(int *imDepth, uchar **outbuf, double *startX, double *startY, double *endX, double *endY, double *gamma) { uchar *p, h0; int i; double *q, *dend; double minval, maxval; double lowthresh, highthresh, w0, w1; int newDepth; dbgprintf("Applying gamma to DOUBLE image\n"); if (currImgNbSamples == 3) { dbgprintf("Image with 3 samples, treating as RGB\n"); newDepth = 3; dbgprintf("Allocating a new buffer\n"); *outbuf = new uchar[3*currImgWidth*currImgHeight]; // find global min and max now. minval = DBL_MAX; maxval = DBL_MIN; for (i = 0 ; i < 3 ; i++) { q = (double *)(currBuffp[i]) + buffZOffset; dend = q + currImgWidth * currImgHeight; while (q < dend) { if (*q < minval) minval = *q; if (*q > maxval) maxval = *q; ++q; } } // apply tranformation // negative or positive contrast? for (i = 0 ; i < 3 ; i++) { if (startY[i] > endY[i]) { // negative h0 = (uchar)(255 * (startY[i] - endY[i])); w0 = (maxval-minval); lowthresh = minval + w0 * startX[i]; highthresh = minval + w0 * endX[i]; w1 = highthresh - lowthresh; q = (double *)(currBuffp[i]) + buffZOffset; dend = q + currImgWidth * currImgHeight; p = *outbuf + i; while (q < dend) { if (*q <= lowthresh) { *p = 255; } else if (*q >= highthresh) { *p = 0; } else { *p = (uchar)(startY[i]*255 - h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[i])); } ++q; p += 3; } } else { // positive h0 = (uchar)(255 * (endY[i] - startY[i])); w0 = (maxval-minval); lowthresh = minval + w0 * startX[i]; highthresh = minval + w0 * endX[i]; w1 = highthresh - lowthresh; q = (double *)(currBuffp[i]) + buffZOffset; dend = q + currImgWidth * currImgHeight; p = *outbuf + i; while (q < dend) { if (*q <= lowthresh) { *p = 0; } else if (*q >= highthresh) { *p = 255; } else { *p = (uchar)(startY[i]*255 + h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[i])); } ++q; p += 3; } } } } else { dbgprintf("Image with %d samples, processing sample %d\n", currImgNbSamples, currComp); newDepth = 1; dbgprintf("Allocating a new buffer\n"); *outbuf = new uchar[currImgWidth*currImgHeight]; // find global min and max now. minval = DBL_MAX; maxval = DBL_MIN; q = (double *)(currBuffp[currComp]) + buffZOffset; dend = q + currImgWidth * currImgHeight; // only the red-channel transform is relevant while (q < dend) { if (*q < minval) minval = *q; if (*q > maxval) maxval = *q; ++q; } // apply tranformation // negative or positive contrast? if (startY[0] > endY[0]) { // negative h0 = (uchar)(255 * (startY[0] - endY[0])); w0 = (maxval-minval); lowthresh = minval + w0 * startX[0]; highthresh = minval + w0 * endX[0]; w1 = highthresh - lowthresh; q = (double *)(currBuffp[currComp]) + buffZOffset; dend = q + currImgWidth * currImgHeight; p = *outbuf; while (q < dend) { if (*q <= lowthresh) { *p = 255; } else if (*q >= highthresh) { *p = 0; } else { *p = (uchar)(startY[0]*255 - h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[0])); } ++q; ++p; } } else { // positive h0 = (uchar)(255 * (endY[0] - startY[0])); w0 = (maxval-minval); lowthresh = minval + w0 * startX[0]; highthresh = minval + w0 * endX[0]; w1 = highthresh - lowthresh; q = (double *)(currBuffp[currComp]) + buffZOffset; dend = q + currImgWidth * currImgHeight; p = *outbuf; while (q < dend) { if (*q <= lowthresh) { *p = 0; } else if (*q >= highthresh) { *p = 255; } else { *p = (uchar)(startY[0]*255 + h0*pow(((double)(*q)-lowthresh)/w1,1/gamma[0])); } ++q; ++p; } } } // only now update *imDepth, as it points to imspp most of the time *imDepth = newDepth; return; } #endif // HAVE_MEMBER_TEMPLATES // place buffer in overlay void imageIO::setOverlay(uchar *buf) { if (overlay) { delete[] overlay; } overlay = buf; // already allocated with right dimensions, etc } // extremely simple int imageIO::setPixelInOverlay(int index, uchar value) { int retval = 0; if (!overlay) { overlay = new uchar[currImgWidth * currImgHeight]; ovlspp = 1; memset(overlay, 0, currImgWidth * currImgHeight * sizeof(uchar)); } // array bounds check if (index < currImgWidth*currImgHeight) overlay[index] = value; return retval; } // this is REALLY quick and dirty int imageIO::applyOverlayToCurrentImage(void) { int retval = 0; uchar *newbuf, *p, *q, *r, *end; double ovl_transparency = fileprefs->overlayTransparency(); assert((currZpos >= 0) && (currZpos < currImgThickness)); if (overlay && imdata) { dbgprintf("Applying overlay to current image\n"); if (currBuffp != 0) { dbgprintf("NOT re-translating for display\n"); //translateForDisplay(true); // keep the overlay, retrieve original data into imdata } else { dbgprintf("Saving data to raw buffers\n"); saveToRawBuffers(true); // so that the image data is always available } if (ovlspp == 1) { if (imspp != 3) { // we'll have to make it colour newbuf = new uchar[3*currImgWidth*currImgHeight]; p = imdata; q = newbuf; r = overlay + currZpos * currImgWidth * currImgHeight; end = q + 3*currImgWidth * currImgHeight; /* this will ensure we can safely apply the colour overlay */ assert(MAX_FL_COLOURS > 255); if (ovl_transparency == 0.0) { while (q != end) { *q++ = FL_COLOURS[*r][0]; *q++ = FL_COLOURS[*r][1]; *q++ = FL_COLOURS[*r][2]; p++; r++; } } else { // more expensive calculation while (q != end) { *q++ = (uchar)(FL_COLOURS[*r][0] + (*p - FL_COLOURS[*r][0]) * ovl_transparency); *q++ = (uchar)(FL_COLOURS[*r][1] + (*p - FL_COLOURS[*r][1]) * ovl_transparency); *q++ = (uchar)(FL_COLOURS[*r][2] + (*p - FL_COLOURS[*r][2]) * ovl_transparency); p++; r++; } } delete[] imdata; imdata = newbuf; imspp = 3; } else { q = imdata; r = overlay + currZpos * currImgWidth * currImgHeight; end = q + 3*currImgWidth * currImgHeight; if (ovl_transparency == 0.0) { while (q != end) { *q++ = FL_COLOURS[*r][0]; *q++ = FL_COLOURS[*r][1]; *q++ = FL_COLOURS[*r][2]; r++; } } else { while (q != end) { *q = (uchar)(FL_COLOURS[*r][0] + (*q - FL_COLOURS[*r][0]) * ovl_transparency); q++; *q = (uchar)(FL_COLOURS[*r][1] + (*q - FL_COLOURS[*r][1]) * ovl_transparency); q++; *q = (uchar)(FL_COLOURS[*r][2] + (*q - FL_COLOURS[*r][2]) * ovl_transparency); q++; r++; } } } } else { // ovlspp == 3 if (imspp != 3) { // we'll have to make it colour newbuf = new uchar[3*currImgWidth*currImgHeight]; p = imdata; q = newbuf; r = overlay; end = q + 3*currImgWidth * currImgHeight; if (ovl_transparency == 0.0) { // very simple and very fast memcpy(newbuf, overlay, 3 * currImgWidth * currImgHeight); } else { // more expensive calculation while (q != end) { *q = (uchar)(*r + (*p - *r) * ovl_transparency); ++q; ++r; *q = (uchar)(*r + (*p - *r) * ovl_transparency); ++q; ++r; *q = (uchar)(*r + (*p - *r) * ovl_transparency); ++q; ++r; ++p; } } delete[] imdata; imdata = newbuf; imspp = 3; } else { // just overwrite imdata q = imdata; r = overlay; end = q + 3*currImgWidth * currImgHeight; if (ovl_transparency == 0.0) { // simple memcpy(imdata, overlay, 3 * currImgWidth * currImgHeight); } else { while (q != end) { *q = (uchar)(*r + (*q - *r) * ovl_transparency); ++q; ++r; } } } } } else { dbgprintf("Apply overlay: nothing to do\n"); } return retval; } char *imageIO::getClutNameIfPresent(const char *imageName) { static char clutpath[1024]; //char *p; char *retval = 0; dbgprintf("Checking for the present of a CLUT in the current directory\n"); // the `./' is needed otherwise CLUT in the current directory will show up // twice in the CLUT list (as myclut.lut and ./myclut.lut)... sprintf(clutpath, "./%s", imageName); /* Uncomment this for IMAGE and correspongind LUT combinations like: image_z --> image.lut, image.tiff --> image.tiff.lut if ((p = strrchr(clutpath, '_')) == 0) { dbgprintf("No underscore in %s\n", clutpath); strcat(clutpath, ".lut"); } else { dbgprintf(".lut substituted to %s\n", p); strcpy(p, ".lut"); } */ /* This is for IMAGE and corresponding LUT combinations like: image_z --> image_z.lut, image.pgm --> image.pgm.lut Note the code above (commented out). */ strcat(clutpath, ".lut"); // clutpath now ends sensibly in .lut dbgprintf("Checking for %s\n", clutpath); if (access(clutpath, R_OK) == 0) { retval = clutpath; } return retval; } // check if a CLUT can be associated with the given image int imageIO::checkForClut(const char *clutName, const char *imageName, uchar theCLUT[][256]) { static char clutpath[1024]; char *p; FILE *clutf = 0; int clutExists = 0; int i, rollover, r, g, b; dbgprintf("Checking for CLUT presence\n"); if (clutName == 0) { // no a-priori path to a CLUT given: look in the present directory if ((p = getClutNameIfPresent(imageName)) != 0) { strcpy(clutpath, p); clutExists = 1; } } else { // the name of a CLUT was given: use it! // first look in the given path strcpy(clutpath, clutName); if (((p = strrchr(clutpath, '.')) == 0) || (strcmp(p, ".lut") != 0)) // name doesn't end in .lut strcat(clutpath, ".lut"); // try to open the clut in the given directory dbgprintf("Checking for %s\n", clutpath); if (access(clutpath, R_OK) == 0) { clutExists = 1; } } if (clutExists && (theCLUT != 0)) { if ((clutf = fopen(clutpath, "rb")) != 0) { for (i = 0 ; i < 256 ; i++) { if (fscanf(clutf, "%i %i %i\n", &r, &g, &b) != 3) break; else { theCLUT[0][i] = (uchar)r; theCLUT[1][i] = (uchar)g; theCLUT[2][i] = (uchar)b; } } // complete the LUT (in a periodical way) for (rollover = i; i < 256 ; i++) { theCLUT[0][i] = theCLUT[0][i-rollover]; theCLUT[1][i] = theCLUT[1][i-rollover]; theCLUT[2][i] = theCLUT[2][i-rollover]; } fclose(clutf); } else { // the CLUT exists but we can't read it! clutExists = 0; } } return clutExists; } void imageIO::setImData(unsigned char *p) { if (p != 0) { if (currBuffp != 0) freeCurrentBuffers(); if (imdata != 0) { delete[] imdata; } if (overlay) { delete[] overlay; overlay = 0; } imdata = p; } } // this function applies display parameters // specific to a saved image, such as colourmap, etc. // NOTICE: here the clutname parameter is an OUTPUT parameter void imageIO::applyImageParameters(IMAGEPARM *p, const char *imname, char *clutname, bool keepGamma) { int hasCLUT; static char keeptitle[DFLTSTRLEN+1], title[DFLTSTRLEN+1], tmpbuff[DFLTSTRLEN+1]; static char bckupname[DFLTSTRLEN+1]; const char *drvdclut; if (p == 0) { p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p == 0) // no image loaded return; } if (clutname == 0) clutname = bckupname; // if image is 3-D, worry about current slice if (p->zslice < 0) p->zslice = 0; if (p->zslice >= currImgThickness) p->zslice = currImgThickness - 1; currZpos = p->zslice; buffZOffset = currZpos * (currImgWidth*currImgHeight); // if image is multisample, worry about current sample if (p->comp < 0) p->comp = 0; if (p->comp >= currImgNbSamples) p->comp = currImgNbSamples - 1; currComp = p->comp; // work out if a CLUT is present for this image hasCLUT = 0; if ((p != 0) && (p->clutpath != 0)) { strncpy(clutname, p->clutpath, DFLTSTRLEN); hasCLUT = 1; } else if ((imname != 0) && (drvdclut = getClutNameIfPresent(imname)) != 0) { strncpy(clutname, drvdclut, DFLTSTRLEN); hasCLUT = 1; } else { // A CLUT-less image musn't get associated with a CLUT. clutname[0] = '\0'; currImgHasCLUT = false; // this much we are sure of currImgCLUTPath = 0; } if (keepGamma || applyTransferToAll) applyGammaToCurrentImage(); // apply predefined gamma if present else translateForDisplay(); // generate a new imdata if needed // CLUT now operates on imdata by default, so it has to be up to date if (hasCLUT) { applyCLUTtoCurrentImage((const char *)clutname); // specify that we always want to display the current image with // the chosen LUT in the future. if (p->clutpath != 0) free(p->clutpath); p->clutpath = strdup(clutname); // this should work. dbgprintf("Attaching clut %s to image%s\n", p->clutpath, p->itempath); } else { if (imname != 0) dbgprintf("No CLUT of any kind associated with image %s\n", imname); else dbgprintf("No CLUT of any kind associated with current image\n"); } // change the title of the main window if (imname != 0) { imName = imname; sprintf(keeptitle, "%s: %s", appName, imname); } strcpy(title, keeptitle); if ((currImgNbSamples != 1) && (currImgNbSamples != 3)) { sprintf(tmpbuff, " (%d<%d>)", currComp, currImgNbSamples); strcat(title, tmpbuff); } if (currImgThickness > 1) { sprintf(tmpbuff, " [%d<%d>]", currZpos, currImgThickness); strcat(title, tmpbuff); } if (currImgNbFrames > 1) { sprintf(tmpbuff, " {%d<%d>}", currFrame, currImgNbFrames); strcat(title, tmpbuff); } mainWindow->label(title); if (overlay) applyOverlayToCurrentImage(); // put up coloured pixel on top of everything else... return; } // all the other translation functions void imageIO::convertUINT1withLUT(int *imDepth, uchar **outbuf, uchar CLUT[][256]) { uchar *p, *q, *end; dbgprintf("Pixel type is uchar, CLUT is present, %d samples present\n", currImgNbSamples); if (currImgNbSamples == 1) { dbgprintf("Expected number of samples: 1\n"); *imDepth = 3; *outbuf = new uchar[3*currImgWidth*currImgHeight]; p = *outbuf; end = *outbuf + 3*currImgWidth * currImgHeight; q = (uchar *)(currBuffp[0]) + buffZOffset; while (p < end) { *p++ = CLUT[0][*q]; *p++ = CLUT[1][*q]; *p++ = CLUT[2][*q]; q++; } } else { errprintf("Unexpected number of samples: %d\n", currImgNbSamples); } return; } // apply the LUT directly to imdata, this is safe here void imageIO::convertDirectLUT(int *imDepth, uchar **outbuf, uchar CLUT[][256]) { uchar *p, *q, *end; dbgprintf("Applying CLUT directly to internal 8 bit buffer\n"); if (imspp == 1) { dbgprintf("Expected number of samples: 1\n"); *imDepth = 3; *outbuf = new uchar[3*currImgWidth*currImgHeight]; p = *outbuf; end = *outbuf + 3*currImgWidth * currImgHeight; q = imdata; while (p < end) { *p++ = CLUT[0][*q]; *p++ = CLUT[1][*q]; *p++ = CLUT[2][*q]; q++; } } else { errprintf("Unexpected number of samples: %d\n", imspp); } return; } // there might be more than one strategy here... // for now we'll just do the wraparound thing. void imageIO::convertINT4withLUT_wraparound(int *imDepth, uchar **outbuf, uchar CLUT[][256]) { uchar *p, *end; int *q; dbgprintf("Pixel type is [U]INT, CLUT is present, %d samples present\n", currImgNbSamples); if (currImgNbSamples == 1) { dbgprintf("Expected number of samples: 1\n"); *imDepth = 3; *outbuf = new uchar[3*currImgWidth*currImgHeight]; p = *outbuf; end = *outbuf + 3*currImgWidth * currImgHeight; q = (int *)(currBuffp[0]) + buffZOffset; while (p < end) { *p++ = CLUT[0][*q % 256]; *p++ = CLUT[1][*q % 256]; *p++ = CLUT[2][*q % 256]; q++; } } else { errprintf("Unexpected number of samples: %d\n", currImgNbSamples); } return; } #ifdef HAVE_MEMBER_TEMPLATES // This is another possible strategy // doing the stretch before the LUT imposition # ifdef HAVE_TEMPLATE_KEYWORD_QUALIFIER template void imageIO::convertWithLUT_wraparound(int *imDepth, uchar **outbuf, void *CLUTp) # else template void imageIO::convertWithLUT_wraparound(int *imDepth, uchar **outbuf, void *CLUTp, T dummy) #endif { uchar *p, *end; T *q; uchar (*CLUT)[256]; #ifdef HAVE_TEMPLATE_CAST_ARRAY CLUT = (uchar (*)[256]) CLUTp; #else CLUT = CLUTp; // this will generate a nasty warning. Ignore #endif dbgprintf("Pixel type is arbitrary, of size %d, CLUT is present, %d samples present\n", sizeof(T), currImgNbSamples); *imDepth = 3; *outbuf = new uchar[3*currImgWidth*currImgHeight]; p = *outbuf; end = *outbuf + 3*currImgWidth * currImgHeight; q = (T *)(currBuffp[currComp]) + buffZOffset; while (p < end) { *p++ = CLUT[0][(int)(*q) % 256]; *p++ = CLUT[1][(int)(*q) % 256]; *p++ = CLUT[2][(int)(*q) % 256]; q++; } return; } #endif // HAVE_MEMBER_TEMPLATES void imageIO::convertBINARY(int *imDepth, uchar **outbuf) { uchar *p, *q, *end; dbgprintf("Pixel type is binary\n"); if (currImgNbSamples >= 1) { // nothing much to do: save first buffer to outbuff *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; p = *outbuf; q = (uchar *)(currBuffp[currComp]) + buffZOffset; end = p + currImgWidth * currImgHeight; while (p != end) *p++ = (*q++) ? 0 : 255; if ((currImgNbSamples == 1) && (currImgThickness == 1)) { // in this case only: get rid of the buffers. freeCurrentBuffers(); } else { dbgprintf("There are %d binary buffers in this image\n", currImgNbSamples); // keep buffers around: the user might want to see the other buffers ! } } else { errprintf("Incorrect file: %d sample!\n", currImgNbSamples); freeCurrentBuffers(); } return; } // the optional argument for freeBuffers is there because sometimes // we want to keep the raw buffer, for example when they serve as memory // when we keep re-applying the same transform. See applyOverlay for example void imageIO::convertUINT1(int *imDepth, uchar **outbuf, bool freeBuffers, bool interpretRGB) { uchar *p, *qR, *qG, *qB, *end; dbgprintf("Pixel type is uchar\n"); if (currImgNbSamples == 1) { // probably the simplest of all cases: *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; memcpy(*outbuf, (char *)(currBuffp[0]) + buffZOffset, currImgWidth * currImgHeight); if ((currImgThickness == 1) && freeBuffers) freeCurrentBuffers(); } else if (interpretRGB && (currImgNbSamples == 3)) { if (currImgType != IM_RGB) { // a somewhat unhelpfull debugging message dbgprintf("Interpreting image as RGB even though it isn't...\n"); } *imDepth = 3; *outbuf = new uchar[currImgNbSamples*currImgWidth*currImgHeight]; p = *outbuf; end = *outbuf + currImgNbSamples*currImgWidth * currImgHeight; qR = (uchar *)(currBuffp[0]) + buffZOffset; qG = (uchar *)(currBuffp[1]) + buffZOffset; qB = (uchar *)(currBuffp[2]) + buffZOffset; while (p != end) { *p++ = *qR++; *p++ = *qG++; *p++ = *qB++; } if ((currImgThickness == 1) && freeBuffers) freeCurrentBuffers(); } else if (currImgNbSamples > 0) { // display only the current sample *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; memcpy(*outbuf, (char *)(currBuffp[currComp]) + buffZOffset, currImgWidth * currImgHeight); dbgprintf("There are %d uchar buffers in this image\n", currImgNbSamples); // don't free the Buffers as we may need them... } else { errprintf("Incorrect file: %d sample!\n", currImgNbSamples); freeCurrentBuffers(); } return; } // template version of the convert function. Long overdue! // the freeBuffer option is for when this function is called from within applyOverlay via convertForDisplay // in that case the buffers should not be freed otherwise the overlay ends up polluting the original data. // The makeChar option is to tell the function not to bother about converting to a char images even if the data fits // in a char. This is indispensable for float and double images, also useful as an option to the user (it could // be confusing if the user expect INT data and imview keep telling him/her its really char... // the interpretRGB option is there to tell the convert program not to worry about interpreting non-RGB data as // RGB anyway (if it has exactly 3 spectra). Again this could be confusing to the user. // the minmaxAllSamples allows the fitchar effect to come into play either across all samples or just the one // being displayed // By default all these options are set to true. // Hugues Talbot 17 Feb 2001 #ifdef HAVE_MEMBER_TEMPLATES #ifdef HAVE_TEMPLATE_KEYWORD_QUALIFIER template void imageIO::convert(int *imDepth, uchar **outbuf, bool freeBuffers, bool makeChar, bool interpretRGB, bool minmaxAllSamples, bool minmaxAllSlices) #else template void imageIO::convert(int *imDepth, uchar **outbuf, bool freeBuffers,bool makeChar, bool interpretRGB, bool minmaxAllSamples, bool minmaxAllSlices, T dummy) #endif { T *p, *end, *pR, *pG, *pB; uchar *q, *endq; int i; T minval, maxval, nada = 0; // nada is == 0, this is to silence a warning in case T is unsigned dbgprintf("Pixel type size is %d\n", sizeof(T)); dbgprintf("min-max over all samples = %d ; min-max over all slices = %d\n", minmaxAllSamples, minmaxAllSlices); if (currImgNbSamples == 1) { *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; // adjust values if (minmaxAllSlices) { p = (T *)(currBuffp[0]); end = p + currImgWidth * currImgHeight * currImgThickness; } else { p = (T *)(currBuffp[0]) + buffZOffset; end = p + currImgWidth * currImgHeight; } if (minmaxAllSlices && minmax_iscached()) { dbgprintf("Using cached min/max values\n"); double cmin, cmax; minmax_get_cache(cmin, cmax); minval = static_cast(cmin); maxval = static_cast(cmax); } else { minval = maxval = *p++; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } dbgprintf("Store cache min/max\n"); double cmin = static_cast(minval); double cmax = static_cast(maxval); minmax_set_cache(cmin, cmax); } dbgprintf("Nbsamples = 1 ; min = %f , max = %f\n", (double)minval, (double)maxval); p = (T *)(currBuffp[0]) + buffZOffset; q = *outbuf; endq = q + currImgWidth * currImgHeight; if (makeChar && (minval >= nada) && (maxval <= 255)) { // this image fits in a char, just copy things through while (q < endq) { *q++ = (uchar)(*p++); } if ((currImgThickness == 1) && freeBuffers) { freeCurrentBuffers(); // really pretend that the image is char currPixType = IM_UINT1; } } else { if (maxval != minval) while (q < endq) { *q++ = (uchar)((((*p++) - minval) * 255)/(maxval-minval)); } else while (q < endq) { *q++ = 128; // middle of the range. } } } else if ((currImgNbSamples == 3) && interpretRGB) { if (currImgType != IM_RGB) { // a somewhat unhelpfull debugging message dbgprintf("Interpreting image as RGB even though it isn't...\n"); } *imDepth = 3; *outbuf = new uchar[currImgNbSamples*currImgWidth*currImgHeight]; if (minmaxAllSlices && minmax_iscached()) { double cmin, cmax; minmax_get_cache(cmin, cmax); minval = static_cast(cmin); maxval = static_cast(cmax); dbgprintf("Using cached values for min/max\n"); } else { if (minmaxAllSlices) { minval = maxval = *((T *)(currBuffp[0])); } else { minval = maxval = *((T *)(currBuffp[0]) + buffZOffset); } for (i = 0 ; i < currImgNbSamples ; i++) { if (minmaxAllSlices) { p = (T *)(currBuffp[i]) + buffZOffset; end = p + currImgWidth * currImgHeight; } else { p = (T *)(currBuffp[i]); end = p + currImgWidth * currImgHeight * currImgThickness; } while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } dbgprintf("caching min/max\n"); double cmin = static_cast(minval); double cmax = static_cast(maxval); minmax_set_cache(cmin, cmax); } dbgprintf("Nbsamples = 1 ; min = %f , max = %f\n", (double)minval, (double)maxval); pR = (T *)(currBuffp[0]) + buffZOffset; pG = (T *)(currBuffp[1]) + buffZOffset; pB = (T *)(currBuffp[2]) + buffZOffset; q = *outbuf; endq = q + currImgNbSamples*currImgWidth*currImgHeight; if (makeChar && (minval >= nada && maxval <= 255)) { // this image fits on a char: just copy things through while (q < endq) { *q++ = (uchar)(*pR++); *q++ = (uchar)(*pG++); *q++ = (uchar)(*pB++); } if (freeBuffers && (currImgThickness == 1)) { freeCurrentBuffers(); // really pretend that the image is char currPixType = IM_UINT1; } } else { if (maxval != minval) { // doesn't fit on a char: do a grey-level scaling while (q < endq) { *q++ = (uchar)((((*pR++) - minval) * 255)/(maxval-minval)); *q++ = (uchar)((((*pG++) - minval) * 255)/(maxval-minval)); *q++ = (uchar)((((*pB++) - minval) * 255)/(maxval-minval)); } } else { while (q < endq) { *q++ = 128; *q++ = 128; *q++ = 128; } } // don't free the buffers } } else if (currImgNbSamples > 0) { // display only the current sample *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; // adjust values if (minmaxAllSlices && minmax_iscached()) { double cmin, cmax; minmax_get_cache(cmin, cmax); minval = static_cast(cmin); maxval = static_cast(cmax); dbgprintf("Using cached values for min/max\n"); } else { if (minmaxAllSamples) { // take the min and max across all samples! if (minmaxAllSlices) { minval = maxval = *((T *)currBuffp[0]); // very first pixel value } else { // first pixel in current slice only minval = maxval = *(((T *)currBuffp[0]) + buffZOffset); } for (i = 0 ; i < currImgNbSamples ; i++) { if (minmaxAllSlices) { p = (T *)(currBuffp[i]); end = p + currImgWidth * currImgHeight * currImgThickness; } else { p = (T *)(currBuffp[i]) + buffZOffset; end = p + currImgWidth * currImgHeight; } while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } } else { if (minmaxAllSlices) { minval = maxval = *((T *)currBuffp[currComp]); p = (T *)(currBuffp[currComp]); end = p + currImgWidth * currImgHeight * currImgThickness; } else { minval = maxval = *(((T *)currBuffp[currComp]) + buffZOffset); p = (T *)(currBuffp[currComp]) + buffZOffset; end = p + currImgWidth * currImgHeight; } while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } dbgprintf("Caching min/max values\n"); double cmin = static_cast(minval); double cmax = static_cast(maxval); minmax_set_cache(cmin, cmax); } dbgprintf("Nbsamples = %d ; min = %f , max = %f\n", currImgNbSamples, (double)minval, (double)maxval); // just worry about the current sample for display p = (T *)(currBuffp[currComp]) + buffZOffset; q = *outbuf; endq = q + currImgWidth * currImgHeight; if (makeChar && (minval >= nada && maxval <= 255)) { // this image fits in a char, just copy things through while (q < endq) { *q++ = (uchar)(*p++); } if (freeBuffers && (currImgThickness == 1)) { freeCurrentBuffers(); // really pretend that the image is char currPixType = IM_UINT1; } } else { if (maxval != minval) while (q < endq) { *q++ = (uchar)((((*p++) - minval) * 255)/(maxval-minval)); } else while (q < endq) { *q++ = 128; // middle of the range. } } dbgprintf("There are %d uchar buffers in this image\n", currImgNbSamples); // don't free the Buffers as we may need them... } else { errprintf("Incorrect file: %d sample!\n", currImgNbSamples); freeCurrentBuffers(); } return; } #else // HAVE_MEMBER_TEMPLATES void imageIO::convertINT2(int *imDepth, uchar **outbuf) { short *p, *end, *pR, *pG, *pB; uchar *q, *endq; short minval, maxval, i; dbgprintf("Pixel type is int2 (short)\n"); if (currImgNbSamples == 1) { *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; // adjust values p = (short *)(currBuffp[0]) + buffZOffset; end = p + currImgWidth * currImgHeight; minval = maxval = *p++; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } p = (short *)(currBuffp[0]) + buffZOffset; q = *outbuf; endq = q + currImgWidth * currImgHeight; if (minval >= 0 && maxval <= 255) { // this `short' image fits in a char, just copy things through while (q < endq) { *q++ = (uchar)(*p++); } if (currImgThickness == 1) { freeCurrentBuffers(); // really pretend that the image is char currPixType = IM_UINT1; } } else { if (maxval != minval) while (q < endq) { *q++ = (uchar)((((long)(*p++) - minval) * 255)/(maxval-minval)); } else while (q < endq) { *q++ = 128; // middle of the range. } } } else if (currImgNbSamples == 3) { if (currImgType != IM_RGB) { // a somewhat unhelpfull debugging message dbgprintf("Interpreting image as RGB even though it isn't...\n"); } *imDepth = 3; *outbuf = new uchar[currImgNbSamples*currImgWidth*currImgHeight]; minval = maxval = *((short *)(currBuffp[0]) + buffZOffset); for (i = 0 ; i < currImgNbSamples ; i++) { p = (short *)(currBuffp[i]) + buffZOffset; end = p + currImgWidth * currImgHeight; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } pR = (short *)(currBuffp[0]) + buffZOffset; pG = (short *)(currBuffp[1]) + buffZOffset; pB = (short *)(currBuffp[2]) + buffZOffset; q = *outbuf; endq = q + currImgNbSamples*currImgWidth*currImgHeight; if (minval >= 0 && maxval <= 255) { // this image fits on a char: just copy things through while (q < endq) { *q++ = (uchar)(*pR++); *q++ = (uchar)(*pG++); *q++ = (uchar)(*pB++); } if (currImgThickness == 1) { freeCurrentBuffers(); // really pretend that the image is char currPixType = IM_UINT1; } } else { if (maxval != minval) { // doesn't fit on a char: do a grey-level scaling while (q < endq) { *q++ = (uchar)((((long)(*pR++) - minval) * 255)/(maxval-minval)); *q++ = (uchar)((((long)(*pG++) - minval) * 255)/(maxval-minval)); *q++ = (uchar)((((long)(*pB++) - minval) * 255)/(maxval-minval)); } } else { while (q < endq) { *q++ = 128; *q++ = 128; *q++ = 128; } } // don't free the buffers } } else if (currImgNbSamples > 0) { // display only the current sample *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; // adjust values minval = maxval = *(((short *)currBuffp[currComp]) + buffZOffset); // take the min and max across all samples! for (i = 0 ; i < currImgNbSamples ; i++) { p = (short *)(currBuffp[i]) + buffZOffset; end = p + currImgWidth * currImgHeight; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } p = (short *)(currBuffp[currComp]) + buffZOffset; q = *outbuf; endq = q + currImgWidth * currImgHeight; if (minval >= 0 && maxval <= 255) { // this `short' image fits in a char, just copy things through while (q < endq) { *q++ = (uchar)(*p++); } if (currImgThickness == 1) { freeCurrentBuffers(); // really pretend that the image is char currPixType = IM_UINT1; } } else { if (maxval != minval) while (q < endq) { *q++ = (uchar)((((long)(*p++) - minval) * 255)/(maxval-minval)); } else while (q < endq) { *q++ = 128; // middle of the range. } } dbgprintf("There are %d uchar buffers in this image\n", currImgNbSamples); // don't free the Buffers as we may need them... } else { errprintf("Incorrect file: %d sample!\n", currImgNbSamples); freeCurrentBuffers(); } return; } void imageIO::convertUINT2(int *imDepth, uchar **outbuf) { unsigned short *p, *end, *pR, *pG, *pB; uchar *q, *endq; unsigned short minval, maxval, i; dbgprintf("Pixel type is int2 (unsigned short)\n"); if (currImgNbSamples == 1) { *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; // adjust values p = (unsigned short *)(currBuffp[0]) + buffZOffset; end = p + currImgWidth * currImgHeight; minval = maxval = *p++; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } p = (unsigned short *)(currBuffp[0]) + buffZOffset; q = *outbuf; endq = q + currImgWidth * currImgHeight; if (maxval <= 255) { // this `unsigned short' image fits in a char, just copy things through while (q < endq) { *q++ = (uchar)(*p++); } if (currImgThickness == 1) { freeCurrentBuffers(); // really pretend that the image is char currPixType = IM_UINT1; } } else { if (maxval != minval) while (q < endq) { *q++ = (uchar)((((long)(*p++) - minval) * 255)/(maxval-minval)); } else while (q < endq) { *q++ = 128; // middle of the range. } } } else if (currImgNbSamples == 3) { if (currImgType != IM_RGB) { // a somewhat unhelpfull debugging message dbgprintf("Interpreting image as RGB even though it isn't...\n"); } *imDepth = 3; *outbuf = new uchar[currImgNbSamples*currImgWidth*currImgHeight]; minval = maxval = *((unsigned short *)(currBuffp[0]) + buffZOffset); for (i = 0 ; i < currImgNbSamples ; i++) { p = (unsigned short *)(currBuffp[i]) + buffZOffset; end = p + currImgWidth * currImgHeight; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } pR = (unsigned short *)(currBuffp[0]) + buffZOffset; pG = (unsigned short *)(currBuffp[1]) + buffZOffset; pB = (unsigned short *)(currBuffp[2]) + buffZOffset; q = *outbuf; endq = q + currImgNbSamples*currImgWidth*currImgHeight; if (maxval <= 255) { // this image fits on a char: just copy things through while (q < endq) { *q++ = (uchar)(*pR++); *q++ = (uchar)(*pG++); *q++ = (uchar)(*pB++); } if (currImgThickness == 1) { freeCurrentBuffers(); // really pretend that the image is char currPixType = IM_UINT1; } } else { if (maxval != minval) { // doesn't fit on a char: do a grey-level scaling while (q < endq) { *q++ = (uchar)((((long)(*pR++) - minval) * 255)/(maxval-minval)); *q++ = (uchar)((((long)(*pG++) - minval) * 255)/(maxval-minval)); *q++ = (uchar)((((long)(*pB++) - minval) * 255)/(maxval-minval)); } } else { while (q < endq) { *q++ = 128; *q++ = 128; *q++ = 128; } } // don't free the buffers } } else if (currImgNbSamples > 0) { // display only the current sample *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; // adjust values minval = maxval = *(((unsigned short *)currBuffp[currComp]) + buffZOffset); // take the min and max across all samples! for (i = 0 ; i < currImgNbSamples ; i++) { p = (unsigned short *)(currBuffp[i]) + buffZOffset; end = p + currImgWidth * currImgHeight; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } p = (unsigned short *)(currBuffp[currComp]) + buffZOffset; q = *outbuf; endq = q + currImgWidth * currImgHeight; if (maxval <= 255) { // this `unsigned short' image fits in a char, just copy things through while (q < endq) { *q++ = (uchar)(*p++); } if (currImgThickness == 1) { freeCurrentBuffers(); // really pretend that the image is char currPixType = IM_UINT1; } } else { if (maxval != minval) while (q < endq) { *q++ = (uchar)((((long)(*p++) - minval) * 255)/(maxval-minval)); } else while (q < endq) { *q++ = 128; // middle of the range. } } dbgprintf("There are %d uchar buffers in this image\n", currImgNbSamples); // don't free the Buffers as we may need them... } else { errprintf("Incorrect file: %d sample!\n", currImgNbSamples); freeCurrentBuffers(); } return; } void imageIO::convertUINT4(int *imDepth, uchar **outbuf) { unsigned int *p, *end, *pR, *pG, *pB; uchar *q, *endq; unsigned int minval, maxval; int i; dbgprintf("Pixel type is int4\n"); if (currImgNbSamples == 1) { *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; // adjust values p = (unsigned int*)(currBuffp[0]) + buffZOffset; end = p + currImgWidth * currImgHeight; minval = maxval = *p++; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } p = (unsigned int*)(currBuffp[0]) + buffZOffset; q = *outbuf; endq = q + currImgWidth * currImgHeight; if (maxval <= 255) { // this `int' image fits in a char, just copy things through while (q < endq) { *q++ = (uchar)(*p++); } if (currImgThickness == 1) { // really pretend that the image is char currPixType = IM_UINT1; freeCurrentBuffers(); } } else { if (maxval != minval) while (q < endq) { *q++ = (uchar)((((long)(*p++) - minval) * 255)/(maxval-minval)); } else while (q < endq) { *q++ = 128; // middle of the range. } } } else if (currImgNbSamples == 3) { if (currImgType != IM_RGB) { // a somewhat unhelpfull debugging message dbgprintf("Interpreting image as RGB even though it isn't...\n"); } *imDepth = 3; *outbuf = new uchar[currImgNbSamples*currImgWidth*currImgHeight]; minval = maxval = *((unsigned int*)(currBuffp[0]) + buffZOffset); for (i = 0 ; i < currImgNbSamples ; i++) { p = (unsigned int*)(currBuffp[i]) + buffZOffset; end = p + currImgWidth * currImgHeight; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } pR = (unsigned int*)(currBuffp[0]) + buffZOffset; pG = (unsigned int*)(currBuffp[1]) + buffZOffset; pB = (unsigned int*)(currBuffp[2]) + buffZOffset; q = *outbuf; endq = q + currImgNbSamples*currImgWidth*currImgHeight; if (maxval <= 255) { // this image fits on a char: just copy things through while (q < endq) { *q++ = (uchar)(*pR++); *q++ = (uchar)(*pG++); *q++ = (uchar)(*pB++); } if (currImgThickness == 1) { // really pretend that the image is char currPixType = IM_UINT1; freeCurrentBuffers(); } } else { if (maxval != minval) { // doesn't fit on a char: do a grey-level scaling while (q < endq) { *q++ = (uchar)((((long)(*pR++) - minval) * 255)/(maxval-minval)); *q++ = (uchar)((((long)(*pG++) - minval) * 255)/(maxval-minval)); *q++ = (uchar)((((long)(*pB++) - minval) * 255)/(maxval-minval)); } } else { while (q < endq) { *q++ = 128; *q++ = 128; *q++ = 128; } } // don't free the buffers } } else if (currImgNbSamples > 0) { // display only the current sample *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; // adjust values minval = maxval = *((unsigned int*)currBuffp[currComp] + buffZOffset); // take the min and max across all samples! for (i = 0 ; i < currImgNbSamples ; i++) { p = (unsigned int*)(currBuffp[i]) + buffZOffset; end = p + currImgWidth * currImgHeight; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } p = (unsigned int*)(currBuffp[currComp]) + buffZOffset; q = *outbuf; endq = q + currImgWidth * currImgHeight; if (maxval <= 255) { // this `int' image fits in a char, just copy things through while (q < endq) { *q++ = (uchar)(*p++); } if (currImgThickness == 1) { freeCurrentBuffers(); // really pretend that the image is char currPixType = IM_UINT1; } } else { if (maxval != minval) while (q < endq) { *q++ = (uchar)((((long)(*p++) - minval) * 255)/(maxval-minval)); } else while (q < endq) { *q++ = 128; // middle of the range. } } dbgprintf("There are %d uchar buffers in this image\n", currImgNbSamples); // don't free the Buffers as we may need them... } else { errprintf("Incorrect file: %d sample!\n", currImgNbSamples); freeCurrentBuffers(); } return; } void imageIO::convertINT4(int *imDepth, uchar **outbuf) { int *p, *end, *pR, *pG, *pB; uchar *q, *endq; int minval, maxval, i; dbgprintf("Pixel type is int4\n"); if (currImgNbSamples == 1) { *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; // adjust values p = (int *)(currBuffp[0]) + buffZOffset; end = p + currImgWidth * currImgHeight; minval = maxval = *p++; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } p = (int *)(currBuffp[0]) + buffZOffset; q = *outbuf; endq = q + currImgWidth * currImgHeight; if (minval >= 0 && maxval <= 255) { // this `int' image fits in a char, just copy things through while (q < endq) { *q++ = (uchar)(*p++); } if (currImgThickness == 1) { freeCurrentBuffers(); // really pretend that the image is char currPixType = IM_UINT1; } } else { if (maxval != minval) while (q < endq) { *q++ = (uchar)((((long)(*p++) - minval) * 255)/(maxval-minval)); } else while (q < endq) { *q++ = 128; // middle of the range. } } } else if (currImgNbSamples == 3) { if (currImgType != IM_RGB) { // a somewhat unhelpfull debugging message dbgprintf("Interpreting image as RGB even though it isn't...\n"); } *imDepth = 3; *outbuf = new uchar[currImgNbSamples*currImgWidth*currImgHeight]; minval = maxval = *((int *)(currBuffp[0]) + buffZOffset); for (i = 0 ; i < currImgNbSamples ; i++) { p = (int *)(currBuffp[i]) + buffZOffset; end = p + currImgWidth * currImgHeight; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } pR = (int *)(currBuffp[0]) + buffZOffset; pG = (int *)(currBuffp[1]) + buffZOffset; pB = (int *)(currBuffp[2]) + buffZOffset; q = *outbuf; endq = q + currImgNbSamples*currImgWidth*currImgHeight; if (minval >= 0 && maxval <= 255) { // this image fits on a char: just copy things through while (q < endq) { *q++ = (uchar)(*pR++); *q++ = (uchar)(*pG++); *q++ = (uchar)(*pB++); } if (currImgThickness == 1) { freeCurrentBuffers(); // really pretend that the image is char currPixType = IM_UINT1; } } else { if (maxval != minval) { // doesn't fit on a char: do a grey-level scaling while (q < endq) { *q++ = (uchar)((((long)(*pR++) - minval) * 255)/(maxval-minval)); *q++ = (uchar)((((long)(*pG++) - minval) * 255)/(maxval-minval)); *q++ = (uchar)((((long)(*pB++) - minval) * 255)/(maxval-minval)); } } else { while (q < endq) { *q++ = 128; *q++ = 128; *q++ = 128; } } // don't free the buffers } } else if (currImgNbSamples > 0) { // display only the current sample *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; // adjust values minval = maxval = *(((int *)currBuffp[currComp]) + buffZOffset); // take the min and max across all samples! for (i = 0 ; i < currImgNbSamples ; i++) { p = (int *)(currBuffp[i]) + buffZOffset; end = p + currImgWidth * currImgHeight; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } p = (int *)(currBuffp[currComp]) + buffZOffset; q = *outbuf; endq = q + currImgWidth * currImgHeight; if (minval >= 0 && maxval <= 255) { // this `int' image fits in a char, just copy things through while (q < endq) { *q++ = (uchar)(*p++); } if (currImgThickness == 1) { freeCurrentBuffers(); // really pretend that the image is char currPixType = IM_UINT1; } } else { if (maxval != minval) while (q < endq) { *q++ = (uchar)((((long)(*p++) - minval) * 255)/(maxval-minval)); } else while (q < endq) { *q++ = 128; // middle of the range. } } dbgprintf("There are %d uchar buffers in this image\n", currImgNbSamples); // don't free the Buffers as we may need them... } else { errprintf("Incorrect file: %d sample!\n", currImgNbSamples); freeCurrentBuffers(); } return; } void imageIO::convertDOUBLE(int *imDepth, uchar **outbuf) { double *p, *end, *pR, *pG, *pB; uchar *q, *endq; double minval, maxval; int i; dbgprintf("Pixel type is double\n"); if (currImgNbSamples == 1) { *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; // adjust values p = (double *)(currBuffp[0]) + buffZOffset; end = p + currImgWidth * currImgHeight; minval = maxval = *p++; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } p = (double *)(currBuffp[0]) + buffZOffset; q = *outbuf; endq = q + currImgWidth * currImgHeight; if (maxval != minval) while (q < endq) { *q++ = (uchar)((((*p++) - minval) * 255.0)/(maxval-minval)); } else while (q < endq) { *q++ = 128; // middle of the range. } } else if (currImgNbSamples == 3) { if (currImgType != IM_RGB) { // a somewhat unhelpfull debugging message dbgprintf("Interpreting image as RGB even though it isn't...\n"); } *imDepth = 3; *outbuf = new uchar[currImgNbSamples*currImgWidth*currImgHeight]; minval = maxval = *((double *)(currBuffp[0]) + buffZOffset); for (i = 0 ; i < currImgNbSamples ; i++) { p = (double *)(currBuffp[i]) + buffZOffset; end = p + currImgWidth * currImgHeight; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } pR = (double *)(currBuffp[0]) + buffZOffset; pG = (double *)(currBuffp[1]) + buffZOffset; pB = (double *)(currBuffp[2]) + buffZOffset; q = *outbuf; endq = q + currImgNbSamples*currImgWidth*currImgHeight; if (maxval != minval) { // doesn't fit on a char: do a grey-level scaling while (q < endq) { *q++ = (uchar)((((*pR++) - minval) * 255)/(maxval-minval)); *q++ = (uchar)((((*pG++) - minval) * 255)/(maxval-minval)); *q++ = (uchar)((((*pB++) - minval) * 255)/(maxval-minval)); } } else { while (q < endq) { *q++ = 128; *q++ = 128; *q++ = 128; } } // don't free the buffers } else if (currImgNbSamples > 0) { // display only the current sample *imDepth = 1; *outbuf = new uchar[currImgWidth * currImgHeight]; // adjust values minval = maxval = *(((double *)currBuffp[currComp]) + buffZOffset); // take the min and max across all samples! for (i = 0 ; i < currImgNbSamples ; i++) { p = (double *)(currBuffp[i]) + buffZOffset; end = p + currImgWidth * currImgHeight; while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } dbgprintf("Double image, range: min=%.6g, max=%.6g\n", minval, maxval); p = (double *)(currBuffp[currComp]) + buffZOffset; q = *outbuf; endq = q + currImgWidth * currImgHeight; if (maxval != minval) while (q < endq) { *q++ = (uchar)((((*p++) - minval) * 255)/(maxval-minval)); } else while (q < endq) { *q++ = 128; // middle of the range. } dbgprintf("There are %d uchar buffers in this image\n", currImgNbSamples); // don't free the Buffers as we may need them... } else { errprintf("Incorrect file: %d sample!\n", currImgNbSamples); freeCurrentBuffers(); } return; } #endif // HAVE_MEMBER_TEMPLATES void imageIO::freeCurrentBuffers(void) { int i; if (!dontFreeBuffers) { for (i = 0 ; i < currImgNbSamples ; i++) free(currBuffp[i]); free(currBuffp); } // at any rate, we set the pointer to 0. // the pointer is NOT lost when we are dealing with socket data. currBuffp = 0; return; } // free given raw buffers that correspond to the CurrBuffp structure void imageIO::freeRawBuffers(void *p, int imspp) { void **fb = (void **)p; for (int i = 0 ; i < imspp ; i ++) { void *ffb = fb[i]; free(ffb); } free(fb); } char *imageIO::typeName(pixtype whatType) { switch (whatType) { case IM_INVALID: return "INVALID"; case IM_BINARY: return "BINARY"; case IM_INT1: return "CHAR"; case IM_UINT1: return "UCHAR"; case IM_INT2: return "SHORT"; case IM_UINT2: return "USHORT"; case IM_INT4: return "INT"; case IM_UINT4: return "UINT"; case IM_INT8: return "INT8"; case IM_UINT8: return "UINT8"; case IM_FLOAT: return "FLOAT"; case IM_DOUBLE: return "DOUBLE"; } return "UNKNOWN"; } size_t imageIO::typeSize(pixtype whatType) { switch (whatType) { case IM_INVALID: return 0; case IM_BINARY: case IM_INT1: case IM_UINT1: return sizeof(char); case IM_UINT2: case IM_INT2: return sizeof(short); case IM_INT4: case IM_UINT4: return sizeof(int); case IM_INT8: case IM_UINT8: return sizeof(long); case IM_FLOAT: return sizeof(float); case IM_DOUBLE: return sizeof(double); } return 0; } char *imageIO::imgTypeName(imgtype whatType) { switch (whatType) { case IM_ERROR: return "Error!?"; case IM_UNSPEC: return "Unspecified"; case IM_SINGLE: return "Single"; case IM_SPECTRUM: if (imspp == 1) return "Single"; else return "Multispectral"; case IM_RGB: return "RGB"; case IM_HLS: return "HLS"; } return "UNKNOWN"; } imview-1.1.9c/imtranslate.hxx0000644000076500007650000000571007653236465017072 0ustar talbottalbot00000000000000/* * $Id: imtranslate.hxx,v 4.0 2003/04/28 14:39:49 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * imtranslate.H * * translate raw image data into viewable pixmaps * * Hugues Talbot 21 Jan 1998 * *-----------------------------------------------------------------------*/ #ifndef IMTRANSLATE_H #define IMTRANSLATE_H // external global variables that we need // defined in imview.C extern int currImgNbComps, currImgWidth, currImgHeight; extern imgtype currImgType; extern pixtype currPixType; extern unsigned short *currImgColourMap[]; extern long currImgNbColours; extern void **currBuffp; // generic functions uchar *applyCLUTtoCurrentImage(uchar *oldata, const char *CLUTpath, int *imWidth, int *imHeight, int *imDepth); char *getClutNameIfPresent(const char *impath); int checkForClut(const char *clutName, const char *imageName, uchar theCLUT[][256]); char *typeName(pixtype atype); char *getRawDataInfo(const unsigned char *olddata, int nx, int xpos, int ypos); void freeCurrentBuffers(void); void readBINARY(int *imDepth, uchar **outbuf); void readUINT1(int *imDepth, uchar **outbuf); void readINT4(int *imDepth, uchar **outbuf); void readUINT4(int *imDepth, uchar **outbuf); void readDOUBLE(int *imDepth, uchar **outbuf); void readUINT1withLUT(int *imDepth, uchar **outbuf, uchar CLUT[][256]); #endif // IMTRANSLATE_H imview-1.1.9c/imunistd.h0000755000076500007650000000474510054504410016006 0ustar talbottalbot00000000000000/* * $Id: imunistd.h,v 4.2 2004/05/24 23:45:12 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Compatibility Unistd header, not found with windows. * *-----------------------------------------------------------------------*/ #ifndef IMUNISTD_H #define IMUNISTD_H #include #ifndef WIN32_NOTCYGWIN # include #else # include # include # define sleep _sleep # ifdef _MSC_VER // Visual C++ # define strcasecmp(s,t) stricmp((s), (t)) # define strncasecmp(s,t,n) strnicmp((s), (t), (n)) # define access _access # define F_OK 00 // check for existence # define W_OK 02 // write permission # define R_OK 04 // check for read access /* extras.. */ # include typedef int ssize_t; # define snprintf _snprintf # define vsnprintf _vsnprintf # endif // _MSC_VER #endif // WIN32_NOTCYGWIN #endif // IMUNISTD_H imview-1.1.9c/imview.cxx0000644000076500007650000022375210720351523016030 0ustar talbottalbot00000000000000/* * $Id: imview.cxx,v 4.30 2007/11/19 18:17:55 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2005 by the Australian Commonwealth * Science and Industry Research Organisation (CSIRO). Please see the * COPYRIGHT file for full details. Imview also includes the * contributions of many others. Please see the CREDITS file for full * details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The Main part of imView, an image viewer program for X11 * by Hugues Talbot 26 Oct 1997 * * This program is available free of charge for anyone to use under no * guarantee of any kind, expressed or implied. * *-----------------------------------------------------------------------*/ #include // very important to have at the top there #include "imnmspc.hxx" #include #include #include #include #include #include #include #include #ifdef HAVE_NATIVE_CHOOSER #include #endif #include #include "imunistd.h" #include #include #include #include #include #include #include #include #include #ifdef WIN32_NOTCYGWIN # include # include # include #else # include // should always be there because FLTK defines it. #endif #ifdef HAVE_PTHREADS #include // oh my God. #endif #include // C++ stl maps #include // the C++ ones #include "imview.hxx" #include "imviewWindow.hxx" #include "io/imSystem.hxx" #include "menubar.hxx" #include "imageIO.hxx" #include "pointfile.hxx" #include "imageViewer.hxx" #include "printPrefs.hxx" #include "savePrefs.hxx" #include "imageInfo.hxx" #include "transferFunction.hxx" #include "spectraBox.hxx" #include "profileBox.hxx" #include "saveSpect.hxx" #include "printSpect.hxx" #include "userPrefs.hxx" #include "progressInfo.hxx" #include "nocase.hxx" #include "io/newprefio.hxx" #include "tmpMsg.hxx" #include "bivHist.hxx" #include "machine.hxx" #include "server/imserver.hxx" #include "server/interpreter.hxx" #include "rawImage.hxx" #include "annotatePoints.hxx" #include "toolbar.hxx" #include "io/readMagick.hxx" // for the initImageMagick function #include "transferRGBFunction.hxx" #include "sliceSlider.hxx" // generic panel with linked slider/value #include "view3d.hxx" // 3D image viewer #include "patchlevel.h" typedef map::const_iterator cmi; // const Map iterator /*-- miscellaneous global variables ---*/ char appName[DFLTSTRLEN]; char **extpathlist = 0; // list of all the LUT paths // components of the application imviewWindow *mainWindow = 0; imageViewer *mainViewer = 0; imViewMenuBar *mainMenuBar = 0; imageIO *IOBlackBox = 0; Fl_Box *titleBox = 0, *imageBox = 0; Fl_Image *titleImage = 0; pointfile *PtFileMngr = 0; // point file manager Fl_File_Chooser *ImviewFC = 0; // File chooser dialog #ifdef HAVE_NATIVE_CHOOSER Fl_Native_File_Chooser *ImviewNFC = 0; // native file chooser #endif // objects created using fluid printprefs *printPrefsPanel = 0; // print preferences panel saveprefs *savePrefsPanel = 0; // save preferences panel imageinfo *imageInfoPanel = 0; // image information panel transfer *transferEditorPanel = 0; // transfer function editor panel transferRGB *transferRGBEditorPanel = 0; // same as above for RGB images spectra *spectraPanel = 0; // spectrum display for hyperspectral images spectra *depthProfile = 0; // profile down the depth axis for 3D image profile *profilePanel = 0; // 1d profiles savespect *saveSpectPanel = 0; // saves a spectrum printspect *printSpectPanel = 0; // prints a spectrum userprefs *userprefsPanel = 0; // deals with the user preferences tmpmsg *tmpmsgPanel = 0; // for temporary messages bivhist *bivHistPanel = 0; // bivariate histogram progress *progressPanel = 0; // progress slider panel rawimage *rawImagePanel = 0; // unrecognized format, manually entered parms Fl_Help_Dialog *help = 0; // the Help dialog... annotatept *annotatePointPanel = 0; // point annotation toolbar *toolbarPanel = 0; // as the name implies, a primitive toolbar slideinput *slice3D = 0, *sliceComponent = 0, *sliceSeries = 0; view3D *view3dPanel = 0; // 3 views at once, very useful // other objects imprefs *fileprefs = 0; char currentprefspath[DFLTSTRLEN]; char installpath[DFLTSTRLEN]; char runningpath[DFLTSTRLEN]; interpreter *imview_interpreter = 0; // used to access the server remotely linkmanager *imview_linkmanager = 0; // essentially the client to other imview servers. // threads & server #ifdef HAVE_PTHREADS pthread_t serverthread; bool serverIsRunning = false; #endif // HAVE_PTHREADS Semaphore access_debug, access_error; // the output channels must be protected bool server_terminate = false; bool main_terminate = false; imview_server *is = 0; double simple_progress = 0.0; volatile int serverPortNumber = 0; int portfileDescriptor = -1; int pipepair[2]; char portfilename[DFLTSTRLEN]; // these depend on the size of the physical screen int appMaxWidth, appMaxHeight; // useful strings string truestr = "True"; string falsestr = "False"; string BWstr = "BW"; string GREYstr = "Grey"; string COLOURstr = "Colour"; string CONSTRAINEDstr = "Constrained"; string UNCONSTRAINEDstr = "Unconstrained"; // splash screen image const char splashImg[] = "imview_banner.jpg"; // mapping real PS file names to temporary files map psfilemap; // mapping pathnames to image header, useful for raw images map rawfilemap; // various flag/preferences int debugIsOn = 0; int stopDebug = 0; int serverDebug = 0; // explicitely to debug the server bool lutWraparound = false; // LUT behaviour for regions > 255 volatile bool syncDisplay = false; volatile bool hasSynced = false; bool hideMainMenu = false; // hides but still enables the main menu bool disableMainMenu = false; // disable but stil shows the main menu bool disableIOKeys = false; // disables *some* keyboard shortcuts bool disableQuit = false; // Imview just won't quit now... int makeImageCharIfFits = 1; // if a non-CHAR image fits in a char image, should we call it a char image and save memory? int RGBdisplaysRGB = 1; // should 3-spectra images and RGB images be displayed as RGB or multi-spectra images? int fitCharOverAllSamples = 1; // Should a multi-sample non-char image be fitcharred over all samples or only the one displayed? int fitCharOverAllSlices = 1; // Should we fit a 3D image over all slices? bool performFork = false; // useful when called from system() bool ntChild = false; // specific to windows. bool darwinChild = false; // specific to Darwin/MacOS/Carbon int zimageArgs = 0; int appendPoints = 0; int applyTransferToAll = 0; int deleteAfter = 0; // should we delete the images after we close them? int startServer = 0; bool useOffscreenBuff = true; // if true, use an off-screen buffer to draw image into at zoom = 1.0. bool useMagick = true; // if false, the use of the ImageMagick library is disallowed (ImageMagick crashes easily) bool forceMagick = false; // if true, forces the use of ImageMagick to the exclusion of natively supported image format bool forceRaw = false ; // if true, disable image format recognition and forces unknown/raw format bool simplePointfile = false; // if true, export simpler versions of the pointfiles (no annotation, no colour support) int menuheight = MENUHEIGHT; displaymode displaymodepref = IMV_DISPLAY_WINDOW_FIT_IMG; bool fullScreen = false; // a couple of temporary file name buffer char *imTempFileName = 0; //const char *psonlyfile; double persistentGamma = 1.0; // the nasty signals longjump buffer static im_jmp_buf abortenv; // an RGB description of the FL colours // hand-coded Look-up table for the overlay plane. unsigned char FL_COLOURS[MAX_FL_COLOURS][3] = { {0, 0, 0}, // 0 black {255, 0, 0}, // 1 Red {0, 255, 0}, // 2 Green {255, 255, 0}, // 3 Yellow {0, 0, 255}, // 4 Blue {255, 0, 255}, // 5 Magenta {0, 255, 255}, // 6 cyan {255, 255, 255}, // 7 white // other colours { 0, 127, 255}, { 127, 255, 0}, { 255, 0, 127}, { 148, 148, 148}, { 0, 255, 128}, { 128, 0, 255}, { 255, 128, 0}, { 1, 0, 159}, { 0, 159, 1}, { 159, 1, 0}, { 96, 254, 255}, { 255, 96, 254}, { 254, 255, 96}, { 21, 125, 126}, { 126, 21, 125}, { 125, 126, 21}, { 116, 116, 255}, { 116, 255, 116}, { 255, 116, 116}, { 0, 227, 228}, { 228, 0, 227}, { 227, 228, 0}, { 28, 27, 255}, { 27, 255, 28}, { 255, 28, 27}, { 59, 59, 59}, { 176, 195, 234}, { 255, 196, 175}, { 68, 194, 171}, { 171, 68, 194}, { 194, 171, 68}, { 71, 184, 72}, { 72, 71, 184}, { 184, 72, 71}, { 188, 255, 169}, { 63, 179, 252}, { 179, 252, 63}, { 252, 63, 179}, { 0, 9, 80}, { 9, 80, 0}, { 80, 0, 9}, { 250, 175, 255}, { 213, 134, 199}, { 95, 100, 115}, { 0, 163, 188}, { 163, 188, 0}, { 188, 0, 163}, { 0, 73, 203}, { 73, 203, 0}, { 203, 0, 73}, { 0, 189, 94}, { 94, 0, 189}, { 189, 94, 0}, { 119, 243, 187}, { 32, 125, 55}, { 55, 32, 125}, { 125, 55, 32}, { 185, 102, 255}, { 255, 185, 102}, { 168, 209, 120}, { 119, 166, 208}, { 192, 96, 135}, { 41, 255, 182}, { 130, 153, 83}, { 55, 88, 247}, { 55, 247, 89}, { 247, 55, 88}, { 0, 75, 87}, { 75, 87, 0}, { 87, 0, 75}, { 59, 135, 200}, { 127, 213, 51}, { 162, 255, 255}, { 182, 37, 255}, { 255, 182, 37}, { 117, 57, 228}, { 210, 163, 142}, { 228, 117, 57}, { 246, 255, 193}, { 123, 107, 188}, { 107, 194, 123}, { 5, 59, 145}, { 59, 145, 5}, { 145, 5, 59}, { 198, 39, 119}, { 23, 197, 40}, { 40, 23, 197}, { 197, 40, 23}, { 158, 199, 178}, { 121, 201, 255}, { 223, 223, 134}, { 84, 253, 39}, { 15, 203, 149}, { 149, 15, 203}, { 203, 149, 15}, { 90, 144, 152}, { 139, 75, 143}, { 132, 97, 71}, { 219, 65, 224}, { 224, 219, 65}, { 40, 255, 255}, { 69, 223, 218}, { 0, 241, 74}, { 74, 0, 241}, { 241, 74, 0}, { 51, 171, 122}, { 227, 211, 220}, { 87, 127, 61}, { 176, 124, 90}, { 13, 39, 36}, { 255, 142, 165}, { 255, 38, 255}, { 255, 255, 38}, { 107, 50, 83}, { 165, 142, 224}, { 9, 181, 255}, { 181, 255, 9}, { 255, 9, 181}, { 70, 238, 140}, { 5, 74, 255}, { 255, 5, 74}, { 51, 84, 138}, { 101, 172, 31}, { 17, 115, 177}, { 0, 0, 221}, { 0, 221, 0}, { 221, 0, 0}, { 200, 255, 220}, { 50, 41, 0}, { 205, 150, 255}, { 116, 45, 178}, { 189, 255, 113}, { 44, 0, 47}, { 171, 119, 40}, { 255, 107, 205}, { 172, 115, 177}, { 236, 73, 133}, { 168, 0, 109}, { 207, 46, 168}, { 203, 181, 188}, { 35, 188, 212}, { 52, 97, 90}, { 184, 209, 39}, { 152, 164, 41}, { 70, 46, 227}, { 227, 70, 46}, { 255, 156, 211}, { 222, 146, 98}, { 95, 56, 136}, { 152, 54, 102}, { 0, 142, 86}, { 86, 0, 142}, { 142, 86, 0}, { 96, 223, 86}, { 46, 135, 246}, { 120, 208, 4}, { 158, 233, 212}, { 214, 92, 177}, { 88, 147, 104}, { 147, 240, 149}, { 148, 93, 227}, { 133, 255, 72}, { 194, 27, 209}, { 255, 255, 147}, { 0, 93, 44}, { 158, 36, 160}, { 0, 233, 182}, { 217, 94, 96}, { 88, 103, 218}, { 38, 154, 163}, { 139, 114, 118}, { 43, 0, 94}, { 174, 164, 113}, { 114, 188, 168}, { 119, 23, 0}, { 93, 86, 42}, { 202, 226, 255}, { 155, 191, 80}, { 136, 158, 255}, { 62, 247, 0}, { 88, 146, 234}, { 229, 183, 0}, { 36, 212, 110}, { 161, 143, 0}, { 210, 191, 105}, { 0, 164, 133}, { 89, 30, 41}, { 132, 0, 164}, { 42, 89, 30}, { 217, 222, 178}, { 11, 22, 121}, { 22, 107, 221}, { 255, 151, 69}, { 3, 158, 45}, { 45, 3, 158}, { 158, 45, 3}, { 29, 42, 86}, { 22, 122, 9}, { 110, 209, 213}, { 57, 221, 53}, { 91, 101, 159}, { 45, 140, 93}, { 37, 213, 247}, { 0, 34, 185}, { 34, 185, 0}, { 185, 0, 34}, { 172, 0, 236}, { 78, 180, 210}, { 221, 107, 231}, { 43, 49, 162}, { 49, 162, 43}, { 162, 43, 49}, { 213, 248, 36}, { 214, 0, 114}, { 248, 36, 213}, { 243, 34, 149}, { 167, 158, 185}, { 224, 122, 144}, { 149, 245, 34}, { 98, 31, 255}, { 255, 98, 31}, { 193, 200, 152}, { 95, 80, 255}, { 63, 123, 128}, { 72, 62, 102}, { 148, 62, 255}, { 108, 226, 151}, { 255, 99, 159}, { 126, 255, 226}, { 136, 223, 98}, { 255, 95, 80}, { 15, 153, 225}, { 211, 41, 73}, { 41, 71, 212}, { 187, 217, 83}, { 79, 235, 180}, { 127, 166, 0}, { 243, 135, 251}, { 0, 41, 229}, { 229, 0, 41}, { 216, 255, 82}, { 249, 174, 141}, { 255, 215, 249}, { 79, 31, 167}, { 167, 79, 31}, { 185, 102, 213}, { 83, 215, 255}, { 40, 2, 4}, { 220, 171, 224}, { 4, 0, 41}, { 90, 50, 6}, { 113, 15, 221}, { 221, 113, 15}, { 115, 0, 33} }; // page sizes in points float page_formats[PAGESIZE_NB][2] = { {-1, -1}, /* automatic */ {421.0, 595.0}, /* A5 */ {501.0, 709.0}, /* B5 */ {595.0, 842.0}, /* A4 */ {612.0, 792.0}, /* Letter */ {612.0, 1008.0}, /* Legal (not sure */ {842.0, 1190.0} /* A3 */ }; /* thanks to Python */ /* imview... */ const char *silly_messages[] = { "is dead, Jim", "has joined the Choir Invisible", "has run down the curtain", "has gone to meet its Developer (who says Hi)", "is pushing up the daisies", "has passed on", "is no more", "has ceased to be", "has expired", "is a stiff", "is bereft of artificial life", "may rest in peace", "'s computing processes are now history", "is off the twig", "has shuffled off this mortal coil", "is an ex-imview", "has kicked the bucket", "a passé l'arme à gauche", "n'est plus", "nous a quitté", "has done itself in", NULL }; // returns the Fl_Color closest to the RGB value given Fl_Color fl_closest_colour(uchar r, uchar g, uchar b) { return (fl_color_cube(r * (FL_NUM_RED - 1) / 255, g * (FL_NUM_GREEN - 1) / 255, b * (FL_NUM_BLUE - 1) / 255)); } // returns the FLTK colour closest to the index in the FL_COLOUR array Fl_Color fl_closest_index(int i) { return (fl_closest_colour(FL_COLOURS[i][0], FL_COLOURS[i][1], FL_COLOURS[i][2])); } static void experimental_sync(void); // VERY useful function. // equivalent to the '<' operator. // returns 0 if both strings are the same // return 1 if a < b // return -1 if a > b int cmp_nocase(const string &a, const string &b) { string::const_iterator p = a.begin(); string::const_iterator q = b.begin(); while (p != a.end() && q != b.end()) { if (toupper(*p) != toupper(*q)) return ((toupper(*p) < toupper(*q)) ? -1: 1); ++p; ++q; } return ((b.size() == a.size()) ? 0 : (a.size() < b.size()) ? -1:1); } // case-insensitive compare strings // the nocase operator, equivalent to the '<' operator, but for // case-independent comparisons. bool Nocase::operator () (const string &x, const string &y) const { string::const_iterator p = x.begin(); string::const_iterator q = y.begin(); while (p!=x.end() && q!=y.end() && toupper(*p) == toupper(*q)) { ++p; ++q; } if (p == x.end()) return q != y.end(); return toupper(*p) < toupper(*q); } // the title banner Fl_Box *bannerBox(int x, int y, int w, int h) { static char message[200]; sprintf(message,"Imview %s", patchlevel); dbgprintf("%s\n",message); Fl_Box *box = new Fl_Box(x,y,w,h,message); box->labelfont(FL_TIMES | FL_ITALIC | FL_BOLD); box->labelsize(24); box->labeltype(FL_SHADOW_LABEL); box->labelcolor(FL_WHITE); return box; } void showSimpleBanner(void) { int tboxwidth, tboxheight, ret; static int splashwidth, splashheight, splashspp,i,j; static long splashbytes = 0; static unsigned char *splashScreen = 0; mainWindow->size_range(MINWIDTH,MINHEIGHT,SWIDTH,SHEIGHT-(MENUHEIGHT-menuheight)); dbgprintf("Setting size limit in showSimpleBanner\n"); mainWindow->size(SWIDTH,SHEIGHT-(MENUHEIGHT-menuheight)); // show the splash screen if found // installpath is defined dynamically and splashImg is a constant char[] defined above. if (splashScreen == 0) { static char pathToSplash[DFLTSTRLEN]; char tmppath[DFLTSTRLEN]; for ( i = 0, j = 0; ; ) { // ever if ((installpath[i] != PATHSEP) && (installpath[i] != '\0')) { tmppath[j++] = installpath[i++]; } else { tmppath[j] = '\0'; dbgprintf("looking in %s\n", tmppath); snprintf(pathToSplash, DFLTSTRLEN, "%s%c%s", tmppath, SLASH, splashImg); // try to read it off a file if ((ret = IOBlackBox->read(pathToSplash, 0)) == 0) { // fine, we could read the splash image splashwidth = IOBlackBox->imageWidth(); splashheight = IOBlackBox->imageHeight(); splashspp = IOBlackBox->imageDepth(); splashbytes = splashwidth * splashheight * splashspp * sizeof(uchar); splashScreen = (uchar *) malloc(splashbytes); // take a permanent copy memcpy(splashScreen, IOBlackBox->imageData(), splashbytes); // set minimal information IOBlackBox->setImName(pathToSplash); IOBlackBox->setCurrImgNbFrames(1); break; } else { warnprintf("showSimpleBanner: could not read file %s\n", pathToSplash); // no joy there, try next string if possible if (installpath[i] != '\0') { j = 0; i++; } else break; } } } } // test again if (splashScreen != 0) { // then display it titleImage = new Fl_RGB_Image(splashScreen, splashwidth, splashheight); imageBox = new Fl_Box((mainWindow->w()-splashwidth)/2, (mainWindow->h()-splashheight+menuheight)/2, splashwidth, splashheight); titleImage->label(imageBox); mainWindow->add(imageBox); titleBox = bannerBox(5, 50, 160, 30); } else { tboxheight = TBOXHEIGHT; tboxwidth = mainWindow->w()-50; // say // show a simple text banner titleBox = bannerBox((mainWindow->w()-tboxwidth)/2, (mainWindow->h()-tboxheight)/2, tboxwidth, tboxheight); } mainWindow->add(titleBox); } void removeSimpleBanner(void) { if (titleBox) { // && titleBox->visible()) { mainWindow->remove(titleBox); delete(titleBox); titleBox = 0; mainWindow->size_range(MINWIDTH,MINHEIGHT,appMaxWidth,appMaxHeight); dbgprintf("Removing size limits in removeSimpleBanner\n"); } if (imageBox) { mainWindow->remove(imageBox); delete(imageBox); imageBox = 0; } if (titleImage) { delete(titleImage); titleImage = 0; } } static void printUnixUsage(char *fname) { const char *newfname; char blankpad[DFLTSTRLEN]; int i = 0; newfname = myBaseName(fname); strcpy(blankpad, newfname); // converts to blanks while (blankpad[i] != '\0') blankpad[i++] = ' '; fprintf(stderr, "Purpose: this application displays images\n" "Usage : %s [-h] [-v] [-debug] [-stopdebug] [-h] [-v] [-C defaultLUT]\n" " %s [-p pointfile] [-a] [-] [-mag defaultMagnification]\n" " %s [-wt ] [-delete] [-no_dblbuf]\n" " %s [-hide_menubar] [-disable_menubar] [-disable_io_keys] \n" " %s [-disable_quit] [-locked] [-no_magick]\n" " %s [image1 [-c clut1]] [image2 [-c clut2]] ...\n" "\n" "%s-specific options:\n" "------------------------\n" " - : reads an image from stdin\n" " -a : reads and appends to an existing pointfile\n" " -c : Z-IMAGE type look-up table attached to preceding image\n" " -C : changes the default LUT for all images\n" " -debug : prints gobs of debugging messages\n" " -delete : deletes images after use\n" "-disable_menubar : disable the main menu (but does not hide it)\n" "-disable_io_keys : disable I/O key shortcuts (open/close images, quit, etc)\n" " -disable_quit : disable standard ways to quit the application (Esc, etc)\n" " -fit : fits the image display to the window: no scrollbars\n" " -force_magick : forces use of the ImageMagick library instead of native support\n" " -force_raw : disable image format recognition, forces unknown/raw format\n" " -fork : sends itself to the background\n" " -gamma : specifies as the default gamma\n" " -h : this help\n" " -hide_menubar : hide the main menu (but does not disable it)\n" " -locked : equivalent to all the disable_* and -hide_menubar flags set together\n" " -mag : changes the default magnification to \n" " -no_dblbuf : do not use double-buffering at certain zoom factors\n" " -no_magick : use of library ImageMagick is disallowed (as it can be quite buggy)\n" " -p : specifies a point file name\n" "-portfile : saves the TCP port number to \n" " -server : start the TCP image server\n" " -simple_pf : simplify pointfiles somewhat\n" " -stopdebug : not only that, but stops at each message\n" " -v : prints version number\n" " -wt : sets the window title\n" " image : GIF, ICS, JPEG, TIFF, Z-IMAGE or any type supported by ImageMagick.\n" "\n" "Other standard X11 options:\n" "---------------------------\n" "%s\n", newfname, blankpad, blankpad, blankpad, blankpad, blankpad, newfname, Fl::help); return; } static void printZusage(char *fname) { fprintf(stderr, "Purpose: displays images under X11\n" "Usage : %s(<image1>,[cmap:\"std_grey\"],<image2>,[cmap:\"std_grey\"],...\n" " ,[CMAP:\"std_grey\"],[file:\"pointfile\"],[append:\"F/T\"]\n" " ,[mag:1.0], [xmax:1.0], [ymag:1.0], [gamma:1.0]\n" " ,[title:\"imview\"], [debug:\"F/T\"])\n" " <image1>, <image2>, ... is a list of arbitrary images\n" " cmap:\"some_LUT\" applies a colour LUT only to preceding image \n" " on command line\n" " CMAP:\"some_LUT\" applies a colour LUT to all images on the command\n" " line, except for those with a cmap: argument\n" " file:\"point_file_name\" names the default file where points\n" " location and values can be saved\n" " append:\"F/T\" appends to an existing pointfile\n" " mag/xmag/ymag:<xx.xx> changes the default magnification to <xx.xx> \n" " gamma:<x.xx> changes the default gamma value \n" " title:\"some_title\" changes the window title \n" " debug:\"F/T\" turns on some debugging messages\n", myBaseName(fname) ); return; } static void printCredits(char *fname) { static char currentpath[DFLTSTRLEN]; printf("%s version %s build #%d for %s. Made on %s by %s\n" "Copyright Hugues Talbot, Image Analysis Group, CSIRO-MIS 1997-2003\n", myBaseName(fname), patchlevel, totalbnb, systemName(), __DATE__, builder ); // location getcwd(currentpath, DFLTSTRLEN); printf("Current path: %s\n", currentpath); printf("Running path: %s\n", runningpath); // more details concerning the configuration printf("Configuration:\n"); printf("-------------------------------+-----\n"); #ifdef HAVE_TIFF printf(" - Native TIFF support: Yes | \n"); #else printf(" - Native TIFF support: | No\n"); #endif printf("-------------------------------+-----\n"); #ifdef HAVE_JPEG printf(" - Native JPEG support: Yes | \n"); #else printf(" - Native JPEG support: | No\n"); #endif printf("-------------------------------+-----\n"); #ifdef HAVE_PNG printf(" - Native PNG support : Yes | \n"); #else printf(" - Native PNG support : | No\n"); #endif printf("-------------------------------+-----\n"); #ifdef HAVE_MAGICK printf(" - LibMagick support : Yes | \n"); #else printf(" - LibMagick support : | No \n"); #endif printf("-------------------------------+-----\n"); #ifdef HAVE_PTHREADS printf(" - Image server : Yes | \n"); #else printf(" - Image server : | No \n"); #endif printf("-------------------------------+-----\n"); #ifdef HAVE_SYSV_IPC printf(" - Unix SYSV IPC : Yes | \n"); #else printf(" - Unix SYSV IPC : | No \n"); #endif printf("-------------------------------+-----\n"); #ifdef HAVE_POSIX_IPC printf(" - Unix POSIX IPC : Yes | \n"); #else printf(" - Unix POSIX IPC : | No \n"); #endif printf("-------------------------------+-----\n"); return; } // look for lut in given path static char *clutFullPath(char *lutproto) { int i = 0; static char lutpath[DFLTSTRLEN]; char *dotp; if ((lutproto != 0) && (extpathlist != 0)) { while (extpathlist[i] != 0) { sprintf(lutpath,"%s/%s", extpathlist[i], lutproto); if (((dotp = strrchr(lutpath, '.')) == 0) || (strcmp(dotp, CLUT_SUFFIX) != 0)) { // we need to add the .lut suffix strcat(lutpath, CLUT_SUFFIX); } if (access(lutpath, R_OK) == 0) { dbgprintf("Found lut %s\n", lutpath); return lutpath; } i++; } // if we get there this means we got no valid lut path errprintf("%s not a valid colour LUT\n", lutpath); } return 0; } // this little function will remove the \" at the end // of stupid Z-IMAGE string arguments static char *cleanZarg(char *input) { char *pcbuf; int k = 0; pcbuf = strdup(input); // the caller will need to free this later on while ((pcbuf[k] != '\0') && (pcbuf[k] != '\"')) k++; pcbuf[k] = '\0'; return pcbuf; } // argument checking function // this function may not return at all (calls exit) // is is a bit too complicated because we try to // support both the normal Unix command line and the Z-IMAGE // quirky interface void checkArgs(int argc, char **argv, char ***imagelist, char ***clutlist, double *defaultZoom, double *defaultGamma) { int i = 1, nbimages, j = 0, stl; int k, fltk_args; bool checkMinus = true; // check that arguments start with -, when false, even those will be considered images // empty the application name appName[0] = '\0'; // allocate an image list no matter what *imagelist = new char *[argc]; *clutlist = new char *[argc]; // sensible default *defaultZoom = 1.0; *defaultGamma = 1.0; // empty optional portfile portfilename[0] = '\0'; if (argc > 1) { nbimages = argc - 1; // test to see if we are being called from Z-IMAGE stl = strlen(argv[1]); if (((stl >= 5) // first part is for Z-IMAGE && (argv[1][0] == 'z') && (argv[1][1] == '_') && (isdigit(argv[1][2])) && (argv[1][stl-2] == '_') && (argv[1][stl-1] == 'z')) || ((strncmp(argv[1], "Zfile", 5) == 0) // second part is for SZ && (argv[1][stl-1] == 'z') && (argv[1][stl-2] == '_') && (isdigit(argv[1][5])) ) ){ dbgprintf("We are being called from Z-IMAGE\n"); zimageArgs = 1; i++; nbimages--; } while (i < argc) { if ((fltk_args = Fl::arg(argc, argv, i)) != 0) { // test if argument recognized by FL nbimages -= fltk_args; continue; // i gets correctly incremented by Fl:arg } else if (strncmp(argv[i], "-gamma", 6) == 0) { if (i+1 < argc) { dbgprintf("Got new default gamma factor %s\n", argv[i+1]); *defaultGamma = atof(argv[i+1]); i += 2; nbimages -= 2; } else { errprintf("Incomplete argument %s\n", argv[i]); // continue anyway i++; nbimages--; } } else if (zimageArgs && (strncmp(argv[i], "gamma:", 6) == 0)) { char *p = cleanZarg(argv[i]+4); dbgprintf("Got new default gamma factor %s\n", p); *defaultGamma = atof(p); i++; nbimages--; } else if ((strncmp(argv[i], "-debug", 6) == 0) // test for debugging || (zimageArgs && (strncmp(argv[i], "debug:\"", 7) == 0) && ((toupper(argv[i][7]) == 'T') || (toupper(argv[i][7]) =='Y') ))) { printf("Debug is ON\n"); debugIsOn = 1; i++; nbimages--; } else if ((strncmp(argv[i], "-stopdebug", 10) == 0) // test for debugging || (zimageArgs && (strncmp(argv[i], "stopdebug:\"", 11) == 0) && ((toupper(argv[i][7]) == 'T') || (toupper(argv[i][7]) =='Y') ))) { printf("Press any key after each debugging message\n"); debugIsOn = 1; stopDebug = 1; i++; nbimages--; } else if (zimageArgs && (strncmp(argv[i], "zdebug:\"", 6) == 0)) { // ignore argument i++; nbimages--; } else if (strcmp(argv[i], "-p") == 0) { /* */ if (i+1 < argc) { dbgprintf("Got default pointfile name: %s\n", argv[i+1]); PtFileMngr->setPtFileName(argv[i+1]); i += 2; // we progress by 2 arguments on the command line: nbimages -= 2; // -p and the argument after that. } else { errprintf("Incomplete argument %s\n", argv[i]); // but continue anyway... i++; nbimages--; } } else if (zimageArgs && (strncmp(argv[i], "file:\"", 6) == 0)) { // this strdups the input argument char *p = cleanZarg(argv[i]+6); dbgprintf("Got default pointfile name: %s as Z argument\n", p); PtFileMngr->setPtFileName(p); i++; // we progress by only one argument on the command line: nbimages--; // free the input argument free(p); } else if ((strncmp(argv[i], "-a", 2) == 0) // we want to append data to a pointfile || (zimageArgs && (strncmp(argv[i], "append:\"", 8) == 0) && ((toupper(argv[i][8]) == 'T') || (toupper(argv[i][8]) == 'Y')))) { dbgprintf("Pointfile append mode\n"); appendPoints = 1; i++; nbimages--; } else if (strncmp(argv[i], "-mag", 4) == 0) { if (i+1 < argc) { dbgprintf("Got new default zoom factor %s\n", argv[i+1]); *defaultZoom = atof(argv[i+1]); i += 2; nbimages -= 2; } else { errprintf("Incomplete argument %s\n", argv[i]); // continue anyway i++; nbimages--; } } else if (zimageArgs && (strncmp(argv[i], "mag:", 4) == 0)) { char *p = cleanZarg(argv[i]+4); dbgprintf("Got new default zoom factor %s\n", p); *defaultZoom = atof(p); i++; nbimages--; } else if (zimageArgs && ((strncmp(argv[i], "xmag:", 5) == 0) || (strncmp(argv[i], "ymag:", 5) == 0))) { char *p = cleanZarg(argv[i]+5); dbgprintf("Got new default zoom factor %s\n", p); *defaultZoom = atof(p); i++; nbimages--; } else if (strncmp(argv[i], "-fit", 4) == 0) { displaymodepref = IMV_DISPLAY_IMG_FIT_WINDOW; ++i; --nbimages; } else if (strncmp(argv[i], "-dec", 4) == 0) { displaymodepref = IMV_DISPLAY_DECOUPLE_WIN_IMG; ++i; --nbimages; } else if (strncmp(argv[i], "-wt", 3) == 0) { if (i+1 < argc) { dbgprintf("Got the window title: %s\n", argv[i+1]); strcpy(appName, argv[i+1]); i += 2; nbimages -= 2; } else { errprintf("Incomplete argument %s\n", argv[i]); // continue anyway i++; nbimages--; } } else if (zimageArgs && (strncmp(argv[i], "title:\"", 6) == 0)) { // this strdups the input argument char *p = cleanZarg(argv[i]+7); dbgprintf("Got window title: %s as Z argument\n", p); strcpy(appName, p); i++; // we progress by only one argument on the command line: nbimages--; // free the input argument free(p); } else if (strncmp(argv[i], "-server", 7) == 0) { #ifdef HAVE_PTHREADS dbgprintf("We shall be starting the server momentarily\n"); startServer = 1; #else dbgprintf("Server not compiled in\n"); #endif i++; nbimages--; } else if (strncmp(argv[i], "-servdebug", 10) == 0) { dbgprintf("Debugging the server\n"); serverDebug = 1; i++; nbimages--; } else if (strncmp(argv[i], "-fork", 5) == 0) { dbgprintf("Will fork by itself\n"); performFork = true; i++; nbimages--; } else if (strncmp(argv[i], "-ntchild", 8) == 0) { dbgprintf("we got restarted by a win32 CreateProcess\n"); ntChild = true; i++; nbimages--; } else if (strncmp(argv[i], "-darwinchild", 12) == 0) { dbgprintf("We got restarted by a Darwin/MacOS/Carbon fork()\n"); darwinChild=true; i++; nbimages--; } else if (strncmp(argv[i], "-delete", 7) == 0) { dbgprintf("We will delete images after use\n"); deleteAfter = 1; i++; nbimages--; } else if (strncmp(argv[i], "-portfile", 9) == 0) { dbgprintf("Port file is expected as next argument... \a"); if (i+1 < argc) { dbgprintf("got port file name: %s\b", argv[i+1]); strncpy(portfilename, argv[i+1], PF_MAX_LEN); } i += 2; nbimages -= 2; } else if (strncmp(argv[i], "-no_dblbuf", 9) == 0) { dbgprintf("not using offscreen buffer at zoom = 1.0\n"); useOffscreenBuff = false; ++i; --nbimages; } else if (strncmp(argv[i], "-hide_menubar", 10) == 0) { dbgprintf("No main menu bar\n"); hideMainMenu = true; ++i; --nbimages; } else if (strncmp(argv[i], "-disable_menubar", 16) == 0) { dbgprintf("Disabled main menu bar\n"); disableMainMenu = true; ++i; --nbimages; } else if (strncmp(argv[i], "-disable_io_keys", 16) == 0) { dbgprintf("Disabled I/O related key shortcuts\n"); disableIOKeys = true; ++i; --nbimages; } else if (strncmp(argv[i], "-disable_quit", 13) == 0) { dbgprintf("Imview will keep going forever...\n"); disableQuit = true; ++i; --nbimages; } else if (strncmp(argv[i], "-locked", 7) == 0) { dbgprintf("Imview is locked on\n"); hideMainMenu = true; disableMainMenu = true; disableIOKeys = true; disableQuit = true; ++i; --nbimages; } else if (strncmp(argv[i], "-no_magick", 10) == 0) { dbgprintf("Use of ImageMagick is disallowed\n"); useMagick = false; ++i; --nbimages; } else if (strncmp(argv[i], "-force_magick", 13) == 0) { dbgprintf("Use of ImageMagick is forced\n"); forceMagick = true; ++i; --nbimages; } else if (strncmp(argv[i], "-force_raw", 10) == 0) { dbgprintf("Image format recognition disabled\n"); forceRaw = true; ++i; --nbimages; } else if (strncmp(argv[i], "-simple_pf", 10) == 0) { dbgprintf("Simplify pointfile output\n"); simplePointfile = true; ++i; --nbimages; } else if (strncmp(argv[i], "-sync", 7) == 0) { dbgprintf("Synchronizing display\n"); syncDisplay = true; ++i; --nbimages; } else if (strncmp(argv[i], "-v", 2) == 0) { printCredits(argv[0]); delete[] *imagelist; delete[] *clutlist; *imagelist = *clutlist = 0; imview_exit(0); } else if (strncmp(argv[i], "-C", 2) == 0) { if (i+1 < argc) { dbgprintf("Got default colourmap %s\n", argv[i+1]); // ignore the colourmaps for the images up to the // point where -C is declared. for (k = 0 ; k < argc ; k++) if ((*clutlist)[k] == 0) { // unix-style arguments are not strdup'ed (*clutlist)[k] = argv[i+1]; } i += 2; // we progress by 2 arguments on the command line nbimages -= 2; // (`-C' and argument after that) } else { errprintf("Incomplete argument %s\n", argv[i]); // but continue anyway... i ++; nbimages--; } } else if (zimageArgs && (strncmp(argv[i], "CMAP:\"", 6) == 0)) { dbgprintf("Applying colourmap %s to all images\n", argv[i]+6); for (k = 0 ; k < argc ; k++) if ((*clutlist)[k] == 0) { // not very efficient but succinct (*clutlist)[k] = cleanZarg(argv[i]+6); } i++; nbimages--; // only one argument gets processed in this case. // we don't make j progress because no specific image is involved. } else if (strncmp(argv[i], "-c", 2) == 0) { // colourmaps if (i+1 < argc) { dbgprintf("Got CLUT %s\n", argv[i+1]); if (j > 0) (*clutlist)[j-1] = argv[i+1]; else errprintf("Colourmap %s doesn't apply to any image\n", argv[i+1]); i += 2; // -c nbimages -= 2; // and `lutname' make 2 arguments... } else { errprintf("Incomplete argument %s\n", argv[i]); // but continue anyway... i ++; nbimages--; } } else if (zimageArgs && (strncmp(argv[i], "cmap:\"", 6) == 0)) { if (j > 0) { if ((*clutlist)[j-1] != 0) free((*clutlist)[j-1]); // may have been set up by the CMAP: arg // this will strdup the argument as well (*clutlist)[j-1] = cleanZarg(argv[i]+6); dbgprintf("Got CLUT %s\n", (*clutlist)[j-1]); } else { errprintf("Argument %s doesn't apply to any image\n", argv[i]); } i++; // only one argument gets processed in the Z case nbimages--; } else if (strcmp(argv[i], "-") == 0) { // read from stdin dbgprintf("Reading from stdin\n"); if (stdinToTemp() == 0) { dbgprintf("Got image %s\n", imTempFileName); (*imagelist)[j] = imTempFileName; (*clutlist)[j++] = 0; // by default... } else { errprintf("Couldn't create temporary file to read from standard input\n"); nbimages--; } i++; } else if (strncmp(argv[i], "-h", 2) == 0) { // ask for some help printUnixUsage(argv[0]); delete[] *imagelist; delete[] *clutlist; *imagelist = *clutlist = 0; imview_exit(0); // no error } else if (strcmp(argv[i], "--") == 0) { // EXACTLY -- checkMinus = false; // future arguments will be imaages... ++i; --nbimages; } else if (argv[i][0] == '-') { // unrecognized argument stderrprintf("Argument %s unrecognized\n", argv[i]); delete[] *imagelist; delete[] *clutlist; *imagelist = *clutlist = 0; imview_exit(10); // this is an error } else { // this is just an image name dbgprintf("Got image %s\n", argv[i]); (*imagelist)[j] = argv[i++]; (*clutlist)[j++] = 0; // by default } } // mark the end of the list: dbgprintf("Got %d image%c\n", nbimages,(nbimages > 1)?'s':'\0'); (*imagelist)[nbimages] = 0; (*clutlist)[nbimages] = 0; if (zimageArgs && (nbimages == 0)) { printZusage(argv[0]); delete[] *imagelist; delete[] *clutlist; *imagelist = *clutlist = 0; imview_exit(10); } } else { (*imagelist)[0] = (*clutlist)[0] = 0; } return; } void huntCLUT(const char **clutpathlist) { int i, j, nbext; const char *q; char *p, fullpath[DFLTSTRLEN]; dbgprintf("----- LOOKING FOR LUTS -----\n"); // expand the path list for (i = 0, j = 0 ; clutpathlist[i] != 0 ; i++) { if (clutpathlist[i][0] != 0) { j++; dbgprintf("Expanding %s\n", clutpathlist[i]); q = clutpathlist[i]; while (*q) if (*q++ == PATHSEP) // : or , j++; } } nbext = j; dbgprintf("total number of paths: %d\n", nbext); extpathlist = new char *[nbext+1]; // get all the starting points for (i = 0, j = 0 ; clutpathlist[i] != 0 ; i++) { if (clutpathlist[i][0] != 0) { extpathlist[j++] = strdup(clutpathlist[i]); q = clutpathlist[i]; while (*q) { if (*q++ == PATHSEP) extpathlist[j++] = strdup(q); } } } // list terminated by NULL extpathlist[nbext] = 0; #ifdef WIN32_NOTCYGWIN // Windows way to look through directories long done; struct _finddata_t c_file; char fname[DFLTSTRLEN]; // we force the use of POSIX paths for (i = 0 ; i < nbext ; i++) { p = strchr(extpathlist[i], PATHSEP); if (p) *p = '\0'; // search this directory dbgprintf("Searching %s\n", extpathlist[i]); strncpy(fname, extpathlist[i], DFLTSTRLEN); // replaces all `\\' with `/' for (p = fname; *p != '\0' ; p++) if (*p == '\\') *p = '/'; // add the extension we are looking for strcat(fname, "/*.lut"); if ((done = _findfirst(fname, &c_file)) != -1L) { do { dbgprintf("Found: %s\n", c_file.name); strncpy(fullpath, extpathlist[i], DFLTSTRLEN-strlen(c_file.name)-1); strcat(fullpath, "/"); strcat(fullpath, c_file.name); if (!mainMenuBar->isAlreadyInItemList(fullpath, CLUT_LIST_ID)) mainMenuBar->addToItemList(fullpath,CLUT_LIST_ID); } while (_findnext(done, &c_file) == 0); } _findclose(done); } #else // the Unix way DIR *dirp; struct dirent *dp; char *name, *dotp; // get all the endpoints for (i = 0 ; i < nbext ; i++) { p = strchr(extpathlist[i], PATHSEP); if (p) *p = '\0'; // search this directory dbgprintf("Searching %s\n", extpathlist[i]); if ((dirp = opendir (extpathlist[i])) == 0) { warnprintf("huntCLUT: cannot access directory %s\n", extpathlist[i]); continue; // skip over that one } // loop searching for lut files for (dp = readdir (dirp); dp != 0; dp = readdir (dirp)) { name = dp->d_name; if ((name != 0) && ((dotp = strrchr(name,'.')) != 0) && (strcmp (dotp,CLUT_SUFFIX) == 0)) { dbgprintf("Found: %s\n", name); strncpy(fullpath, extpathlist[i], DFLTSTRLEN-strlen(name)-1); strcat(fullpath, "/"); strcat(fullpath, name); if (!mainMenuBar->isAlreadyInItemList(fullpath, CLUT_LIST_ID)) mainMenuBar->addToItemList(fullpath,CLUT_LIST_ID); } } closedir (dirp); } #endif // WIN32_NOTCYGWIN dbgprintf("----- END OF LOOKING FOR LUTS -----\n"); return; } void readUserPrefs(void) { char prefpath[DFLTSTRLEN]; char tmppath[DFLTSTRLEN]; int i, j; const char *p; dbgprintf("----- LOOKING FOR PREFERENCES -----\n"); // allocate the preferences manager, and initialise it with pref file fileprefs = new imprefs; currentprefspath[0] = '\0'; // initialize this to empty // read the user preferences if present if (((p = getenv("IMVIEWHOME")) != 0) || ((p = getenv("HOME")) != 0)) { strncpy(prefpath, p, DFLTSTRLEN); // keep these potential paths as the install path snprintf(installpath, DFLTSTRLEN, "%s%c%s", prefpath, PATHSEP, PrefPath); } else { snprintf(prefpath, DFLTSTRLEN, ".%c%s", PATHSEP, PrefPath); // look in the default installation directory (long shot) strncpy(installpath, prefpath, DFLTSTRLEN); } #ifdef MACOSX_CARBON // MacOS/X peculiar .app containers char AppContainerPath[DFLTSTRLEN]; snprintf(AppContainerPath, DFLTSTRLEN,"%c%s/../Resources", PATHSEP, runningpath); strncat(installpath, AppContainerPath, DFLTSTRLEN); #endif for ( i = 0, j = 0; ; ) { // ever if ((prefpath[i] != PATHSEP) && (prefpath[i] != '\0')) { tmppath[j++] = prefpath[i++]; } else { tmppath[j++] = SLASH; // end of string tmppath[j] = '\0'; strcat(tmppath, "preferences"); dbgprintf("looking in %s\n", tmppath); if (fileprefs->readprefs(tmppath)) { strcpy(currentprefspath, tmppath); // save the location of the prefs file break; // found preferences, finished } else { // no joy there, try next string if possible if (prefpath[i] != '\0') { j = 0; i++; } else break; } } } dbgprintf("----- END OF LOOKING FOR PREFERENCES -----\n"); return; } // display the images given on the command line // if possible. Otherwise shows a simple banner void displayImages(char **imageList, char **lutList) { int i, openRes, displayOK; IMAGEPARM *p; const char *clutname; // try do display the images that were given on the command line, // if there are any... displayOK = 0; if (imageList && imageList[0]) { // place the names on the image list for (i = 0 ; imageList[i] != 0 ; i++) { mainMenuBar->addToItemList(imageList[i],IMAGE_LIST_ID); // attach LUT if possible p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); clutname = clutFullPath(lutList[i]); if ((p != 0) && (clutname != 0)) { if (p->clutpath != 0) free(p->clutpath); p->clutpath = strdup(clutname); dbgprintf("Attaching clut %s to image %s as default\n", p->clutpath, p->itempath); } } // display the first valid image i = 0; displayOK = 1; while ((openRes = openimage(imageList[i])) != 0) { // the current image is invalid: remove it from the list dbgprintf("Unrecognized argument: %s\n", imageList[i]); mainMenuBar->removeFromItemList(imageList[i], IMAGE_LIST_ID); if (imageList[++i] == 0) { // we have exhausted all the options displayOK = 0; break; } } } if (!displayOK) { showSimpleBanner(); } return; } #ifdef HAVE_PTHREADS // this handler will catch all the deadly signals. // we do this only when the server starts. Experimentally very annoying // things can happen in multithreaded applications static void abortHandler(int sig) { // implement the default handler if a disaster occurs // while we are still processing the previous disaster... signal(sig, SIG_DFL); im_longjmp(abortenv, 1); } void start_server(void) { int rval, nbsillymsg; pthread_attr_t impthread_attr; #ifndef WIN32_NOTCYGWIN // apparently this is standard practice to close stdin // in this case. fclose(stdin); fclose(stdout); // acutally we want to keep stderr: fclose(stderr); #endif // WIN32_NOTCYGWIN // Under DU4.x, ending a thread might bring about a nasty ABORT dbgprintf("Setting up deadly signals handler\n"); im_signal(SIGABRT, abortHandler); im_signal(SIGBUS, abortHandler); im_signal(SIGSEGV, abortHandler); im_signal(SIGKILL, abortHandler); im_signal(SIGHUP, abortHandler); im_signal(SIGQUIT, abortHandler); im_signal(SIGTERM, abortHandler); im_signal(SIGINT, abortHandler); if (im_setjmp(abortenv, 1) == 0) { if ((rval = pthread_attr_init(&impthread_attr)) == 0) #if HAVE_DECTHREADS rval = pthread_create(&serverthread, impthread_attr, (mt) init_server, 0); #else // standard PTHREADS rval = pthread_create(&serverthread, &impthread_attr, (mt) init_server, 0); #endif serverIsRunning = true; if (rval) { errprintf("Server could not be started\n"); } else dbgprintf("Server started\n"); } else { for (nbsillymsg = 0 ; silly_messages[nbsillymsg] != NULL; ++nbsillymsg) ; // we only get there via the signal handler int index = (int)((double)random()/INT_MAX * nbsillymsg); dbgprintf("Printing silly message %d\n", index); fprintf(stderr, "\n*** Aaargh, deadly signal caught: imview %s\n", silly_messages[index]); serverIsRunning = false; imview_exit(101); // will NOT call abort() } return; } #else // HAVE_PTHREADS void start_server(void) {} #endif // HAVE_PTHREADS // simple run function void run(void) { string as; int i; char tmptitle[100]; if (startServer) { // synchronize with server i = 0; #ifndef WIN32_NOTCYGWIN int maxcount = 200; while ((serverPortNumber == 0) && (i < maxcount)) { myusleep(10000); i++; } #else int maxcount = 20; while ((serverPortNumber == 0) && (i < maxcount)) { _sleep(1); i++; } #endif if (i < maxcount) { // no timeout dbgprintf("Got port number after %d iterations\n", i); sprintf(tmptitle, "[%d] %s", serverPortNumber, appName); strncpy(appName, tmptitle, 100); mainWindow->label(appName); } else { dbgprintf("Didn't get port number :-(\n"); sprintf(tmptitle, "[%d] %s", serverPortNumber, appName); strncpy(appName, tmptitle, 100); mainWindow->label(appName); } } experimental_sync(); while (!main_terminate) { #ifdef HAVE_PTHREADS // surrogate for HAVE_SERVER... double wp; unsigned int image_present; if (fileprefs) wp = fileprefs->pollFrequency(); else wp = 100.0; // 100 Hz assert((wp > 1.0) && (wp < 10000.0)) ; // everything else is a bug Fl::wait(1/wp); // wait some controlled amount of time // if there is an interpreter, do something with it. if (imview_interpreter && is) { is->manage_commands(); // check to see if there is anything to display image_present = IOBlackBox->checkDisplay(as); if (image_present > 0) { // we have an image, display it. dbgprintf("An image is present: %s\n", as.c_str()); openimage(as.c_str(), 0); } // see if an upload is in progress if (progressPanel && progressPanel->visible()) { progressPanel->setProgress(simple_progress); } } #else Fl::wait(); #endif if (!mainWindow || !Fl::first_window()) // no window break; } // if we get here this means it hadn't been called before... imview_exit(0); } // called when imview is about to exit void imview_exit(int status, bool do_abort) { int j = 0, srval = 0; IMAGEPARM *p; cmi q; #ifdef HAVE_PTHREADS void *server_return; // stop the server if (serverIsRunning) { server_terminate = true; // this will stop the server if (pthread_join(serverthread, &server_return) != 0) { errprintf("Server thread failed to terminate gracefully"); } srval = (long) server_return; // we know the return value is an int. dbgprintf("Server stopped\n"); } // get rid of the interpreter if (imview_interpreter) { // this should free the interpreter resources such as shared memory, // semaphores, etc. delete imview_interpreter; imview_interpreter = 0; } #endif // if the user asked for physical deletion, just do it if (deleteAfter) { while ((p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID)) != 0) { // be a bit conservative: remove the image only if it is in one of the tmp directories if (strstr(p->itempath, "/tmp/") != 0) { dbgprintf("Physically deleting the image %s\n", p->itempath); unlink(p->itempath); } else { dbgprintf("Not deleting %s after all\n", p->itempath); } mainMenuBar->removeFromItemList(p->itempath, IMAGE_LIST_ID); // this will change the selection... p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); // therefore it is NO LONGER the same image as above } } // delete allocated memory if (extpathlist != 0) { while (extpathlist[j] != 0) free(extpathlist[j++]); delete[] extpathlist; } // did we create a temporary file? if (imTempFileName) { unlink(imTempFileName); free(imTempFileName); } // delete the temporary files in the Postscript map for (q = psfilemap.begin() ; q != psfilemap.end() ; q++) { dbgprintf("Erasing %s, associated with file : %s\n", ((q->second).getfilename()).c_str(), (q->first).c_str()); unlink((q->second).getfilename().c_str()); } // empty the map psfilemap.clear(); // what happens if we do that? delete PtFileMngr; // get rid of semaphores semaphore_destroy(&access_error); semaphore_destroy(&access_debug); if (!do_abort) { dbgprintf("Final message, after that is exit\n"); if (!zimageArgs) exit(status + (srval << 4)); else exit(255); // z-image requires this as the exit status } else { dbgprintf("Boy, we caught a deadly signal\n"); abort(); // this will override any abort handler } } /* send this process to the background, possibly waiting for some data from the child */ #ifndef WIN32_NOTCYGWIN static void experimental_sync(void) { #if !defined(MACOSX_CARBON) && !defined(__CYGWIN__) // No X with Darwin or Cygwin dbgprintf("Syncing with X... \a"); XSync(fl_display, False); dbgprintf("Done\b"); #endif hasSynced = true; } void unix_jobbg(void) { // the following lines are a bit complicated // if a server is started and we are asked to put ourselves in the background // A file is open in read/write mode. The client will // block on read, waiting for the server to fill the file with // one integer: the port number the server is bound to. // If we are in Z-IMAGE mode we put ourselves in the background // a fork is performed. if (startServer && performFork) { // make a pipe between client and server if (pipe(pipepair) < 0) { fprintf(stderr, "Could not create a pipe between parent and child: %s\n", strerror(errno)); exit(10); } portfileDescriptor = pipepair[1]; // for the client (the child) if (portfileDescriptor == -1) { fprintf(stderr, "Could not open pipe: %s", strerror(errno)); exit(11); } } if ((zimageArgs || performFork) && (fork()!=0)) { /* parent process */ if (performFork && startServer) { // block on read from pipe portfileDescriptor = pipepair[0]; if (debugIsOn) fprintf(stderr, "Waiting for port number to appear\n"); int nbr = read(portfileDescriptor, (void *)&serverPortNumber, sizeof(int)); if (nbr != sizeof(int)) { fprintf(stderr, "Port number not returned in pipe\n"); serverPortNumber = 0; } else { if (debugIsOn) fprintf(stderr,"Port number returned successfully: %d\n", serverPortNumber); } // at any rate, close the file-pipe close(portfileDescriptor); // maybe save the port number if (portfilename[0] == '\0') { printf("Port: %d\n", serverPortNumber); } else { FILE *fp = fopen(portfilename, "w"); if (fp != NULL) { fprintf(fp, "%d\n", serverPortNumber); fclose(fp); } else { fprintf(stderr, "Could not write port number %d to file %s: %s\n", serverPortNumber, portfilename, strerror(errno)); } } } /* then call exit()--*/ delete PtFileMngr; semaphore_destroy(&access_error); semaphore_destroy(&access_debug); myusleep(100000); // we seem to need this on some systems for the server port to be truly registered. if (zimageArgs) exit(255); // required, means: no output image else exit(0); // we shouldn't use the return status anyway } srv_dbgprintf("Child process (server) started\n"); /* child */ return; } // Darwin's fork() does not play nice with Carbon // We need to do an exec() right after fork for it to be safe // We also need to do some command line hacking like with NT. void darwin_jobbg(int argc, char *argv[]) { // the following lines are a bit complicated // if a server is started and we are asked to put ourselves in the background // A file is open in read/write mode. The client will // block on read, waiting for the server to fill the file with // one integer: the port number the server is bound to. // If we are in Z-IMAGE mode we put ourselves in the background // a fork is performed. if (startServer && performFork) { // make a pipe between client and server if (pipe(pipepair) < 0) { fprintf(stderr, "Could not create a pipe between parent and child: %s\n", strerror(errno)); exit(10); } portfileDescriptor = pipepair[1]; // for the client (the child) if (portfileDescriptor == -1) { fprintf(stderr, "Could not open pipe: %s", strerror(errno)); exit(11); } } if (zimageArgs || performFork) { if (fork()!=0) { /* parent process */ if (performFork && startServer) { // block on read from pipe portfileDescriptor = pipepair[0]; if (debugIsOn) fprintf(stderr, "Darwin O/S, waiting for port number to appear\n"); int nbr = read(portfileDescriptor, (void *)&serverPortNumber, sizeof(int)); if (nbr != sizeof(int)) { fprintf(stderr, "Darwin O/S: port number not returned in pipe\n"); serverPortNumber = 0; } else { if (debugIsOn) fprintf(stderr,"Darwin O/S: port number returned successfully: %d\n", serverPortNumber); } // at any rate, close the file-pipe close(portfileDescriptor); // maybe save the port number if (portfilename[0] == '\0') { printf("Darwin O/S, port: %d\n", serverPortNumber); } else { FILE *fp = fopen(portfilename, "w"); if (fp != NULL) { fprintf(fp, "%d\n", serverPortNumber); fclose(fp); } else { fprintf(stderr, "Could not write port number %d to file %s: %s\n", serverPortNumber, portfilename, strerror(errno)); } } } /* then call exit()--*/ delete PtFileMngr; semaphore_destroy(&access_error); semaphore_destroy(&access_debug); myusleep(100000); // we seem to need this on some systems for the server port to be truly registered. if (zimageArgs) exit(255); // required, means: no output image else exit(0); // we shouldn't use the return status anyway } else { /* child */ srv_dbgprintf("Child process (server) started\n"); // Unixery char *cleanedCmd[DFLTSTRLEN]; int i, cmdlen, l; srv_dbgprintf("Darwin process `backgroundisation'\n"); // empty string memset(cleanedCmd, 0, DFLTSTRLEN); // all NULL pointers for (i = 0, cmdlen = 0 ; i < argc ; i++) { // replace the -fork argument... if (strcmp(argv[i], "-fork") == 0) cleanedCmd[i] = "-darwinchild"; else cleanedCmd[i] = argv[i]; // pointer copy should be OK if (i >= DFLTSTRLEN-1) break; // last argument. } srv_dbgprintf("Cleaned command has %d entries, looks likes this:\n", i); for (l = 0 ; l < i ; ++l) srv_dbgprintf("%s ", cleanedCmd[l]); srv_dbgprintf("\n"); // redirect port descriptor to standard error (double redirection) dup2(portfileDescriptor, 2); close(portfileDescriptor); // not needed after redirection // now simply exec that command. if (execvp(cleanedCmd[0], cleanedCmd) != 0) { srv_dbgprintf("Execvp failed with error %d, %s\n", strerror(errno)); if (zimageArgs) exit(255); // no output image else exit(1); // didn't work } srv_dbgprintf("Should not get there: exit call\n"); exit(0); // shouldn't get there } } if (darwinChild) { srv_dbgprintf("In the exec()ed child\n"); } /* child */ return; } #else // #ifndef WIN32_NOTCYGWIN #include <windows.h> #include <process.h> static void experimental_sync(void) { dbgprintf("WIN32 syncing: nothing to do\n"); hasSynced = true; } // here we have no fork and pipes are hard to use, we'll try // with CreateProcess (dead slow) and mailslots. // Inspired by the book `win32 system programming' by J. M. Hart // all other considerations apart, I find the code horrible to look at... void nt_jobbg(int argc, char **argv) { if (performFork) { STARTUPINFO StartUp; PROCESS_INFORMATION ProcessInfo; HANDLE hReadPipe, hWritePipe; // Unixery char cleanedCmd[DFLTSTRLEN], singleArg[100]; int i, cmdlen, l; dbgprintf("Win32/NT process `backgroundisation'\n"); // empty string memset(cleanedCmd, 0, DFLTSTRLEN); for (i = 0, cmdlen = 0 ; i < argc ; i++) { // replace the -fork argument... if (strcmp(argv[i], "-fork") == 0) strcpy(singleArg, "-ntchild"); else strncpy(singleArg, argv[i], 100); // concatenate the rest l = strlen(singleArg); // don't write past the end if (cmdlen + l >= 1023) break; else cmdlen += l; strcat(cleanedCmd, singleArg); strcat(cleanedCmd, " "); // one space } dbgprintf("Cleaned command is: %s\n", cleanedCmd); GetStartupInfo (&StartUp); // are we also starting the server? if so the parent will need to know the port number... // we'll use an anonymous pipe to pass the number to the parent. if (startServer) { SECURITY_ATTRIBUTES PipeSA = {sizeof (SECURITY_ATTRIBUTES), NULL, TRUE}; // for the pipe if (!CreatePipe(&hReadPipe, &hWritePipe, &PipeSA, 0)) errprintf("Could not create anonymous pipe to get port number\n"); // we continue anyway else { // the child's standard output will be through the pipe StartUp.hStdInput = GetStdHandle (STD_INPUT_HANDLE); StartUp.hStdError = GetStdHandle (STD_ERROR_HANDLE); StartUp.hStdOutput = hWritePipe; StartUp.dwFlags = STARTF_USESTDHANDLES; } } if (!CreateProcess (NULL, // image Name. Not needed for some reason _T(cleanedCmd), // command line (arguments). Cleaned of -fork NULL, // default process security NULL, // default thread security TRUE, // Inherits handles (files, etc) 0, // DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP, // no console of its own, running, new group NULL, // use parent's environment (search path, etc) NULL, // starts in current (parent's) directory &StartUp, // get the startup information &ProcessInfo)) { // get the process information errprintf("Process %s could not be started\n", cleanedCmd); // we will die here } else { if (startServer) { DWORD rb; // wait for the child to send something down the pipe if (!ReadFile(hReadPipe, (LPVOID)&serverPortNumber, (DWORD)sizeof(int), &rb, NULL)) { errprintf("Could not read port number from child\n"); } else { dbgprintf("Parent: read %d bytes, port number: %d\n", rb, serverPortNumber); if (portfilename[0] == '\0') { printf("Port: %d\n", serverPortNumber); } else { FILE *fp = fopen(portfilename, "w"); if (fp != NULL) { fprintf(fp, "%d\n", serverPortNumber); fclose(fp); } else { fprintf(stderr, "Could not write port number %d to file %s: %s\n", serverPortNumber, portfilename, strerror(errno)); } } } CloseHandle(hReadPipe); CloseHandle(hWritePipe); } CloseHandle (ProcessInfo.hThread); CloseHandle (ProcessInfo.hProcess); dbgprintf("New job started, pid=%d\n", ProcessInfo.dwProcessId); } /* then call exit()--*/ delete PtFileMngr; semaphore_destroy(&access_error); semaphore_destroy(&access_debug); if (zimageArgs) exit(255); // required, means: no output image else exit(0); // we shouldn't use the return status } else if (ntChild) { /* child */ dbgprintf("The Child is running\n"); if (startServer) portfileDescriptor = 1; // The portfile descriptor is just stdout = 1 } return; } #endif // #ifndef WIN32_NOTCYGWIN // Main function: entry point of the code. int main(int argc, char **argv) { int i; char **imageList, **clutList; const char *p; char zetcdir[DFLTSTRLEN]; const char *clutpathlist[7]; double defaultZoom; #if 0 // temporary debug FILE *dbgargs; dbgargs = fopen("/tmp/imviewargs.txt", "w"); for (i = 0 ; i < argc ; ++i) fprintf(dbgargs, "%03d: %s\n", i, argv[i]); fclose(dbgargs); #endif // 0 installpath[0] = '\0'; // empty install path p = myDirName(argv[0]); if (p != NULL) strncpy(runningpath, p, DFLTSTRLEN); else runningpath[0] = '\0'; // we use both printf and cout, therefore: // sync_with_stdio(); // the semaphores are needed right now because // imdebug & co use them, even if there is only one thread semaphore_init(&access_debug); semaphore_init(&access_error); // setup random number generator #ifdef WIN32_NOTCYGWIN srand(time(NULL)); #else srandom(time(NULL)); #endif // the pointfile might be specified in the arguments // we need to define it early PtFileMngr = new pointfile; #ifdef MACOSX_CARBON // register an "open callback" fl_open_callback(openfile_cb); Fl::scheme("plastic"); // more aqua like #else Fl::scheme(NULL); #endif // now we can check the arguments, // returns an image list and an attached colour LUT list. checkArgs(argc, argv, &imageList, &clutList, &defaultZoom, &persistentGamma); // make sure we get the best display available // Only a problem on Suns so far Fl::visual(FL_RGB|FL_DOUBLE|FL_INDEX); // experiment: early fork #ifdef WIN32_NOTCYGWIN nt_jobbg(argc, argv); #elif defined(DARWIN) darwin_jobbg(argc, argv); #else unix_jobbg(); #endif // Useful for the file chooser Fl_File_Icon::load_system_icons(); if (performFork) srv_dbgprintf("After load_system_icons()\n"); // initializes the Image Magick Library initImageMagick(argv[0]); // only has an effect if ImageMagick is compiled in if (performFork) srv_dbgprintf("After initImageMagick()\n"); // get the screen's dimensions // // old code // fl_open_display(); // appMaxWidth = XDisplayWidth(fl_display, fl_screen); // appMaxHeight= XDisplayHeight(fl_display, fl_screen); // new, more portable code appMaxWidth = Fl::w(); appMaxHeight = Fl::h(); // read the user preferences readUserPrefs(); if (performFork) srv_dbgprintf("After readUserPrefs()\n"); // useful when debugging, in effect only then. synchronize_GUI(); if (performFork) srv_dbgprintf("After synchronize_GUI()\n"); // maybe don't show the menu hideMainMenu |= fileprefs->hideMenu(); // hide menu from both the command line or the saved preferences if (hideMainMenu) menuheight = 0; else menuheight = MENUHEIGHT; // I don't like these arbitrary limits anymore Hugues Talbot 5 Sep 2003 //if (appMaxWidth > MINWIDTH+20) appMaxWidth -= 10; // window decoration on either side if (appMaxHeight > MINHEIGHT+MENUHEIGHT) appMaxHeight -= menuheight; dbgprintf("Application max window size are:%d x %d\n", appMaxWidth, appMaxHeight); // allocate the diverse components of the application mainWindow = new imviewWindow(SWIDTH, SHEIGHT - (MENUHEIGHT-menuheight) ); mainWindow->size_range(MINWIDTH,MINHEIGHT,appMaxWidth,appMaxHeight); if (disableQuit) mainWindow->callback(noquit_cb); if (performFork) srv_dbgprintf("New window allocated\n"); mainMenuBar = new imViewMenuBar(0,0,SWIDTH,menuheight); mainViewer = new imageViewer(0, menuheight, SWIDTH, SHEIGHT - MENUHEIGHT); mainWindow->end(); // this is the end of this group IOBlackBox = new imageIO; // give the imageIO to the mainViewer mainViewer->setImageIO(IOBlackBox); mainWindow->resizable(mainViewer); // set the name of the application up if not already done if (appName[0] == '\0') { strcpy(appName, myBaseName(argv[0])); mainWindow->iconlabel(appName); } // hunt for colour LUT files clutpathlist[0] = "."; p = getenv("ZHOME"); clutpathlist[1] = (p == 0) ? "":p; // some strange manipulation to append /etc strcpy(zetcdir, clutpathlist[1]); strcat(zetcdir, "/etc"); clutpathlist[1] = (const char *)zetcdir; p = getenv("IMVIEWHOME"); clutpathlist[2] = (p == 0) ? "":p; clutpathlist[3] = PrefPath; // defined in imcfg.h at configuration time #ifdef MACOSX_CARBON char AppContainerPath[DFLTSTRLEN]; strncpy(AppContainerPath, runningpath, DFLTSTRLEN); strncat(AppContainerPath, "/../Resources", DFLTSTRLEN); clutpathlist[4] = AppContainerPath; clutpathlist[5] = 0; #else clutpathlist[4] = 0; #endif huntCLUT(clutpathlist); if (performFork) srv_dbgprintf("HuntClut done\n"); // sets the default point file if possible and necessary if (!PtFileMngr->getPtFileName()) { PtFileMngr->setPtFileName(DEFAULTPF); } // apply the default zoom factor if reasonable if (defaultZoom > 0) { mainViewer->setDefaultZoomFactor(defaultZoom); mainViewer->resetDisplay(false,true); } else errprintf("Default zoom factor %f ignored\n", defaultZoom); // display the images given on the command line displayImages(imageList, clutList); if (performFork) srv_dbgprintf("After displayImages()\n"); // initialize the gamma transfer panel if need be if (persistentGamma != 1.0) { transferEditorPanel = new transfer; transfer &transferref = *transferEditorPanel; // initializes the fluid-generated panel transfer_panel(transferref); // do our own initialisation transferEditorPanel->setDefaults(); // do not show it though } if (performFork) srv_dbgprintf("About to put main window on screen\n"); // show the main window mainWindow->show(argc, argv); if (performFork) srv_dbgprintf("Putting main window on screen\n"); // initialize the file chooser fl_file_chooser_callback(filechooser_cb); // free the image list & the clut list if (zimageArgs) { i = -1; while (imageList[++i] != 0) if (clutList[i] != 0) free(clutList[i]); // all those names have been strdup'ed } delete[] imageList; delete[] clutList; // read the current pointfile if the user desires to if (appendPoints) PtFileMngr->readlist(); #ifdef HAVE_PTHREADS // surrogate for HAVE_SERVER if (startServer) {// do it // allocate an interpreter (no need for it otherwise) imview_interpreter = new interpreter; start_server(); // in its own thread if (performFork) srv_dbgprintf("Server started!\n"); } #endif // If the rawImagePanel is non-null at this point, this means the user is // trying to read an unrecognized-formatted image. Unfortunately the `unknown image format' // panel is created before the main panel, which hides it by default. We need to put it back // on top. 8 Jun 2000 if (rawImagePanel != 0) rawImagePanel->show(); // sets the system menu (if it exists) mainMenuBar->setSysMenu(); // loop forever if (performFork) srv_dbgprintf("About to call run()\n"); // our global run function run(); return 0; } ����������������������imview-1.1.9c/imview.hxx����������������������������������������������������������������������������0000644�0000765�0000765�00000025744�10720351523�016036� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: imview.hxx,v 4.5 2007/11/19 18:17:55 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Main include file for imview, an application for displaying image * under X11 and the Windows (tm) GDI. * * Hugues Talbot 26 Oct 1997 * * Usage is free of charge for anyone under no guarantee whatsoever, * expressed or implied. * *-----------------------------------------------------------------------*/ #ifndef IMVIEW_H #define IMVIEW_H #include <imcfg.h> // defines all sorts of things... #include <string> #include <FL/Fl.H> #include <FL/Fl_Menu.H> #include <FL/Fl_Menu_Bar.H> #ifndef WIN32 //#include <vector> // OK, a header that defines needs to be included //using namespace std; #endif using std::string; // Constants #define SHEIGHT 400 #define SWIDTH 600 #define MINHEIGHT 100 #define MINWIDTH 280 #define MAXWIDTH 1024 #define MAXHEIGHT 768 #define MENUHEIGHT 30 #define TBOXWIDTH 460 #define TBOXHEIGHT 100 #define DFLTSTRLEN 1024 #define SMALSTRLEN 128 #define MAX_FL_COLOURS 292 // a weird number, but heh. // Installation path #if !defined(PrefPath) #define PrefPath "/usr/local/share/Imview" #endif #ifdef WIN32 // win32 doesn't have basename(), so we do the bit by hand # define IMVIEW "imview" # define PATHSEP ',' // Windows/DOS path use :, as in D:\mydir # define SLASH '\\' #else # define PATHSEP ':' // traditionally, Unix path use : as separators # define SLASH '/' // POSIX directory slash #endif // prefix to debug messages #define DEBUGPROMPT "Imview> " #define SRVDBGPRMPT "Server Imview> " #define SRVIDBGPRMPT "Server Internal> " #define ERRORPROMPT "**error** Imview> " // default point file name #define DEFAULTPF "pointfile" #define ANNOTEHDR "# annotation: " // overlay image marker #define OVERLAY_MARKER "<overlay>" // default port file name #define DEFAULT_PORT_FILE "portfile" #define PF_MAX_LEN 1023 // max length of port file name #define CLUT_SUFFIX ".lut" // trivial macros #ifndef trivmin #define trivmin(x,y) ((x) > (y)) ? (y):(x) #endif #ifndef trivmax #define trivmax(x,y) ((x) < (y)) ? (y):(x) #endif // page sizes // needed by both io/cpostscript.cxx and io/readps.cxx typedef enum { PAGESIZE_AUTO = 0, PAGESIZE_A5, PAGESIZE_B5, PAGESIZE_A4, PAGESIZE_LETTER, PAGESIZE_LEGAL, PAGESIZE_A3, PAGESIZE_NB /* size of array needed */ } page_size; // image types and pixel types typedef enum { IM_INVALID = 0, IM_BINARY=10, IM_CHAR=31, IM_INT1 = 31, IM_UINT1 = 30, IM_SHORT = 35, IM_INT2 = 35, IM_UINT2 = 37, IM_INT = 40, IM_INT4 = 40, IM_UINT4 = 42, IM_INT8 = 43, IM_UINT8 = 44, IM_FLOAT=45, IM_DOUBLE=50 } pixtype; /*-- Multi-component image types --*/ typedef enum { IM_ERROR=0, IM_UNSPEC, IM_SINGLE, IM_SPECTRUM, IM_RGB, IM_HLS } imgtype; /* the colour used in the bivariate histogram */ typedef enum {BHPBlack = FL_BLACK, BHPRed=FL_RED, BHPGreen=FL_GREEN, BHPYellow=FL_YELLOW, BHPBlue=FL_BLUE, BHPMagenta=FL_MAGENTA, BHPCyan=FL_CYAN } BHPColour; // the valid image formats typedef enum { TIFF_FMT = 0, ZIMAGE_FMT = 1, EURO_FMT = 2, PNG_FMT = 3, JPG_FMT = 4, LAST_FMT = 5 } imgfmt; // panel IDS typedef enum{SPECTRAPANEL=0, PROFILEPANEL} paneltype; // orientations typedef enum { STR_NE=0, STR_SE, STR_SW, STR_NW, STR_QUAD_MAX } str_quadrant; // endianness typedef enum { ENDIAN_DEFAULT=0, ENDIAN_BIG, ENDIAN_LITTLE, ENDIAN_UNKNOWN } endianness; // filemap class image_psfile { public: image_psfile(void) {} image_psfile(const image_psfile &i) {filename_ = i.getfilename(); hash_ = i.gethash();} image_psfile(const string &fn, const string &hh) {filename_ = fn; hash_ = hh;} image_psfile& operator=(image_psfile &i) { if (this == &i) return *this; // nothing more filename_ = i.getfilename(); hash_ = i.gethash(); } const string getfilename(void) const {return filename_;} void setfilename(const string &s) {filename_ = s;} const string gethash() const {return hash_;} void sethash(const string &s) {hash_ = s;} private: string filename_; string hash_; }; // simple useful typedefs typedef unsigned char uchar; // this structure is used to store extra information // about the images in the image list. typedef struct image_parm { char *itempath; // used to index the structure... char *clutpath; // path to the CLUT used by the image char *ovlpath; // path to overlay, if any char *pfpath; // path to pointfile, if any int zslice; // 3rd dimension slice to display int comp; // component to show int frame; // frame to show int nbframes; // total number of frames in image float gamma; // gamma factor to be used float contrast; // contrast to use float brightness; // same for brightness double Rgamma, Rbrightness, Rcontrast; // RGB version double Ggamma, Gbrightness, Gcontrast; double Bgamma, Bbrightness, Bcontrast; float angle; // Remember the angle char mirror; // Remember the mirror state (0 or 1) struct item_xtra *next; // next in list } IMAGEPARM; // image header, useful when receiving raw binary data typedef struct imagecomp_header { int nx, ny, nz; // size int ox, oy, oz; // offset imgtype imgt; // types pixtype pixt; // .... int spp; // samples per pixel void **buffp; // array of buffers (one per spectrum.) } IMAGECOMP_HEADER; typedef struct image_header { char *label; // image name or label unsigned int unique_id; // necessary to find the right buffer, assumed to be 4 bytes unsigned int previous_id; // ID of previous buffer unsigned int expected_size; bool needswap; // if the data comes from a diffent-endian machine int nbc; // nb of components void *rawdata; // pointer to raw data, needed when freed. IMAGECOMP_HEADER *comp; // array of components } IMAGE_HEADER; // this structure is sufficiently different from the `socket' raw data // that it warrants its own type. typedef struct rawfile_header { int nx, ny, nz; int spp; endianness byo; // sample per pixels = nb of bands; byo = byte ordering int itl; // interleave type pixtype pixt; int filesize; // if changed! int skip; // need to remember this too! } RAWFILE_HEADER; // the `bivariate histogram point' class. Has to be small class BHPoint { public: BHPoint(void) { return;} BHPoint(BHPColour c, int i, double dx, double dy) { colour = c; imgOffset = i; Xvalue = dx; Yvalue = dy; } BHPColour colour; // 255 different colours should be enough int imgOffset; // offset in the original image. Enough for a cube 1600 pixels aside. double Xvalue, Yvalue; // values of the point in both components. }; // this predicate class to be used to sort the points class cmpBHPoints { public: bool operator() (const BHPoint &a, const BHPoint &b) const; }; // this structure for rectangle selection typedef struct SelectionRectangle { int x, y, w, h; } SELRECT; // prototypes for C-like functions void run(void); Fl_Menu_Bar *makeMenu(void); // this functions checks the argument and return an image list. void huntCLUT(const char **clutpathlist); void checkArgs(int argc, char **argv, char ***imlist, char ***lutlist); void showSimpleBanner(void); void removeSimpleBanner(void); void displayImages(char **imageList, char **lutList); void filechooser_cb(const char *name); int arg_cb(int argc, char **argv, int &i); // server startup function void start_server(void); // exit/cleanup function void imview_exit(int status, bool abort = false); // debugging function int dbgprintf(const char *msg, ...); int stderrprintf(const char *msg, ...); int srv_dbgprintf(const char *msg, ...); int srv_internal_dbgprintf(const char *msg, ...); int srv_printf(const char * msg,...); // error printing function int errprintf(const char *msg, ...); // warning printing function int warnprintf(const char * msg,...); // utility colour function Fl_Color fl_closest_colour(uchar r, uchar g, uchar b); Fl_Color fl_closest_index(int i); // from the FL directory // defines the very important snprintf #if !HAVE_SNPRINTF #include <stdio.h> #include <stdarg.h> extern "C" { int snprintf(char* str, size_t size, const char* fmt, ...); } #endif /* !HAVE_SNPRINTF */ #if !HAVE_VSNPRINTF #include <stdio.h> #include <stdarg.h> extern "C" { int vsnprintf(char* str, size_t size, const char* fmt, va_list ap); } #endif /* !HAVE_VSNPRINTF */ // puzzling missing prototype // not missing anymore in RH >= 5.0 // missing againg in 6.1 //#ifdef Linux //extern "C" { // const char *basename(const char *name); //} //#endif #if defined(Solaris) || defined(Linux) #include <libgen.h> // isn't that totally incredible? #endif #endif ����������������������������imview-1.1.9c/imview.list.in������������������������������������������������������������������������0000644�0000765�0000765�00000007136�07653236466�016625� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# $Id: imview.list.in,v 4.0 2003/04/28 14:39:50 hut66au Exp $ # # Packaging information for the imview software using the ESP Package Manager # # Copyright Hugues Talbot 2001 hut66au@users.sourceforge.net # # # directories $prefix=@prefix@ $srcdir=@srcdir@ # Product information %product imview Image Viewing and Analysis %copyright 1997-2001 Hugues Talbot, All Rights Reserved. %vendor Commonwealth Scientific and Industrial Research Organization (CSIRO) %license ${srcdir}/COPYING %readme ${srcdir}/distrib/binaries/README %description Image display and analysis tool %version @MAJOR_VERSION@.@MINOR_VERSION@.@MICRO_VERSION@ %prefix $prefix %relocatable true # post installation script %install share/Imview/imview_post_install.sh %system all # directories d 0755 root sys share/Imview/doc d 0755 root sys share/Imview # Executables f 0755 root sys bin/imview $srcdir/support/imview.sh f 0755 root sys bin/imview.bin imview f 0755 root sys share/Imview/imview_post_install.sh ${srcdir}/distrib/binaries/imview_post_install.sh # Online documentation f 0644 root sys share/Imview/doc/README $srcdir/README f 0644 root sys share/Imview/doc/COPYING $srcdir/COPYING f 0644 root sys share/Imview/doc/ChangeLog $srcdir/ChangeLog f 0644 root sys share/Imview/doc/ $srcdir/doc/quickhelp*.html f 0644 root sys share/Imview/doc/gpl.html $srcdir/doc/gpl.html f 0644 root sys share/Imview/doc/warranty.html $srcdir/doc/warranty.html # Man page f 0644 root sys man/man1/imview.1 $srcdir/doc/imview.1 # look-up tables f 0644 root sys share/Imview/NeWSfb.lut $srcdir/support/NeWSfb.lut f 0644 root sys share/Imview/binary.lut $srcdir/support/binary.lut f 0644 root sys share/Imview/blue.lut $srcdir/support/blue.lut f 0644 root sys share/Imview/green.lut $srcdir/support/green.lut f 0644 root sys share/Imview/heat.lut $srcdir/support/heat.lut f 0644 root sys share/Imview/hue.lut $srcdir/support/hue.lut f 0644 root sys share/Imview/inv_binary.lut $srcdir/support/inv_binary.lut f 0644 root sys share/Imview/inv_grey.lut $srcdir/support/inv_grey.lut f 0644 root sys share/Imview/inv_heat.lut $srcdir/support/inv_heat.lut f 0644 root sys share/Imview/inv_rainbow.lut $srcdir/support/inv_rainbow.lut f 0644 root sys share/Imview/inv_spec.lut $srcdir/support/inv_spec.lut f 0644 root sys share/Imview/inv_spiral.lut $srcdir/support/inv_spiral.lut f 0644 root sys share/Imview/overlay_blue.lut $srcdir/support/overlay_blue.lut f 0644 root sys share/Imview/overlay_cyan.lut $srcdir/support/overlay_cyan.lut f 0644 root sys share/Imview/overlay_green.lut $srcdir/support/overlay_green.lut f 0644 root sys share/Imview/overlay_magenta.lut $srcdir/support/overlay_magenta.lut f 0644 root sys share/Imview/overlay_red.lut $srcdir/support/overlay_red.lut f 0644 root sys share/Imview/overlay_yellow.lut $srcdir/support/overlay_yellow.lut f 0644 root sys share/Imview/rainbow.lut $srcdir/support/rainbow.lut f 0644 root sys share/Imview/ramps.lut $srcdir/support/ramps.lut f 0644 root sys share/Imview/red.lut $srcdir/support/red.lut f 0644 root sys share/Imview/regions.lut $srcdir/support/regions.lut f 0644 root sys share/Imview/regions1.lut $srcdir/support/regions1.lut f 0644 root sys share/Imview/rg.lut $srcdir/support/rg.lut f 0644 root sys share/Imview/rgb.lut $srcdir/support/rgb.lut f 0644 root sys share/Imview/spectrum.lut $srcdir/support/spectrum.lut f 0644 root sys share/Imview/spiral.lut $srcdir/support/spiral.lut f 0644 root sys share/Imview/std_grey.lut $srcdir/support/std_grey.lut # Splash image f 0644 root sys share/Imview/imview_banner.jpg $srcdir/support/imview_banner.jpg # Man pages # # End of "$Id: imview.list.in,v 4.0 2003/04/28 14:39:50 hut66au Exp $". # ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/imviewWindow.cxx����������������������������������������������������������������������0000644�0000765�0000765�00000016033�10211352061�017201� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*------------------------------------------------------------------------ * * A subclass of the Fl_Window, that has a few nicer features * More specifically, can impose size limit on the window. * * Hugues Talbot 5 Jan 2001 * *-----------------------------------------------------------------------*/ #include "imview.hxx" #include "imviewWindow.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "menubar.hxx" #include <assert.h> extern imageViewer *mainViewer; extern imViewMenuBar *mainMenuBar; imviewWindow::imviewWindow(int w, int h, const char *label) #ifdef IMVIEW_USES_DBLBUF : Fl_Overlay_Window(w,h,label) #else : Fl_Window(w, h, label) #endif { w_lower_limit = w_upper_limit = h_lower_limit = h_upper_limit = -1; zoomSelRect.w = zoomSelRect.h = -1; #ifdef HAVE_XINERAMA screens = 0; xinerama_screen = -1; #endif return; } imviewWindow::imviewWindow(int x, int y, int w, int h, const char *label) #ifdef IMVIEW_USES_DBLBUF : Fl_Overlay_Window(x,y,w,h,label) #else : Fl_Window(x,y,w,h,label) #endif { w_lower_limit = w_upper_limit = h_lower_limit = h_upper_limit = -1; zoomSelRect.w = zoomSelRect.h = -1; return; } imviewWindow::~imviewWindow() { return; } void imviewWindow::removeMainMenu(void) { int hh = h() - MENUHEIGHT; dbgprintf("imviewWindow: removing main menu\n"); // removing all from group: remove(mainMenuBar); remove(mainViewer); h_lower_limit -= MENUHEIGHT; size(w(), h()-MENUHEIGHT); // resize main window to smaller size mainMenuBar->resize(0,0,w(),0); mainViewer->resize(0,0,w(),hh); // smaller size here add(mainViewer); add(mainMenuBar); dbgprintf("imviewWindow: done\n"); return; } void imviewWindow::addMainMenu(void) { int hh = h() + MENUHEIGHT; dbgprintf("imviewWindow: adding main menu\n"); // need to do that to avoid spurious resizes by the toolkit remove(mainMenuBar); remove(mainViewer); h_upper_limit += MENUHEIGHT; size(w(), hh); // resizes main window to accomodate menu mainViewer->resize(0,MENUHEIGHT, w(), hh); mainMenuBar->resize(0,0,w(), MENUHEIGHT); add(mainViewer); add(mainMenuBar); dbgprintf("imviewWindow: done\n"); return; } // resize with limits. // I don't understand why FLTK's limit dont work. void imviewWindow::resize(int x,int y, int w, int h) { bool change = false; assert(mainViewer); displaymode m = mainViewer->getdisplaymode() ; if (m == IMV_DISPLAY_WINDOW_FIT_IMG) { dbgprintf("Main window asked to resize to: %dx%d+%d+%d\n", w,h,x,y); // looking for weird resizes coming from the WM if ((w == SWIDTH) && (h == SHEIGHT) && (w != w_upper_limit) && (h != h_upper_limit)) { dbgprintf("Weird resize coming from the windows manager. Resize denied!\n"); return; // HA! } if ((w_upper_limit > 0) && (w > w_upper_limit)) { w = w_upper_limit; change = true; } if ((h_upper_limit > 0) && (h > h_upper_limit)) { h = h_upper_limit; change = true; } if ((w_lower_limit > 0) && (w < w_lower_limit)) { w = w_lower_limit; change = true; } if ((h_lower_limit > 0) && (h < h_lower_limit)) { h = h_lower_limit; change = true; } if (change) dbgprintf("In fact resizing to: %dx%d+%d+%d\n", w,h,x,y); else dbgprintf("Resize accepted\n"); } else if (m == IMV_DISPLAY_IMG_FIT_WINDOW) { dbgprintf("Stretch to fit mode\n"); } else if (m == IMV_DISPLAY_DECOUPLE_WIN_IMG) { dbgprintf("Decoupled display mode\n"); } #ifdef IMVIEW_USES_DBL Fl_Overlay_Window::resize(x,y,w,h); #else Fl_Window::resize(x,y,w,h); #endif return; } void imviewWindow::size_range(int minw, int minh, int maxw, int maxh, int dw, int dh, int aspect) { w_lower_limit = minw; w_upper_limit = maxw; h_lower_limit = minh; h_upper_limit = maxh; dbgprintf("Limits set to [%dx%d--%dx%d]\n", minw, minh, maxw, maxh); #ifdef IMVIEW_USES_DBL Fl_Overlay_Window::size_range(minw, minh, maxw, maxh, dw, dh, aspect); #else Fl_Window::size_range(minw, minh, maxw, maxh, dw, dh, aspect); #endif return; } // This is the way an overlay needs to be drawn now. // We allow for rectangle selections, lines, etc. void imviewWindow::draw_overlay(void) { dbgprintf("Draw_overlay called\n"); if (zoomSelRect.w > 0 && zoomSelRect.h > 0 ) { dbgprintf("Drawing rectangular overlay: (%d,%d),(%d x %d)\n", zoomSelRect.x, zoomSelRect.y, zoomSelRect.w, zoomSelRect.h); fl_color(FL_RED); fl_rect(zoomSelRect.x, zoomSelRect.y, zoomSelRect.w, zoomSelRect.h); } return; } int imviewWindow::currentDisplayWidth(void) { int w = Fl::w(); #ifdef HAVE_XINERAMA // expensive call, how to speed that up? if (XineramaIsActive(fl_display)) { getXineramaInfo(); w = screens[xinerama_screen].width; } #endif return w; } int imviewWindow::currentDisplayHeight(void) { int h = Fl::h(); #ifdef HAVE_XINERAMA // expensive call, how to speed that up? if (XineramaIsActive(fl_display)) { getXineramaInfo(); h = screens[xinerama_screen].height; } #endif return h; } #ifdef HAVE_XINERAMA // put the relevant information in the screens array // and find which screen the mouse is on. void imviewWindow::getXineramaInfo(void) { int num_screens; int currentX, currentY; Fl::get_mouse(currentX, currentY); // get the screens configuration if (!screens) screens = XineramaQueryScreens(fl_display, &num_screens); for (int i = 0 ; i < num_screens ; ++i) { // find out which screen we are on if ((screens[i].x_org <= currentX) && (screens[i].y_org <= currentY) && ((screens[i].x_org+screens[i].width) >= currentX) && ((screens[i].y_org+screens[i].height) >= currentY)) { dbgprintf("xinerama screen is: %d\n", i); xinerama_screen = i; break; } } if (xinerama_screen < 0) { dbgprintf("Could not find suitable screen for some reason, defaulting to 0\n"); xinerama_screen = 0; } return; } // totally replaces the stock fltk methods. void imviewWindow::fullscreen() { if (XineramaIsActive(fl_display)) { getXineramaInfo(); border(0); // Fl_Window public method // resize window to the dimensions of the screen if (x() == screens[xinerama_screen].x_org) x(screens[xinerama_screen].x_org + 1); // force a call to XResizeWindow (?) resize(screens[xinerama_screen].x_org, screens[xinerama_screen].y_org, screens[xinerama_screen].width, screens[xinerama_screen].height); // done } else { // just call the stock member function, it will be fine. Fl_Window::fullscreen(); } return; } #endif // HAVE_XINERAMA �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/imviewWindow.hxx����������������������������������������������������������������������0000644�0000765�0000765�00000003601�10211352061�017203� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*------------------------------------------------------------------------ * * * A subclass of the Fl_Window, that has a few nicer features * * Hugues Talbot 5 Jan 2001 * * Modified 24 Feb 2005: now a subclass of Fl_Overlay_Window to cope with * Mac OS/X Quartz rendering of overlays. * *-----------------------------------------------------------------------*/ #ifndef IMVIEWWINDOW_H #define IMVIEWWINDOW_H #include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/Fl_Overlay_Window.H> #ifdef HAVE_XINERAMA # include <FL/Fl.H> # include <FL/x.H> extern "C" { # include <X11/extensions/Xinerama.h> } #endif // HAVE_XINERAMA class imviewWindow : public #ifdef IMVIEW_USES_DBLBUF Fl_Overlay_Window #else Fl_Window #endif { public: imviewWindow(int w, int h, const char *label = 0); imviewWindow(int x, int y, int w, int h, const char *label=0); ~imviewWindow(); void removeMainMenu(void); void addMainMenu(void); void resize(int x,int y, int w, int h); void size_range(int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0); int currentDisplayWidth(void); int currentDisplayHeight(void); void setZoomSelRect(int x, int y, int w, int h) { dbgprintf("Calling setZoomSelRect\n"); zoomSelRect.x = x ; zoomSelRect.y = y; zoomSelRect.w = w ; zoomSelRect.h = h; } void draw_overlay(void); #ifdef HAVE_XINERAMA // redefine these non-virtual methods with a version that supports Xinerama, if present void fullscreen(void); // fullscreen_off from stock fltk is still compatible. #endif private: int w_lower_limit, w_upper_limit; int h_lower_limit, h_upper_limit; SELRECT zoomSelRect; #ifdef HAVE_XINERAMA int xinerama_screen; XineramaScreenInfo *screens; void getXineramaInfo(void); #endif }; #endif // IMVIEWWINDOW_H �������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/INSTALL�������������������������������������������������������������������������������0000644�0000765�0000765�00000027456�10632004146�015036� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- text -*- # $Id: INSTALL,v 4.4 2007/06/07 13:30:14 hut66au Exp $ # This is Imview's installation documentation: ------------------------------------------- These instruction relate to imview 1.1.x Prerequisite ============ 0- This software works on Unix, MacOS X and Windows. No BeOS, no MacOS prior to OS/X, sorry (please help if you want a version for your favourite O/S). 1- You will need a reasonably ANSI/ISO compliant C++ compiler, The GNU Compiler Collection (GCC) version 3.1 or more recent is such a compiler, that you can get from ftp://prep.ai.mit.edu/pub/gnu/ and various mirrors. Earlier versions of GCC are no longer supported, sorry! The Intel C++ compiler, version 7.0 or later is also fine. On Linux this compiler is free for non-commercial use. On windows, MS Visual C++ version 6.0 patchlevel 3 is fine for the time being but plans are to move to a more recent version (probably version 7.1 a.k.a. .NET 2003). Other compilers might be fine also, YMMV. The configure script will tell you if it thinks your compiler is not up to scratch (and the compilation will probably fail in that case). 2- To build, imview *REQUIRES* FLTK, the Fast Light ToolKit. Get it from http://www.fltk.org Compile it and install it on your machine. As of this writing, the version I used was fltk-1.1.4. NOTE: The flags that I used to compile FLTK were: fltk% ./configure --enable-threads --enable-xft Neither of the two --enable switches are indispensible. NOTE: While this version of imview requires FLTK 1.1.x. FLTK-1.0.x is still supported in a different imview CVS branch, contact the author if you need that version. FLTK works on Mac OS/X, most Unix distributions (including Linux) and on Microsoft Windows (all versions >= win95) as well. Imview will not compile at all until FLTK is available on your system. Very few systems come with FLTK pre-installed (except maybe a very complete Debian Linux distribution...) FLTK itself requires the X11 windowing system OR the windows win32 GDI that comes will all win32 distributions OR the `carbon' environment that comes with MacOS X. All unix systems I know come with X11 (even MacOS X in fact!). Recommended add-ons =================== While FLTK is the only true requirement, Imview will take advantage of the following libraries/enhancements to the O/S: 1- The TIFF library (originally by Sam Leffler): http://www.libtiff.org/ Any version after 3.4beta037 is fine. The current version is 3.5.7. 2- The JPEG library ftp://ftp.uu.net/graphics/jpeg/ I used version v6b. 3- The ImageMagick library. This will add dozens of formats to those that Imview knows of natively, at the cost of a relatively big library (which can be shared). While ImageMagick is somewhat unstable I still recommend you use it. Version 5.x is necessary. http://www.simplesystems.org/ImageMagick/ In turn, ImageMagick may require: 3a- the PNG library ftp://ftp.uu.net/graphics/png/ Current version is 1.0.8 3b- the ZLIB library ftp://ftp.uu.net/pub/archiving/zip/zlib/ Current version is 1.1.3 4- POSIX Threads. Most recent Unix systems come with POSIX-compliant threads, there is a pthread library for win32 available at: ftp://sources.redhat.com/pub/pthreads-win32/ Don't bother with the source, just download the DLLs. Without the image libraries, Imview will be unable to load the corresponding image formats. Theoretically ImageMagick should be enough (it can also read jpeg and tiff images) but its TIFF support is not great. Imview can read just about any TIFF file, not just the common 8 bit-per-channel ones. The native JPEG support is there for historical reasons. Without the POSIX thread library, the Imview server will not run (see the Imview documentation). Most Linux distributions come with all the libraries listed above (except FLTK), one notable exception being the (now defunct) Corel distro. Building Imview =============== 1 Under Unix: ------------- To build imview, normally you only need to do: % ./configure % make % make install 1.1 Options ----------- 1.1.1 Standard options As is standard with every ./configure scripts, lots of options are available. Try ./configure --help for a list of them! If you are not familiar with autoconf-generated ./configure, just about the only really useful one is --prefix, which specifies where to put your software and where to look for libraries. Normally you would put everything under the one hierarchy, by default under /usr/local 1.1.2 Imview-specific options --enable-prof enable prof source profiling support (default is no) --enable-gprof enable gprof source profiling support (default is no) --enable-gcov enable gcov source profiling support (default is no) --without-jpeg disable JPEG support --without-tiff disable TIFF support --without-magick disable ImageMagick support --enable-debug turn on debugging [default=no] --without-server disable image server [default=no] --without-sysv disable Unix SYSV shared memory support [default=no] --with-x use the X Window System Unless you know what you are doing, you shouldn't need to mess with these, except maybe --enable-debug, if you've found a bug in Imview that you want to track (by default, ./configure will set things up to build a production release, optimized without symbols). 1.1.3 A neat trick If you are going to build imview for a number of platform, I suggest that you create a obj/<platform> directory, that you cd to this directory and that you run ../../configure from there. Then build imview the normal way in this directory (just run make). This works VERY well (I use it all the time). The big benefit is of course that you can have as many as these <platform> subdirectories as you want and that you don't need to clean and re-configure between them (if you've got the hard disk space, that is). 2 For windows: ---------------- There are at least three routes to build Imview for win32: 2.1: Use a cross-compiler ------------------------- It is possible to compile Imview with a cross-compiler, this is supported. I cross-compile imview for win32 on both Linux and OS/X. To do that, you need a mingw32 cross compiler, and at configure time, simply specify % [./]configure --host=mingw32 <other options> 2.2: Use GCC under windows -------------------------- There are at least two ways of running GCC under windows: 2.2.1: the mingw32 environment ------------------------------ Mingw32 stands for "minimal" GNU for win32. It uses the GNU tools together with Microsoft's implementation of the ANSI/ISO C and POSIX libraries to make things work. The benefits are that executables are relatively small and portable, and no extra library is necessary besides those that ship with Windows. Point your browser to http://www.mingw.org to download the compiler and the environment. The development tools are in the large MinGW.exe package, and the minimal compiling enviroment (including shell) is called MSYS. This MSYS environment is almost like a normal Unix environment, except it's Windows. To Nowadays MinGW comes with pre-compiled versions of libtiff, libjpeg, libpng and libz, You'll only need to compile FLTK yourself. Also you'll need POSIX threads to be able to run the server, this can be provided by pthread-win32: http://sources.redhat.com/pthreads-win32/ I've yet to succeed in compiling ImageMagick from within mingw, but I'm sure it's feasible, but apart from that the rest of the libraries that imview uses all compile and work fine. To configure and compile Imview, just proceed as under Unix above. 2.2.2: the Cygwin environment ----------------------------- Cygwin is an effort to port the whole Unix environment to Windows: X11, shells, utilities, libraries, and development tools: http://www.cygwin.com From within the cygwin framework you can install pre-compiled version of everything Imview uses: FLTK, libjpeg, libtiff, etc. You can ./configure the cygwin environment exactly as with any other Unix platform, the script will detect your environment and compile imview correctly. It will not require X11 to run, but it will require the Cygwin libraries, which in my opinion makes it an inferior solution to the mingw32 route for portability, but might make sense in your setup. Cygwin provide their own posix thread library, so you don't need the pthread-win32 library that you need if you compile with mingw. Also the ImageMagick library that ships with Cygwin requires X11, so at the moment it's not compatible with imview. At any rate the end result works OK but there are some unresolved issues, see the TODO file. 2.3: Use MSVC++ --------------- The two solutions above work fine for 99% of cases, but I've discovered a bug in the pthread-win32 library that is such that version of Imview compiled with it under any version of GCC for windows will not run well on Windows NT-4.0 on true SMP machines (i.e: If you are running windows NT on a dual-CPU machine or more). This has to do with exception handling. The problem has been reported and might have been fixed but I haven't tested it... It might have gone away with win2k or XP but I seriously doubt it. To make Imview work well with Pthreads on multiple CPUs under NT, you need to compile with MSVC++. A project file is included in the obj/NT-msvc++ directory in this distribution. You will need to edit it (by hand!) to indicate the location of the various libraries (fltk, etc). I used MSVC++ version 6.0 patchlevel 3. Due to poor template support in MSVC++ 6.0, some functionality is reduced, but this should hardly be noticeable to the casual user. BTW, I find MSVC++ about 5 times slower (to compile) than the cross-compiler solution. The end result works fine, of course. 3 For Mac. --------- Imview works very well on MacOS/X. Last tested on 10.4.9, no problem reported. Display uses Aqua/Carbon, not X11, thanks to FLTK support. Support for Cocoa is foreseen for when FLTK-2.0 comes out of alpha. 4 Known issues ================ Known platforms; Imview is known to work on the following platforms Linux glibc-2.x: Redhat 5.x, 6.x, 7.x, 8.x and 9, Fedora FC1-FC6 Debian 2.2 and following, including Ubuntu. DEC Unix (Compaq Tru64) 3.x, 4.x, 5.x Solaris 2.5.1, Solaris 7, Solaris 8, Solaris 9 MS-Windows win32: win9x, win-NT 3.51, win-NT 4.0, win2k, winXP MacOS: Mac OS/X 10.0.3, 10.3.x, 10.4.x I welcome any news on any other platform. Known bugs: ----------- There are a few known bugs. Please see the full documentation. Compilation and installation issues: ----------------------------------- Here are a few non-platform-dependent issues: Warnings: There should be very few warnings when you compile imview, except on Solaris (see below). Depending on your compiler, you will probably see a few in imtranslate.cxx. They relate to template instanciation and can be ignored. Here are a few platform-dependent issues. Solaris: The X11 headers are stuffed, Sun does not provide a set of ANSI-compliant X11 headers: the prototypes are incomplete. Gcc prior to 2.95 just didn't care but suddently from 2.95 it refuses to compile these headers unless the -fpermissive flag is added. The configure script checks for that *BUT* you will most likely get a *TON* of warnings. gcc-2.95.3 has a workaround that works if the set of headers that you use come from /usr/include/X11. Myself I've just patched gcc so this problem disappears. Contact me if you want to get it, it's a one-line change. You may have to specify --x-libraries=/usr/openwin/lib to the configure script if you get an error with the exception structure being multiply defined under Solaris-2.5.1 FINALLY: ======== Thank you for your interest in Imview. Let me know how you go! First version: Hugues Talbot 22 Dec 2000 Last edited: Hugues Talbot 7 Jun 2007 -- Release 1.1.9 ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/install-sh����������������������������������������������������������������������������0000755�0000765�0000765�00000012736�07653236466�016031� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 ����������������������������������imview-1.1.9c/io/�����������������������������������������������������������������������������������0000755�0000765�0000765�00000000000�10756342327�014413� 5����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/.cvsignore�������������������������������������������������������������������������0000644�0000765�0000765�00000000030�07653237116�016405� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������makedepend *.a *.o .ix* ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/byte-swap.h������������������������������������������������������������������������0000644�0000765�0000765�00000004362�10115104071�016461� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* Copyright (C) 1996, 1997 John W. Eaton This file is part of Octave. Octave 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, or (at your option) any later version. Octave 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 Octave; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #if !defined (byte_swap_h) #define byte_swap_h 1 // XXX FIXME XXX -- not sure these volatile qualifiers are really // needed or appropriate here. static inline void swap_bytes (volatile void *ptr, unsigned int i, unsigned int j) { volatile char *t = static_cast<volatile char *> (ptr); char tmp = t[i]; t[i] = t[j]; t[j] = tmp; } static inline void swap_2_bytes (volatile void *ptr) { volatile char *t = static_cast<volatile char *> (ptr); swap_bytes (t, 0, 1); } static inline void swap_4_bytes (volatile void *ptr) { volatile char *t = static_cast<volatile char *> (ptr); swap_bytes (t, 0, 3); swap_bytes (t, 1, 2); } static inline void swap_8_bytes (volatile void *ptr) { volatile char *t = static_cast<volatile char *> (ptr); swap_bytes (t, 0, 7); swap_bytes (t, 1, 6); swap_bytes (t, 2, 5); swap_bytes (t, 3, 4); } static inline void swap_2_bytes (volatile void *ptr, int len) { volatile char *t = static_cast<volatile char *> (ptr); for (int i = 0; i < len; i++) { swap_2_bytes (t); t += 2; } } static inline void swap_4_bytes (volatile void *ptr, int len) { volatile char *t = static_cast<volatile char *> (ptr); for (int i = 0; i < len; i++) { swap_4_bytes (t); t += 4; } } static inline void swap_8_bytes (volatile void *ptr, int len) { volatile char *t = static_cast<volatile char *> (ptr); for (int i = 0; i < len; i++) { swap_8_bytes (t); t += 8; } } #endif /* ;;; Local Variables: *** ;;; mode: C++ *** ;;; End: *** */ ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/config.h.in������������������������������������������������������������������������0000644�0000765�0000765�00000001772�07653237117�016447� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* config.h.in. Generated automatically from configure.in by autoheader. */ /* Define to empty if the keyword does not work. */ #undef const /* Define if you don't have vprintf but do have _doprnt. */ #undef HAVE_DOPRNT /* Define if you have the vprintf function. */ #undef HAVE_VPRINTF /* Define as __inline if that's what the C compiler calls it. */ #undef inline /* Define as the return type of signal handlers (int or void). */ #undef RETSIGTYPE /* Define if the setvbuf function takes the buffering type as its second argument and the buffer pointer as the third, as on System V before release 3. */ #undef SETVBUF_REVERSED /* Define to `unsigned' if <sys/types.h> doesn't define. */ #undef size_t /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define if you have the strerror function. */ #undef HAVE_STRERROR /* Define if you have the <fcntl.h> header file. */ #undef HAVE_FCNTL_H /* Define if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H ������imview-1.1.9c/io/configure.in�����������������������������������������������������������������������0000644�0000765�0000765�00000000735�07653237120�016725� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������dnl Process this file with autoconf to produce a configure script. AC_INIT(cpostscript.C) dnl Checks for programs. AC_PROG_CC dnl Checks for libraries. dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(fcntl.h unistd.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_C_INLINE AC_TYPE_SIZE_T dnl Checks for library functions. AC_FUNC_SETVBUF_REVERSED AC_TYPE_SIGNAL AC_FUNC_VPRINTF AC_CHECK_FUNCS(strerror) AC_OUTPUT(Makefile) �����������������������������������imview-1.1.9c/io/cpostscript.cxx��������������������������������������������������������������������0000644�0000765�0000765�00000100073�10065514725�017511� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: cpostscript.cxx,v 4.6 2004/06/21 08:18:29 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /* $Id: cpostscript.cxx,v 4.6 2004/06/21 08:18:29 hut66au Exp $ */ /*------------------------------------------------------------------------ * cpostscript.c * * This file contains functions used to produce a page or an * encapsulated postscript file from a list of images in the * form of buffers. * * by Hugues Talbot 16 Feb 1995 * modified Hugues Talbot 23 Apr 1998 for ImView * *-----------------------------------------------------------------------*/ #include <stdio.h> #include <string.h> #include <math.h> #include <time.h> #include <assert.h> #include "imview.hxx" #include "cpostscript.hxx" extern int dbgprintf(const char *msg, ...); extern const char *patchlevel; extern char appName[]; /* globals */ static char errMsg[300]; /* page size in points */ extern float page_formats[][2]; static margin_size currentMarginIndex = MARGIN_SIZE_STANDARD; /* various allowable margins in points */ static float page_margins[MARGIN_SIZE_NB][MARGIN_INDEX_NB] = { {25.0, 25.0, 30.0, 75.0, 40.0, 10.0, 10.0}, // standard {10.0, 10.0, 10.0, 20.0, 10.0, 5.0, 5.0}, // small {40.0, 40.0, 40.0, 80.0, 40.0, 10.0, 10.0}, // large { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // zero (the title will never be printed!) { 0.0, 0.0, 0.0, 35.0, 0.0, 5.0, 5.0} // custom }; static void ps_getWindowBounds(byte papertype, byte win_type, byte orientation, float *boundOx, float *boundOy, float *boundW, float *boundH); static void ps_arrange_images(HIMAGE *theImageList, int nbIm, double aspectRatio, float boundOx, float boundOy, float boundW, float boundH, int nbAcross, int nbDown, byte drawFrame, FILE *tbp); static void ps_start(byte papertype, byte orientation, int nbCopies, char *fontName, FILE *tbp); static void ps_end( FILE *tbp); static void arrange_page(int nbIm, float trueW, float trueH, long maxRows, long maxCols, double aspectRatio, int *nacross, int *ndown); static void ps_printAnImage(HIMAGE theimage, BOX *subbox, double theScale, double aspectRatio, byte drawFrame, FILE *tbp); static void getMinMax(PIX_TYPE *buf, long nbpix, PIX_TYPE *theMin, PIX_TYPE *theMax); static void ps_printTitle(float boundOx, float boundOy, float boundW, float boundH, char *theTitle, char *fontName, FILE *tbp); static void ps_drawRibbon(float boundOx, float boundOy, float boundW, float boundH, FILE *tbp); static void eps_start(HIMAGE anImage, double aspect, FILE *tbp); static void eps_save(HIMAGE anImage, double aspect, FILE *tbp); static void eps_end(FILE *tbp); static void myDebug(char *string); /* * * margin management * */ void postscript_set_margin_index(margin_size whichMargins) { currentMarginIndex = whichMargins; } void postscript_set_custom_margins(float allmargings[MARGIN_INDEX_NB]) { for (int i = 0 ; i < MARGIN_INDEX_NB ; ++i) { page_margins[MARGIN_SIZE_CUSTOM][i] = allmargings[i]; } } void postscript_get_margins(margin_size whichMargin, float allmargings[MARGIN_INDEX_NB]) { assert((whichMargin >= 0) && (whichMargin < MARGIN_SIZE_NB)); for (int i = 0 ; i < MARGIN_INDEX_NB ; ++i) { allmargings[i] = page_margins[whichMargin][i]; } } /* * * compose_PostScript_Code() * * this function takes a list of images and a flurry of options, and * output that on a PostScript Device * */ int compose_PostScript_code(HIMAGE *theImageList, /* image list */ int nbIm, /* real number of images */ double aspectRatio, /* aspect of the image */ byte paperType, /* type of the paper (a4, etc) */ byte win_type, /* portion of the window covered */ byte orientation, /* landscape or portrait */ int nbCopies, /* nb of copies */ int nbAcross, /* nb of images across */ int nbDown, /* nb of images down */ char *theTitle, /* title of the page */ char *fontName, /* name of the font */ byte hasRibbon, byte drawFrame, FILE *tbp) { float boundOx, boundOy, boundW, boundH; /* case of the EPS */ if (win_type != WIN_EPS) { myDebug("Standart ps code to eventually print on a page"); /* get the actual bounds of the window */ ps_getWindowBounds(paperType, win_type, orientation, &boundOx, &boundOy, &boundW, &boundH); /* startup */ ps_start(paperType, orientation, nbCopies, fontName, tbp); /* arrange images on the page */ ps_arrange_images(theImageList, nbIm, aspectRatio, boundOx, boundOy, boundW, boundH, nbAcross, nbDown, drawFrame, tbp); /* title */ if (theTitle != NULL) { ps_printTitle(boundOx, boundOy, boundW, boundH, theTitle, fontName, tbp); } /* ribbon if asked for */ if (hasRibbon) { ps_drawRibbon(boundOx, boundOy, boundW, boundH, tbp); } /* the end */ ps_end(tbp); } else { /* when eps is required, everything is different : we consider */ /* only the first image, and output only this one with the tightest bounding box */ /* this image can't be printed, a file name must be supplied */ myDebug("Saving first image on command line into Encapsulated Postscript"); if (nbIm > 1) { myDebug("** Only the first image will be saved to file **"); } if (tbp == NULL) { /* a file name must be supplied */ return EPS_NOFILE; } /* real stuff now */ eps_start(theImageList[0], aspectRatio, tbp); eps_save(theImageList[0], aspectRatio, tbp); /* extremely simple... */ eps_end(tbp); } return 0; } /* computes the correct bounds */ void ps_getWindowBounds(byte papertype, byte win_type, byte orientation, float *boundOx, float *boundOy, float *boundW, float *boundH) { if (orientation == ORI_PRT) { myDebug("image is oriented as portrait"); if (win_type == WIN_ALL) { myDebug("the whole page is used"); *boundOx = *boundOy = 0.0; *boundW = page_formats[papertype][0]; *boundH = page_formats[papertype][1]; } else if (win_type == WIN_UP) { myDebug("Only the top-half of the page is used"); *boundOx = 0.0; *boundOy = page_formats[papertype][1]/2; *boundW = page_formats[papertype][0]; *boundH = page_formats[papertype][1]; } else if (win_type == WIN_LOW) { myDebug("Only the bottom-half of the page is used"); *boundOx = *boundOy = 0.0; *boundW = page_formats[papertype][0]; *boundH = page_formats[papertype][1]/2; } } else if (orientation == ORI_LDS) { myDebug("image is oriented as landscape"); if (win_type == WIN_ALL) { myDebug("the whole page is used"); *boundOx = *boundOy = 0.0; *boundW = page_formats[papertype][1]; *boundH = page_formats[papertype][0]; } else if (win_type == WIN_UP) { myDebug("Only the top-half of the page is used"); *boundOx = 0.0; *boundOy = page_formats[papertype][0]/2; *boundW = page_formats[papertype][1]; *boundH = page_formats[papertype][0]; } else if (win_type == WIN_LOW) { myDebug("Only the bottom-half of the page is used"); *boundOx = *boundOy = 0.0; *boundW = page_formats[papertype][1]; *boundH = page_formats[papertype][0]/2; } } return; } /* the blurb at the beginning of the PS file */ void ps_start(byte papertype, byte orientation, int nbCopies, char *fontName, FILE *tbp) { time_t theTime; myDebug("Writing ps header"); /* first the comments */ theTime = time(0); fprintf(tbp, "%%!PS-Adobe-3.0 EPSF-3.0\n"); /* this comment is compulsery, the rest is mostly makeup */ fprintf(tbp, "%%%%Creator: %s-%s by CSIRO-MIS\n", appName, patchlevel); fprintf(tbp, "%%%%Title: Image printout\n"); fprintf(tbp, "%%%%CreationDate: %s", ctime(&theTime)); fprintf(tbp, "%%%%DocumentFonts: %s\n", fontName); fprintf(tbp, "%%%%Pages:1\n"); fprintf(tbp, "%%%%Origin: 0 0\n"); fprintf(tbp, "%%%%BoundingBox: 0 0 %d %d\n", (int)page_formats[papertype][0],(int)page_formats[papertype][1]); fprintf(tbp, "%%%%EndComments\n" "%%%%EndProlog\n" "%%%%Page: 1 1\n"); /* now the environnent */ fprintf(tbp, "%%%%BeginSetup\n/#copies %d def\n%%%%EndSetup\n", nbCopies); fprintf(tbp, "\n\n/origstate save def\n"); fprintf(tbp, "20 dict begin\n"); /* for local procedures */ if (orientation == ORI_LDS) { /* translate and rotate the coordinate system */ fprintf(tbp, "%d 0 translate\n90 rotate", (int)page_formats[papertype][0]); } return; } /* same thing for eps */ void eps_start(HIMAGE anImage, double aspect, FILE *tbp) { time_t theTime; long w, h; myDebug("Writing eps header"); /* first the comments */ theTime = time(0); fprintf(tbp, "%%!PS-Adobe-3.0 EPSF-3.0\n"); /* this comment is compulsery, the rest is mostly makeup */ fprintf(tbp, "%%%%Creator: %s-%s by CSIRO-MIS\n", appName, patchlevel); fprintf(tbp, "%%%%Title: %s EPS file\n", appName); fprintf(tbp, "%%%%CreationDate: %s", ctime(&theTime)); fprintf(tbp, "%%%%Pages:1\n"); fprintf(tbp, "%%%%DocumentFonts:\n"); fprintf(tbp, "%%%%Origin: 0 0\n"); /* computes bounding box */ w = anImage.nbcols; h = anImage.nbrows; if (aspect > 1.0) { w = (long)(w/aspect); } else { h = (long)(h*aspect); } fprintf(tbp, "%%%%BoundingBox: 0 0 %ld %ld\n", w, h); fprintf(tbp, "%%%%EndComments\n" "%%%%EndProlog\n"); fprintf(tbp, "%%%%Page: 1 1\n"); /* now the environnent */ fprintf(tbp, "\n\n/origstate save def\n"); fprintf(tbp, "20 dict begin\n"); /* for local procedures */ fprintf(tbp, "0 0 translate\n"); return; } void ps_end( FILE *tbp) { fprintf(tbp, "\n\nshowpage\n"); /* otherwise it won't print... */ fprintf(tbp, "\nend\n"); /* of the dictionary */ fprintf(tbp, "origstate restore\n"); /* get back to previous state */ fprintf(tbp, "%%%%Trailer\n"); myDebug("Finished writing ps footer"); return; } /* same thing for eps */ void eps_end( FILE *tbp) { fprintf(tbp, "\n\nshowpage\n"); /* In theory we shouldn't need that, */ /* in fact, we do. Some programs need */ /* it. For example xv... */ fprintf(tbp, "\nend\n"); /* of the dictionary */ fprintf(tbp, "origstate restore\n"); /* get back to previous state */ fprintf(tbp, "%%%%Trailer\n"); myDebug("Finished writing eps footer"); return; } /* This function finds its place for each image, and then call the postscript generator for each of those That sounds complex, but is it ? */ void ps_arrange_images(HIMAGE *theImageList, int nbIm, double aspectRatio, float boundOx, float boundOy, float boundW, float boundH, int nbAcross, int nbDown, byte drawFrame, FILE *tbp) { int i, j, n; int boxWidth, boxHeight; long maxRows, maxCols, aRow, aCol; float trueOx, trueOy, trueW, trueH; double scaleW, scaleH, theScale; BOX subbox; myDebug("Arranging images on page"); /* get the dimensions of the page */ trueOx = boundOx + page_margins[currentMarginIndex][MARGIN_LEFT]; trueOy = boundOy + page_margins[currentMarginIndex][MARGIN_BOTTOM]; trueW = boundW-boundOx - \ page_margins[currentMarginIndex][MARGIN_LEFT] - \ page_margins[currentMarginIndex][MARGIN_RIGHT]; trueH = boundH-boundOy - \ page_margins[currentMarginIndex][MARGIN_BOTTOM] - \ page_margins[currentMarginIndex][MARGIN_TOP]; /* find the "minimum enclosing rectangle" for all images */ maxRows = maxCols = 0; for (i = 0 ; i < nbIm ; i++) { aRow = theImageList[i].nbrows; aCol = theImageList[i].nbcols; if (aRow > maxRows) maxRows = aRow; if (aCol > maxCols) maxCols = aCol; } if ((nbAcross > 0) && (nbDown > 0) && ((nbAcross * nbDown) < nbIm)) { sprintf(errMsg, "The arrangement supplied does not make sense (only %d slots for %d images).\n\ We shall supply our own arrangement", nbAcross*nbDown, nbIm); myDebug(errMsg); nbAcross = nbDown = 0; } arrange_page(nbIm,trueW, trueH, maxRows, maxCols, aspectRatio, &nbAcross, &nbDown); sprintf(errMsg, "Arrangement found : %d image(s) across, %d image(s) down", nbAcross, nbDown); myDebug(errMsg); boxWidth = (int)((trueW - (nbAcross+1)*page_margins[currentMarginIndex][MARGIN_BETWEEN_X]) / nbAcross); boxHeight = (int)((trueH - (nbDown +1)*page_margins[currentMarginIndex][MARGIN_BETWEEN_Y]) / nbDown); /* find the scale (all images are rescaled to the same dimension )*/ scaleW = (double) boxWidth / maxCols; scaleH = (double) boxHeight / maxRows; theScale = MYMIN(scaleW, scaleH); subbox.wide = boxWidth; subbox.high = boxHeight; /* print image per image */ for (j = 0, n = 0 ; j < nbDown ; j++) { for (i = 0; i < nbAcross ; i++, n++) { if (n >= nbIm) break; /* everything has been printed...*/ subbox.xmin = (int)(trueOx + (float)(i+1)*page_margins[currentMarginIndex][MARGIN_BETWEEN_X] + (float)i*boxWidth); subbox.xmax = (int)(subbox.xmin + boxWidth - 1); subbox.ymax = (int)(trueOy + trueH - (float)(j+1) * page_margins[currentMarginIndex][MARGIN_BETWEEN_Y] - (float)j * boxHeight); subbox.ymin = (int)(subbox.ymax - boxHeight +1); sprintf(errMsg,"Printing image %d", n); myDebug(errMsg); ps_printAnImage(theImageList[n], &subbox, theScale, aspectRatio, drawFrame, tbp); } } return; } void arrange_page(int n, float trueW, float trueH, long maxRows, long maxCols, double aspectRatio, int *nacross, int *ndown) { double ratio, across, down; int na, nd; /* computed in any case */ ratio = ((double)maxRows * trueW * aspectRatio) / ((double)maxCols * trueH); if (*nacross != 0) { na = *nacross; if (*ndown == 0) { nd = n / na; if (nd * na < n) nd++; /* once is enough */ } else { nd = *ndown; } } else if (*ndown != 0) { nd = *ndown; na = n / nd; /* no need to test again if *nacross == 0 */ if (na * nd < n) na++; /* once is enough*/ } else { across = sqrt(n*ratio); down = across/ratio; na = (int)floor(across); nd = (int)floor(down); } if (na <= 0) { na = 1; nd = n ; } else if (nd <= 0) { nd = 1; na = n; } else if (ratio <= 1.0) { while (na * nd < n) { if ((++nd) * na < n) { nd--; ++na; } } } else { while (na * nd < n) { if ((++na) * nd < n) { na--; nd++; } } } *nacross = na; *ndown = nd; return; } /* this procedure saves an image under the EPS format */ void eps_save(HIMAGE theImage, double aspectRatio, FILE *tbp) { int i, j, k; byte theByte, imMin, imMax; byte doAnamorphosis; long nbw, nbBytes; long imW, imH, bufferLength; PIX_TYPE *p, *r, *g, *b; /* we can change that anytime */ doAnamorphosis = NO; /* get the dimensions of the picture */ imH = theImage.nbrows; imW = theImage.nbcols; /* computes bounding box */ if (aspectRatio > 1.0) { imW = (int)(imW/aspectRatio); } else { imH = (int)(imH*aspectRatio); } /* set up a string to hold up the information */ bufferLength = MYMIN(PLINE_LENGTH, theImage.nbcols); fprintf(tbp, "%%%% new image\n"); fprintf(tbp, "/picstr %ld string def\n", (long)PLINE_LENGTH); /* set the right scale */ fprintf(tbp, "%ld %ld scale\n", imW, imH); /* Now it depends on # of colors and byte per pixels */ if (theImage.type == PS_BINARY) { myDebug("Saving binary image to EPS"); /* set up the arguments of the postscript image operator */ fprintf(tbp, "%ld %ld %d\n[ %ld 0 0 -%ld 0 %ld ]", theImage.nbcols, theImage.nbrows, 1, theImage.nbcols, theImage.nbrows, theImage.nbrows); /* we are not considering RGB binaries */ /* writing the small bit of program that will read the data */ fprintf(tbp, "{currentfile\npicstr readhexstring pop}\nimage\n"); /* printing the data now */ p = theImage.buf0; for (j = 0, nbw = 0 ; j < theImage.nbrows ; j++ ) { for (i = 0 ; i < theImage.nbcols ; i += 8, nbw++) { for (k = 0, theByte = 0x00; ((k < 8) && (i+k < theImage.nbcols)) ; k++,p++) { theByte <<= 1; theByte |= ((!*p) & 0x01); } /* make up the rest of the byte */ for (; k < 8 ; k++) { theByte <<= 1; } /* print it */ fprintf(tbp, "%2.2x", theByte); if ((nbw % PLINE_LENGTH) == PLINE_LENGTH-1) fprintf(tbp, "\n"); } } if (nbw % PLINE_LENGTH != 0) { /* complete the scanline */ for (i = nbw % PLINE_LENGTH ; i < PLINE_LENGTH ; i++) fprintf(tbp, "%2.2x", 0); } } else if (theImage.nbcomp == 1) { myDebug("Saving gray-level image to EPS"); /* standard Gray-level image */ getMinMax(theImage.buf0, theImage.nbrows*theImage.nbcols, &imMin, &imMax); /* set up the arguments of the postscript image operator */ fprintf(tbp, "%ld %ld %d\n[ %ld 0 0 -%ld 0 %ld ]\n", theImage.nbcols, theImage.nbrows, 8, theImage.nbcols, theImage.nbrows, theImage.nbrows); /* writing the small bit of program that will read the data */ fprintf(tbp, "{currentfile picstr readhexstring pop}\nimage\n"); /* printing the data now */ p = theImage.buf0; nbBytes = theImage.nbrows*theImage.nbcols; if (!doAnamorphosis || (imMax-imMin == 0)) { for (j = 0 ; j < nbBytes ; j++, p++) { fprintf(tbp, "%2.2x", *p); if ((j % PLINE_LENGTH) == PLINE_LENGTH-1) fprintf(tbp, "\n"); } if (j % PLINE_LENGTH != 0) { /* complete the scanline */ for (i = j % PLINE_LENGTH ; i < PLINE_LENGTH ; i++) fprintf(tbp, "%2.2x", 0); } } else { /* gray-level anamorphosis */ for (j = 0 ; j < nbBytes ; j++, p++) { fprintf(tbp, "%2.2x", (int)((*p-imMin)*((double)PIX_TYPE_MAX/(double)(imMax-imMin)))); if ((j % PLINE_LENGTH) == PLINE_LENGTH-1) fprintf(tbp, "\n"); } if (j % PLINE_LENGTH != 0) { /* complete the scanline */ for (i = j % PLINE_LENGTH ; i < PLINE_LENGTH ; i++) fprintf(tbp, "%2.2x", 0); } } } else if (theImage.nbcomp == 3) { myDebug("saving RGB image to EPS"); /* RGB image */ /* set up the arguments for the ColorImage operator */ fprintf(tbp, "%ld %ld %d\n[ %ld 0 0 -%ld 0 %ld ]", theImage.nbcols, theImage.nbrows, 8, theImage.nbcols, theImage.nbrows, theImage.nbrows); /* writing the small bit of program that will read the data */ fprintf(tbp, "{currentfile\npicstr readhexstring pop}\nfalse 3 colorimage\n"); /* the data will be written in interleaved format (RGBRGBRGB...) */ r = theImage.buf0; g = theImage.buf1; b = theImage.buf2; nbBytes = theImage.nbrows*theImage.nbcols; for (j = 0 ; j < nbBytes ; j++, r++, g++, b++) { fprintf(tbp, "%2.2x%2.2x%2.2x", *r, *g, *b); if ((j % (PLINE_LENGTH/3)) == PLINE_LENGTH/3-1) fprintf(tbp, "\n"); } /* complete the scanline */ if (j % (PLINE_LENGTH/3) != 0) { for (i = j % (PLINE_LENGTH/3) ; i < (PLINE_LENGTH/3) ; i++) fprintf(tbp, "%2.2x%2.2x%2.2x", 0, 0, 0); } } return; } /* this procedure prints an image placed within a box */ /* the box itself is not drawn */ void ps_printAnImage(HIMAGE theImage, BOX *subbox, double theScale, double aspectRatio, byte drawFrame, FILE *tbp) { int i, j, k; byte theByte, imMin, imMax; byte doAnamorphosis; long woff, hoff, nbBytes, nbw; long imW, imH, bufferLength; double scaledW, scaledH; PIX_TYPE *p, *r, *g, *b; /* can be changed anytime */ doAnamorphosis = NO; myDebug("Actual printing of the image"); /* first save the graphic state yet again */ fprintf(tbp, "\ngsave\n"); /* get the dimensions of the picture */ imH = theImage.nbrows; imW = theImage.nbcols; scaledW = imW * theScale; /* now in points */ scaledH = imH * theScale; if (aspectRatio > 1.0) { scaledW /= aspectRatio; } else { scaledH *= aspectRatio; } woff = (int)((subbox->wide - scaledW)/2); hoff = (int)((subbox->high - scaledH)/2); /* set up a string to hold up the information */ bufferLength = MYMIN(PLINE_LENGTH, theImage.nbcols); fprintf(tbp, "%%%% printing new image\n"); fprintf(tbp, "/picstr %ld string def\n", (long)PLINE_LENGTH); /* move to the right point (centering the picture) */ fprintf(tbp, "%d %d translate\n", (int)(subbox->xmin+woff), (int)(subbox->ymin+hoff)); /* set the right scale */ fprintf(tbp, "%d %d scale\n", (int)(scaledW), (int)(scaledH)); /* Now it depends on # of colors and byte per pixels */ if (theImage.type == PS_BINARY) { myDebug("Image printed as binary"); /* set up the arguments of the postscript image operator */ fprintf(tbp, "%ld %ld %d\n[ %ld 0 0 -%ld 0 %ld ]", theImage.nbcols, theImage.nbrows, 1, theImage.nbcols, theImage.nbrows, theImage.nbrows); /* we are not considering RGB binaries */ /* writing the small bit of program that will read the data */ fprintf(tbp, "{currentfile\npicstr readhexstring pop}\nimage\n"); /* printing the data now */ p = theImage.buf0; for (j = 0, nbw = 0 ; j < theImage.nbrows ; j++ ) { for (i = 0 ; i < theImage.nbcols ; i += 8, nbw++) { for (k = 0, theByte = 0x00; ((k < 8) && (i+k < theImage.nbcols)) ; k++,p++) { theByte <<= 1; theByte |= ((!*p) & 0x01); } /* make up the rest of the byte */ for (; k < 8 ; k++) { theByte <<= 1; } /* print it */ fprintf(tbp, "%2.2x", theByte); if ((nbw % PLINE_LENGTH) == PLINE_LENGTH-1) fprintf(tbp, "\n"); } } if (nbw % PLINE_LENGTH != 0) { /* complete the scanline */ for (i = nbw % PLINE_LENGTH ; i < PLINE_LENGTH ; i++) fprintf(tbp, "%2.2x", 0); } } else if (theImage.nbcomp == 1) { myDebug("Image printed as gray-level"); /* standard Gray-level image */ getMinMax(theImage.buf0, theImage.nbrows*theImage.nbcols, &imMin, &imMax); /* set up the arguments of the postscript image operator */ fprintf(tbp, "%ld %ld %d\n[ %ld 0 0 -%ld 0 %ld ]\n", theImage.nbcols, theImage.nbrows, 8, theImage.nbcols, theImage.nbrows, theImage.nbrows); /* writing the small bit of program that will read the data */ fprintf(tbp, "{currentfile picstr readhexstring pop}\nimage\n"); /* printing the data now */ p = theImage.buf0; nbBytes = theImage.nbrows*theImage.nbcols; if (!doAnamorphosis || (imMax-imMin == 0)) { for (j = 0 ; j < nbBytes ; j++, p++) { fprintf(tbp, "%2.2x", *p); if ((j % PLINE_LENGTH) == PLINE_LENGTH-1) fprintf(tbp, "\n"); } if (j % PLINE_LENGTH != 0) { /* complete the scanline */ for (i = j % PLINE_LENGTH ; i < PLINE_LENGTH ; i++) fprintf(tbp, "%2.2x", 0); } } else { /* gray-level anamorphosis */ for (j = 0 ; j < nbBytes ; j++, p++) { fprintf(tbp, "%2.2x", (int)((*p-imMin)*((double)PIX_TYPE_MAX/(double)(imMax-imMin)))); if ((j % PLINE_LENGTH) == PLINE_LENGTH-1) fprintf(tbp, "\n"); } if (j % PLINE_LENGTH != 0) { /* complete the scanline */ for (i = j % PLINE_LENGTH ; i < PLINE_LENGTH ; i++) fprintf(tbp, "%2.2x", 0); } } } else if (theImage.nbcomp == 3) { myDebug("image printed as RGB image"); /* RGB image */ /* set up the arguments for the ColorImage operator */ fprintf(tbp, "%ld %ld %d\n[ %ld 0 0 -%ld 0 %ld ]", theImage.nbcols, theImage.nbrows, 8, theImage.nbcols, theImage.nbrows, theImage.nbrows); /* writing the small bit of program that will read the data */ fprintf(tbp, "{currentfile\npicstr readhexstring pop}\nfalse 3 colorimage\n"); /* the data will be written in interleaved format (RGBRGBRGB...) */ r = theImage.buf0; g = theImage.buf1; b = theImage.buf2; nbBytes = theImage.nbrows*theImage.nbcols; for (j = 0 ; j < nbBytes ; j++, r++, g++, b++) { fprintf(tbp, "%2.2x%2.2x%2.2x", *r, *g, *b); if ((j % (PLINE_LENGTH/3)) == PLINE_LENGTH/3-1) fprintf(tbp, "\n"); } /* complete the scanline */ if (j % (PLINE_LENGTH/3) != 0) { for (i = j % (PLINE_LENGTH/3) ; i < (PLINE_LENGTH/3) ; i++) fprintf(tbp, "%2.2x%2.2x%2.2x", 0, 0, 0); } } /* if asked for, draw a very thin small frame around the image */ if (drawFrame) { myDebug("Small frame drawn around image"); fprintf(tbp, "\n\n%%%% frame around image\n"); fprintf(tbp, "0 setlinewidth\n"); fprintf(tbp, "0 setgray\n"); fprintf(tbp, "newpath\n"); fprintf(tbp, "0 0 moveto\n"); fprintf(tbp, "1 0 lineto\n"); fprintf(tbp, "1 1 lineto\n"); fprintf(tbp, "0 1 lineto\n"); fprintf(tbp, "closepath\n"); fprintf(tbp, "stroke\n"); } /* last restore the graphic state yet again */ fprintf(tbp, "\n\ngrestore\n%%%%\n\n"); return ; } /* get min and max of image */ void getMinMax(PIX_TYPE *buf, long nbpix, PIX_TYPE *theMin, PIX_TYPE *theMax) { PIX_TYPE *p, *end; p = buf; end = buf + nbpix; *theMin = PIX_TYPE_MAX; *theMax = PIX_TYPE_MIN; while (p != end) { if (*p > *theMax) *theMax = *p; if (*p < *theMin) *theMin = *p; p++; } return; } void ps_printTitle(float boundOx, float boundOy, float boundW, float boundH, char *theTitle, char *fontName, FILE *tbp) { int startXpoint, startYpoint, startsize, minsize; int titleBoxHeight; int lengthlimit; startXpoint = (int)(boundOx + page_margins[currentMarginIndex][MARGIN_RIGHT]); startYpoint = (int)(boundOy + page_margins[currentMarginIndex][MARGIN_TITLE]); titleBoxHeight = (int)(page_margins[currentMarginIndex][MARGIN_BOTTOM] - page_margins[currentMarginIndex][MARGIN_TITLE]); if (titleBoxHeight > 0) { // then do print startsize = (int)(MYMIN(TEXT_START_SIZE, titleBoxHeight)); minsize = (int)(TEXT_MIN_SIZE); lengthlimit = (int)(boundW - \ page_margins[currentMarginIndex][MARGIN_LEFT] - \ startXpoint); sprintf(errMsg, "box: (boundOx=%g, boundOy=%g, boundW=%g, boundH=%g);\n" "startXpoint=%d, startYpoint= %d\n", boundOx, boundOy, boundW, boundH, startXpoint, startYpoint); myDebug(errMsg); /* start the small ps program */ /* variables first */ myDebug("Writing title"); fprintf(tbp, "\n%%%% Small ps program to write title at bottom of page\n"); fprintf(tbp, "/startpoint {%d %d} def\n", startXpoint, startYpoint); fprintf(tbp, "/startsize %d def\n", startsize); fprintf(tbp, "/minsize %d def\n", minsize); fprintf(tbp, "/myfont {/%s} def\n", fontName); fprintf(tbp, "/lengthlimit %d def\n", lengthlimit); fprintf(tbp, "/mytext (%s) def\n\n", theTitle); /* the program itself now */ fprintf(tbp, "myfont findfont startsize scalefont setfont\n"); /* font selection */ fprintf(tbp, "startsize -1 minsize {\n"); /* start of the for loop */ fprintf(tbp, " /newsize exch def\n"); /* get the new font size from the loop */ fprintf(tbp, " /textlength mytext stringwidth pop def\n"); /* compute the length of the title */ fprintf(tbp, " textlength lengthlimit le {\n"); /* verifies if it is shorter than the available space */ fprintf(tbp, " exit\n"); /* if yes, we have found the right size for the font */ fprintf(tbp, " } {\n"); /* that's an else */ fprintf(tbp, " myfont newsize selectfont\n"); /* selects the new font size (smaller) as current size */ fprintf(tbp, " } ifelse\n"); /* there is the logical operator */ fprintf(tbp, "} for\n\n"); /* and the whole thing is a loop, from biggest size to smallest, we chose the best */ fprintf(tbp, "lengthlimit textlength sub 2 div\n"); /* now we will center the sentence */ fprintf(tbp, "startpoint pop add\n"); /* some calculation */ fprintf(tbp, "startpoint exch pop\n"); /* some more trivial stuff */ fprintf(tbp, "moveto\n"); /* it's making its move now... */ fprintf(tbp, "mytext show"); /* lo and behold, the text appears... */ } else { myDebug("Title not printed because margins are too tight\n"); } /* and this is it */ return; } /* this function draws a black to white strip (+ R, G, B, C, Y, M blocks) */ /* serves for comparisons and checking */ void ps_drawRibbon(float boundOx, float boundOy, float boundW, float boundH, FILE *tbp) { int height, width, realwidth, pagewidth; int swatchwidth; int xpos, ypos; int i; myDebug("printing colour-test ribbon"); /* print ribbon in right-hand margin */ pagewidth = (int)(boundW - boundOx - \ page_margins[currentMarginIndex][MARGIN_RIGHT] - \ page_margins[currentMarginIndex][MARGIN_LEFT]); width = pagewidth/3; swatchwidth = width/6; height = (int)(page_margins[currentMarginIndex][MARGIN_TOP]/3 + 0.5); realwidth = 2*width; height = (int)(page_margins[currentMarginIndex][MARGIN_TOP]/3 + 0.5); xpos = (int)((pagewidth-realwidth)/2 + \ page_margins[currentMarginIndex][MARGIN_RIGHT] \ + boundOx); ypos = (int)(boundH - \ page_margins[currentMarginIndex][MARGIN_TOP] \ + 1); if (ypos < boundOy) { sprintf(errMsg, "** Not enough room on page **"); myDebug(errMsg); } /* variable */ fprintf(tbp, "\n\n%%%% Optionnal ribbon\n"); fprintf(tbp, "/nbgray 256 def\n"); /* that's a constant.. */ fprintf(tbp, "/wherex %d def\n", xpos); fprintf(tbp, "/wherey %d def\n", ypos); fprintf(tbp, "/striplength %d def\n", width); fprintf(tbp, "/stripheight %d def\n", height); fprintf(tbp, "/swatchwidth %d def\n", swatchwidth); fprintf(tbp, "/huelength striplength nbgray div def\n"); fprintf(tbp, "/grayinc 1 nbgray div def\n"); fprintf(tbp, "/tstriplength striplength swatchwidth add def\n"); fprintf(tbp, "\ngsave\n"); /* start of the important stuff */ fprintf(tbp, "wherex wherey translate\n"); fprintf(tbp, "1 1 nbgray {\n"); fprintf(tbp, " /index exch def\n"); fprintf(tbp, " newpath\n"); fprintf(tbp, " 0 0 moveto\n"); fprintf(tbp, " huelength 0 lineto\n"); fprintf(tbp, " huelength stripheight lineto\n"); fprintf(tbp, " 0 stripheight lineto\n"); fprintf(tbp, " closepath\n"); fprintf(tbp, " fill\n"); fprintf(tbp, " huelength 0 translate\n"); fprintf(tbp, " index grayinc mul setgray\n"); fprintf(tbp, "} for\n\n"); fprintf(tbp, "%%%% hairline around the ribbon\n"); fprintf(tbp, "0 striplength sub 0 translate\n"); fprintf(tbp, "newpath\n"); fprintf(tbp, "0 0 moveto\n"); fprintf(tbp, "striplength 0 lineto\n"); fprintf(tbp, "striplength stripheight lineto\n"); fprintf(tbp, "0 stripheight lineto\n"); fprintf(tbp, "closepath\n"); fprintf(tbp, "0 setgray\n"); fprintf(tbp, "0 setlinewidth\n"); fprintf(tbp, "stroke\n"); fprintf(tbp, "\n%%%% color swatches\n"); fprintf(tbp, "striplength 0 translate\n"); for (i = 1 ; i < 7 ; i++) { fprintf(tbp, "newpath\n"); fprintf(tbp, "0 0 moveto\n"); fprintf(tbp, "swatchwidth 0 lineto\n"); fprintf(tbp, "swatchwidth stripheight lineto\n"); fprintf(tbp, "0 stripheight lineto\n"); fprintf(tbp, "closepath\n"); fprintf(tbp, "%d %d %d setrgbcolor\n", (i >> 2 ) & 1, (i >> 1) & 1, i &1); fprintf(tbp, "fill\n"); fprintf(tbp, "swatchwidth 0 translate\n"); } fprintf(tbp, "grestore\n"); fprintf(tbp, "%%%% end of ribbon\n\n"); return ; } void myDebug(char *string) { char myMess[300]; strcpy(myMess, " "); strcat(myMess, string); strcat(myMess, "\n"); dbgprintf(myMess); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/cpostscript.hxx��������������������������������������������������������������������0000644�0000765�0000765�00000012462�10065514725�017522� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: cpostscript.hxx,v 4.5 2004/06/21 08:18:29 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * cpostscript.h * * this file contains most definitions for color postscript * output * * by Hugues Talbot 16 Feb 1995 * *-----------------------------------------------------------------------*/ #ifndef CPOSTSCRIPT_H #define CPOSTSCRIPT_H /* a few useful typedefs */ typedef unsigned char byte; #if !defined(Solaris) && !defined(DECa) typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned long u_long; #endif typedef unsigned char PIX_TYPE; #ifndef YES #define YES 1 #endif #ifndef NO #define NO 0 #endif // types #define PS_BINARY 1 #define PS_CHAR 2 #define PS_GREY 3 /* flags */ #define WIN_ALL 0 #define WIN_UP 1 #define WIN_LOW 2 #define WIN_EPS 3 #define ORI_PRT 0 #define ORI_LDS 1 #define A4_FMT 0 #define LE_FMT 1 #define A3_FMT 2 /* some limits */ #define MAX_NB_COPIES 500 #define MAX_IM_ACROSS 100 #define MAX_IM_DOWN 100 #define MIN_IM_AR 0.01 #define MAX_IM_AR 100.0 /* some error codes */ #define NO_IMAGE 0 #define MEM_ERROR 1 #define LACK_ZHOME 2 #define MALLOC_ERROR -1 #define EPS_NOFILE -2 /* the Z home directory */ #ifndef MAX_PATH # define MAX_PATH 1024 #endif /* LUT constants */ #define MAXCOLOUR 256 /* first index in the page_margin array */ typedef enum { MARGIN_SIZE_STANDARD=0, MARGIN_SIZE_SMALL, MARGIN_SIZE_LARGE, MARGIN_SIZE_ZERO, MARGIN_SIZE_CUSTOM, MARGIN_SIZE_NB } margin_size; /* second index in the page_margin array */ typedef enum { MARGIN_LEFT=0, MARGIN_RIGHT, MARGIN_TOP, MARGIN_BOTTOM, MARGIN_TITLE, MARGIN_BETWEEN_X, MARGIN_BETWEEN_Y, MARGIN_INDEX_NB } margins_index; /* margins (in points) */ #define LEFT_MARGIN 25 #define RIGHT_MARGIN 25 #define TOP_MARGIN 30 #define BOTTOM_MARGIN 75 /* to allow for the title */ #define BOTTOM_LINE 40 /* the Y value under which things get */ /* cropped out*/ #define TEXT_START_SIZE 30 #define TEXT_MIN_SIZE 2 /* pretty unreadable already ... */ #define BETWEEN_X 5 #define BETWEEN_Y 5 #define PLINE_LENGTH 39 /* length of line in output */ /* postscript, should be divisible by 3 (RGB) */ #ifndef PIX_TYPE_MAX #define PIX_TYPE_MAX 255 #endif #ifndef PIX_TYPE_MIN #define PIX_TYPE_MIN 0 #endif /* macros */ #define MYMIN(X, Y) ((X) > (Y)) ? (Y):(X) #define MYMAX(X, Y) ((X) < (Y)) ? (Y):(X) /* a structure to hold image information */ /* we want something simple capable of handling B&W and RGB images, that's all */ typedef struct himage { int type; /* binary, gray, or char */ int nbcomp; /* nb of components (1 or 3 only acceptable values) */ long nbrows; long nbcols; byte needsToFreeByHand; PIX_TYPE *buf0, *buf1, *buf2; } HIMAGE; /* a box structure */ typedef struct box { int wide; int high; int xmin; int xmax; int ymin; int ymax; } BOX; void postscript_set_margin_index(margin_size whichMargins); void postscript_set_custom_margins(float allmargings[MARGIN_INDEX_NB]); void postscript_get_margins(float allmargings[MARGIN_INDEX_NB]); /* prototype */ int compose_PostScript_code(HIMAGE *theImageList, /* image list */ int realNim, /* real number of images */ double aspectRatio, /* aspect of the image */ byte paperType, /* type of the paper (a4, etc) */ byte win_type, /* portion of the window covered */ byte orientation, /* landscape or portrait */ int nbCopies, /* nb of copies */ int nbAcross, /* nb of images across */ int tnbDown, /* nb of images down */ char *theTitle, /* title of the page */ char *fontName, /* name of the font */ byte hasRibbon, byte drawFrame, FILE *tbp); #endif // CPOSTSCRIPT_H ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/gplot2.cxx�������������������������������������������������������������������������0000644�0000765�0000765�00000013006�10064353032�016331� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: gplot2.cxx,v 4.2 2004/06/17 17:34:18 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /* ImView's interface to gnuplot, after similar work for EiC by Ed Breen Example usages: #include gplot2.c plot_t *p1 = openplot("p1"); send2plot(p1,"plot sin(x) + tan(x)"); closeplot(p1); */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdarg.h> #include "gplot2.hxx" #include "imview.hxx" #include "machine.hxx" using std::list; static list <char *> gplottmpnamelist; void Send_2_plot_(plot_t *p, char * fmt, ...) { char *buff; int stringlength, allocatelength; va_list args; stringlength = strlen(fmt)*2; allocatelength = (512 > stringlength) ? 512:stringlength; buff = (char *)malloc(allocatelength); /* fmt string can be VERY long... */ im_va_start(args,fmt); vsprintf(buff,fmt,args); fputs(buff,getPlotFile(p)); fputc('\n',getPlotFile(p)); free(buff); va_end(args); } void plotDoubles(double *hist, int n,plot_t *p, bool smooth) { int i; double min,max; FILE *fp; fp = fopen(p->fname,"w"); min = max = *hist; for(i=0;i<n;++i,++hist) { if(*hist < min) min = *hist; if(*hist > max) max = *hist; fprintf(fp,"%d %g\n",i,*hist); } fclose(fp); Send_2_plot_(p,"plot [0:%d] '%s' %s notitle with lines", n-1, p->fname, smooth ? "smooth csplines":"" ); } static void addToUnlinkList(char *tmpname) { dbgprintf("Adding %s to the list of files to remove later\n", tmpname); gplottmpnamelist.push_back(tmpname); } static void unlinkAllTmpFiles(void) { while (!gplottmpnamelist.empty()) { char *&nameref = gplottmpnamelist.back(); remove(nameref); dbgprintf("Removing %s\n", nameref); // this name had been allocated free(nameref); gplottmpnamelist.pop_back(); } } // Use this in conjunction with dataMPlot char *writeDoubleVector(double *vec, int n) { char * tmpName = tempnam(NULL, "FlIm"); // this allocates a new area FILE *fp = tmpfile(); int i; fp = fopen(tmpName,"w"); if(!fp) return NULL; for(i=0;i<n;++i) fprintf(fp,"%d %g\n",i,vec[i]); fclose(fp); addToUnlinkList(tmpName); return tmpName; } // allows multiple plots on the same plot void dataMPlot(plot_t *p, char * (*f)(...), /* return the name of the file where data is stored */ int nv, /* number of vectors in vecs */ void **vecs, /* array of vectors */ char **labels, /* arrays of labels (may not be NULL) */ int *lens, /* array of lengths to vecs */ bool smooth) /* uses splines or straight lines */ { /* Assumes that plot title, line style etc have been handled elsewhere. */ char *buff; char buf[256]; int blen = 256; char **names = (char **) malloc(nv * sizeof(char*)); char *tmp; int i,k, tl = 0; for(i=0;i<nv;i++) { tmp = f(vecs[i],lens[i]); k = strlen(tmp); names[i] = (char *)malloc(k+1); tl += k + 5; strcpy(names[i],tmp); } buff = (char *)malloc(blen+tl); sprintf(buff,"plot '%s' title '%s'",names[0], labels[0]); free(names[0]); for(i=1;i<nv; i++) { sprintf(buf,",'%s' title '%s'",names[i], labels[i]); strcat(buff,buf); free(names[i]); } send2plot(p,buff); free(names); free(buff); } void * closePlot(plot_t *p) { if(p != NULL) { fflush(p->fp); pclose(p->fp); remove(p->fname); free(p); } unlinkAllTmpFiles(); return NULL; } plot_t * openPlot(char * plotname) { plot_t * plot = (plot_t*)calloc(sizeof(plot_t),1); if(plot != NULL) { if ((plot->fp = popen("gnuplot","w")) != 0) { setvbuf(plot->fp,NULL,_IONBF,0); // unbuffered I/O if(plotname != NULL) { Send_2_plot_(plot,"set title '%s'",plotname); } tmpnam(plot->fname); } else { free(plot); plot = NULL; } } return plot; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/gplot2.hxx�������������������������������������������������������������������������0000644�0000765�0000765�00000006631�10054230061�016337� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: gplot2.hxx,v 4.1 2004/05/23 23:13:53 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * C++ interface to gnuplot * * By Ed Breen. * * Modified Hugues Talbot 28 Jan 1997 * *-----------------------------------------------------------------------*/ #ifndef GPLOT2_H #define GPLOT2_H #include <stdlib.h> #include <stdio.h> #include <list> #include "imnmspc.hxx" // namespace def. if required #include "machine.hxx" struct plot_t { FILE *fp; char fname[L_tmpnam + 1]; /* the following are used for multiplots */ int nrow; /* number of rows */ int ncol; /* number of cols */ int cp; /* current plot in use */ }; /* plot methods */ #define getPlotncol(x) (x)->ncol #define getPlotnrow(x) (x)->nrow #define getCurrentPlot(x) (x)->cp #define getPlotFile(x) (x)->fp #define setCurrentPlot(x,v) (x)->cp = v /*******************************/ #define send2plot Send_2_plot_ #define replot(x) Send_2_plot_(x,"replot") #define titleplot(x,s) Send_2_plot_(x,"set title '%s'",s) #define xlabelplot(x,s) Send_2_plot_(x,"set xlabel '%s'",s) #define ylabelplot(x,s) Send_2_plot_(x,"set ylabel '%s'",s) #define zlabelplot(x,s) Send_2_plot_(x,"set zlabel '%s'",s) /* prototypes */ plot_t * openPlot(char * plotname); void * closePlot(plot_t *p); void Send_2_plot_(plot_t *p, char * fmt, ...); void plotDoubles(double *hist, int n,plot_t *p, bool smooth); char *writeDoubleVector(double *vec, int n); void dataMPlot(plot_t *p, char * (*f)(...), /* return the name of the file where data is stored */ int nv, /* number of vectors in vecs */ void **vecs, /* array of vectors */ char **labels, /* labels */ int *lens, /* array of lengths to vecs */ bool smooth); /* smooth or not ?*/ #endif //GPLOT2_H �������������������������������������������������������������������������������������������������������imview-1.1.9c/io/ics.hxx����������������������������������������������������������������������������0000644�0000765�0000765�00000012665�07653237121�015731� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: ics.hxx,v 4.0 2003/04/28 14:44:33 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /************************************************************* FILE : ics.h PURPOSE : Definitions of dataset structure and other stuff for the ICS file format. USAGE : #include "ics.h" DESCRIPTION OF PARAMETERS : AUTHOR : Damir Sudar Copyright (c) University of California San Francisco HISTORY : 3/30/89 created ******************************************************************/ #ifndef ICS_H #define ICS_H #define MAXDIM 5 #define SIGNED 1 #define UNSIGNED 0 #define WRITE_DIRECT 0 #define READ_DIRECT 0 #define BYTE2SHORT 1 #define SHORT2BYTE 1 #define BIT2BBIT 2 #define BIT2SBIT 3 #define BIT2LBIT 4 #define BBIT2BIT 2 #define SBIT2BIT 3 #define LBIT2BIT 4 #define FILENAME_SIZE 20 #define ORDER_SIZE 10 #define LABEL_SIZE 20 #define UNITS_SIZE 20 #define COORD_SIZE 20 #define FORMAT_SIZE 20 #define CMPS_SIZE 20 #define BYTEORDER_SIZE 16 #define SCIL_SIZE 20 typedef struct { int valid_filename; /* if filename is valid */ char filename[FILENAME_SIZE]; /* basename for header,data,... files */ int valid_parameters; /* if parameters is valid */ int parameters; /* number of parameters */ int valid_order; /* if order is valid */ char order[MAXDIM][ORDER_SIZE];/* order of the parameters */ int valid_sizes; /* if sizes is valid */ int sizes[MAXDIM]; /* dimensions of each parameter */ int valid_sigbits; /* if sigbits is valid */ int sigbits; /* number of significant bits */ int valid_origin; /* if origin is valid */ float origin[MAXDIM]; /* real world origin per parameter */ int valid_scale; /* if scale is valid */ float scale[MAXDIM]; /* real world scale per parameter */ int valid_label; /* if label is valid */ char label[MAXDIM][LABEL_SIZE];/* label per parameter */ int valid_units; /* if units is valid */ char units[MAXDIM][UNITS_SIZE];/* measurement units per parameter */ int valid_coord; /* if coord is valid */ char coord[COORD_SIZE]; /* used coordinate system */ int valid_format; /* if format is valid */ char format[FORMAT_SIZE]; /* integer, float or complex */ int valid_sign; /* if sign is valid */ int sign; /* 0 = unsigned, 1 = signed */ int valid_compression; /* if compression is valid */ char compression[CMPS_SIZE]; /* compression technique used */ int valid_byteorder; /* if byteorder is valid */ int byteorder[BYTEORDER_SIZE]; /* order in which bytes are stored */ int valid_SCIL_TYPE; /* if SCIL_TYPE is valid */ char SCIL_TYPE[SCIL_SIZE]; /* g2d or f2d */ int datalength; /* number of bytes in icsdata */ char *icsdata; /* extra ICS information */ } ICS; typedef struct { int filename; /* if filename is to be copied */ int parameters; /* if parameters is to be copied */ int order; /* if order is to be copied */ int sizes; /* if sizes is to be copied */ int sigbits; /* if sigbits is to be copied */ int origin; /* if origin is to be copied */ int scale; /* if scale is to be copied */ int label; /* if label is to be copied */ int units; /* if units is to be copied */ int coord; /* if coord is to be copied */ int format; /* if format is to be copied */ int sign; /* if sign is to be copied */ int compression; /* if compression is to be copied */ int byteorder; /* if byteorder is to be copied */ int SCIL_TYPE; /* if SCIL_TYPE is to be copied */ int data; /* number of bytes in icsdata is to be copied*/ } ICSC; #endif // ICS_H ���������������������������������������������������������������������������imview-1.1.9c/io/imSystem.cxx�����������������������������������������������������������������������0000644�0000765�0000765�00000005161�07653237121�016751� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: imSystem.cxx,v 4.0 2003/04/28 14:44:33 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Some wrappers for system functions * * Hugues Talbot 29 Jul 1998 * *-----------------------------------------------------------------------*/ #include <stdio.h> static bool isStd = false; FILE *im_fopen(const char *path, const char *mode) { if (path[0] == '|') { isStd = true; if (mode[0] == 'r') return stdin; else return stdout; } else { isStd = false; return fopen(path, mode); } } int im_fclose (FILE *stream) { if (!isStd) return fclose(stream); else return 0; } // the assumption here is that there will always be only // one temporary file made from stdin... extern char *imTempFileName; // declared in imview.C int stdinToTemp(void) { FILE *fp; int i; imTempFileName = tempnam(0, "flim"); if ((fp = im_fopen(imTempFileName, "w")) == 0) { return 10; } else { /* copy the data */ while ( (i=getchar()) != EOF) putc(i,fp); fclose(fp); } return 0; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/imSystem.hxx�����������������������������������������������������������������������0000644�0000765�0000765�00000003432�07653237121�016755� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: imSystem.hxx,v 4.0 2003/04/28 14:44:33 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ #ifndef IMSYSTEM_H #define IMSYSTEM_H // some wrapped functions FILE *im_fopen(const char *path, const char *mode); int im_fclose (FILE *stream); int stdinToTemp(void); #endif ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/loadtiff-code.h��������������������������������������������������������������������0000644�0000765�0000765�00000037067�10065514725�017275� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: loadtiff-code.h,v 4.2 2004/06/21 08:18:29 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Decodes the TIFF format. * Should be able to read any data format. Will deal with non-char * data * * Based on `loadtiff.c' by the same author * * Hugues Talbot 10 Jan 1998 * *-----------------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> #include <tiffio.h> #include <stdarg.h> #include "loadtiff.h" /* useful function for decoding TIFF image type */ int getTiffType(int pi, /* photometric interpretation */ int sf, /* sample format */ int spp, /* samples per pixel */ int bps, /* bits per sample */ pixtype *pixeltype, imgtype *imagetype) { int tys[][3] = { {IM_BINARY,IM_BINARY, -1,}, {IM_UINT1, IM_UINT1, -1,}, /* we _never_ handle signed char */ {IM_INT2, IM_UINT2, -1,}, {IM_INT4, IM_UINT4, IM_FLOAT,}, {IM_INT8, IM_UINT8, IM_DOUBLE,} }; int idx1, idx2; *imagetype = IM_UNSPEC; /*-- default imagetype is 'unspecified'--*/ if(spp == 3 && bps == 8 && pi == 2) { *pixeltype = IM_UINT1; *imagetype = IM_RGB; /*--assume RGB--*/ return 0; } switch(bps) { case 1: idx1 = 0; break; case 4: idx1 = 1; break; case 8: idx1 = 1; break; case 12:idx1 = 2; break; case 16:idx1 = 2; break; case 32:idx1 = 3; break; case 64:idx1 = 4; break; default: *imagetype = IM_ERROR; return 1; /* error unknown image type */ } if(sf == 1 || sf == 4) idx2 = 1; else if(sf == 2) idx2 = 0; else if(sf == 3) idx2 = 2; else { *imagetype = IM_ERROR; return 1; /* error unknown image type */ } *pixeltype = (pixtype)(tys[idx1][idx2]); if(*pixeltype == -1) { *imagetype = IM_ERROR; return 1; /* error unknown image type */ } else { *imagetype = IM_SPECTRUM; /* default to single component image */ return 0; } } /* this is the unalterated function from the LIAR. */ /* Hugues Talbot 10 Jan 1998 */ int load_tiff(const char *fname, /* file name */ int imageindex, /* image index in the file to load */ int start[3], /* dimensions start */ int end[3], /* dimensions end */ int *pi, /* photometric interpretation */ int *sf, /* storage format */ int *spp, /* samples per pixel */ int *bps, /* bits per pixel */ unsigned short *colourmap[3], /* RGB lut */ long *ncolours, /* nb of colours in the lut */ void **inbuffp) /* data buffer for this image */ { /** Loads a TIFF image of any type. RETURN VALUE: int DESCRIPTION: Loads a TIFF image. Always allocate a 2D buffer. HISTORY: by Hugues Talbot and Ed Breen 9 Dec 1996 TESTS: REFERENCES: KEYWORDS: input/output **/ TIFF *tif; void **buffp; uint8 *bufIn, *cp, *cpi; uint16 *sp, *spi, photometric, sampleformat; uint16 *red_cm, *green_cm, *blue_cm; uint32 *lp, *lpi; double *dp, *dpi; tsize_t tf_bytesperrow; uint16 config; uint32 imWidth, imLength; uint16 samplesperpixel; uint16 bitspersample; float imXposition, imYposition; unsigned int i, j, jj, k, l; int n, range, nbcols; /* first open the TIFF file */ if ((tif = TIFFOpen(fname, "r")) == NULL) { LIARerror("Cannot open file %s", fname); return(1); } /* then start by reading the correct subimage */ if (!TIFFSetDirectory(tif, imageindex)) { /* this is quite legitimate to try to read beyond the last index */ TIFFClose(tif); return(2); } /* get information on the image */ TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitspersample); TIFFGetFieldDefaulted(tif, TIFFTAG_SAMPLESPERPIXEL, &samplesperpixel); tf_bytesperrow = TIFFScanlineSize(tif); TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &imWidth); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imLength); /* although as we use it, the X and Y positions are always integer, they are stored as float in the Tiff Lib */ if (!TIFFGetField(tif, TIFFTAG_XPOSITION, &imXposition)) imXposition = 0.0; if (!TIFFGetField(tif, TIFFTAG_YPOSITION, &imYposition)) imYposition = 0.0; if (!TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &sampleformat)) { /* NOTE: if this field is not present then the data is integer... */ if (bitspersample > 16) sampleformat = 2; /* signed for ints and doubles */ else sampleformat = 1; /* unsigned for shorts, chars and lower */ } TIFFGetFieldDefaulted(tif, TIFFTAG_PHOTOMETRIC, &photometric); /* check for colourmap images (Pseudocolor) */ range = 256L; /* old-style 8 bit palettes */ if (photometric == PHOTOMETRIC_PALETTE) { TIFFGetField(tif, TIFFTAG_COLORMAP, &red_cm, &green_cm, &blue_cm); nbcols = 1 << ((bitspersample < 8) ? 8 : bitspersample); for (n = 0; n < (int) nbcols; n++) if ((red_cm[n] >= 256) || (green_cm[n] >= 256) || (blue_cm[n] >= 256)) { range=65535L; break; } } /* fill what is expected of us... */ start[0] = (int)imXposition; end[0] = (int)imXposition + imWidth - 1; start[1] = (int)imYposition; end[1] = (int)imYposition + imLength - 1; start[2] = 0; end[2] = 0; /* preparing for a 3d extention to TIFF */ *spp = samplesperpixel; *bps = bitspersample; *sf = sampleformat; *pi = photometric; buffp = (void **) malloc(samplesperpixel * sizeof(void *)); /* allocate the input buffer (must be known to the TIFF system) */ if ((bufIn = (uint8 *)_TIFFmalloc((tf_bytesperrow+1) * sizeof(uint8))) == NULL) { LIARerror("Error(TIFFRead): Not enough memory"); TIFFClose(tif); return(2); } for (i = 0 ; i < samplesperpixel ; i++) { /* prepare output image buffer */ switch (bitspersample) { /* smaller than 8-bit must be expanded */ case 1: case 4: if ((buffp[i] = malloc(imLength * imWidth * sizeof(uint8))) == NULL) { LIARerror("Error(TIFFRead): Not enough memory"); _TIFFfree(bufIn); TIFFClose(tif); return(3); } break; /* these must be expanded to 16 bits */ case 12: if ((buffp[i] = malloc(imLength * imWidth * sizeof(uint16))) == NULL) { LIARerror("Error(TIFFRead): Not enough memory"); _TIFFfree(bufIn); TIFFClose(tif); return(3); } break; case 8: case 16: case 32: case 64: if ((buffp[i] = malloc(imLength * tf_bytesperrow)) == NULL) { LIARerror("Error(TIFFRead): Not enough memory"); _TIFFfree(bufIn); TIFFClose(tif); return(4); } break; default: LIARerror("Error(TIFFRead): unsupported word length"); _TIFFfree(bufIn); TIFFClose(tif); return(8); } } /* read can be performed now */ LIARdebug("Reading TIFF file %s ; [%d]x[%d], %d bps, %d spp, %d pi, %d sf\n", fname, imWidth, imLength, bitspersample, samplesperpixel, photometric, sampleformat); /* get planar arrangement */ TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &config); switch (config) { case PLANARCONFIG_CONTIG : /* all the data is arranged like this: RGBRGBRGB... */ LIARdebug("Contig config"); for (l = 0 ; l < imLength ; l++) { if (TIFFReadScanline(tif, bufIn, l, 0) < 0) { LIARerror("(load_tiff): Error while reading line %d", l); for (i = 0 ; i < samplesperpixel ; i++) free(buffp[i]); _TIFFfree(bufIn); TIFFClose(tif); return 13; } switch (bitspersample) { case 1: for (k = 0 ; k < samplesperpixel ; k++) { cp = (uint8*)(buffp[k]); for (j = 0 ; j < imWidth ; j++) { jj = k + j*samplesperpixel; cp[j + l*imWidth] = (uint8) ((uint8)(bufIn[jj>>3] & (1 << (7-jj%8))) > 0); } } break; case 4: for (k = 0 ; k < samplesperpixel ; k++) { cp = (uint8*)(buffp[k]); for (j = 0 ; j < imWidth ; j++) { jj = k + j*samplesperpixel; cp[j + l*imWidth] = (uint8) ((uint8)(bufIn[jj>>1] << 4)); } } break; case 8: for (k = 0 ; k < samplesperpixel ; k++) { cp = (uint8*)(buffp[k]) + l*imWidth; cpi = bufIn + k; for (j = 0 ; j < imWidth ; j++) { *cp++ = *cpi; cpi += samplesperpixel; } } break; case 12: { /* assuming 2*12bits packed in 3*8-bits variables */ int linelength = samplesperpixel * imWidth; int b, p, byteindex; uint16 msb, lsb, val; for (b = 0, p = 0 ; b < linelength ; ++b) { byteindex = (b * 3) / 2; if ((b % 2) == 0) { msb = bufIn[byteindex]; lsb = bufIn[byteindex+1]; val = (msb << 4) + (lsb >> 4); } else { msb = bufIn[byteindex] & 0x0f; lsb = bufIn[byteindex+1]; val = (msb << 8) + lsb; } /* find component */ k = b % samplesperpixel; /* should work when samplesperpixel == 1 */ sp = (uint16*)(buffp[k]) + l*imWidth; sp[p++] = val; } } break; case 16: for (k = 0 ; k < samplesperpixel ; k++) { sp = (uint16*)(buffp[k]) + l*imWidth; spi = (uint16*)bufIn + k; for (j = 0 ; j < imWidth ; j++) { *sp++ = *spi; spi += samplesperpixel; } } break; case 32: for (k = 0 ; k < samplesperpixel ; k++) { lp = (uint32*)(buffp[k]) + l*imWidth; lpi = (uint32*)bufIn + k; for (j = 0 ; j < imWidth ; j++) { *lp++ = *lpi; lpi += samplesperpixel; } } break; case 64: for (k = 0 ; k < samplesperpixel ; k++) { dp = (double*)(buffp[k]) + l*imWidth; dpi = (double*)bufIn + k; for (j = 0 ; j < imWidth ; j++) { *dp++ = *dpi; dpi += samplesperpixel; } } break; } } break; case PLANARCONFIG_SEPARATE: /* this is a little easier: RRRR..., then GGG..., then BBB..., etc */ LIARdebug("Separate config"); for (k = 0 ; k < samplesperpixel ; k++) { for (l = 0 ; l < imLength ; l++) { /* read component k in line l */ if (TIFFReadScanline(tif, bufIn, l, k) < 0) { LIARerror("(load_tiff): Error while reading component %d in line %d", k, l); for (i = 0 ; i < samplesperpixel ; i++) free(buffp[i]); _TIFFfree(bufIn); TIFFClose(tif); return 13; } /* write this line out */ switch (bitspersample) { case 1: cp = (uint8*)(buffp[k]); for (j = 0 ; j < imWidth ; j++) { cp[j + l*imWidth] = (uint8) ((uint8)(bufIn[j>>3] & (1 << (7-j%8))) > 0); } break; case 4: cp = (uint8*)(buffp[k]); for (j = 0 ; j < imWidth ; j++) { cp[j + l*imWidth] = (uint8) ((uint8)(bufIn[j>>1] << 4)); } break; case 8: cp = (uint8*)(buffp[k]) + l*imWidth; cpi = bufIn; for (j = 0 ; j < imWidth ; j++) *cp++ = *cpi++; break; case 12: { /* assuming 2*12bits packed in 3*8-bits variables */ int linelength = imWidth; int b, p, byteindex; uint16 msb, lsb, val; for (b = 0, p = 0 ; b < linelength ; ++b) { byteindex = (b * 3) / 2; if ((b % 2) == 0) { msb = bufIn[byteindex]; lsb = bufIn[byteindex+1]; val = (msb << 4) + (lsb >> 4); } else { msb = bufIn[byteindex] & 0x0f; lsb = bufIn[byteindex+1]; val = (msb << 8) + lsb; } /* find component */ sp = (uint16*)(buffp[k]) + l*imWidth; sp[p++] = val; } } break; case 16: sp = (uint16*)(buffp[k]) + l*imWidth; spi = (uint16*)bufIn; for (j = 0 ; j < imWidth ; j++) *sp++ = *spi++; break; case 32: lp = (uint32*)(buffp[k]) + l*imWidth; lpi = (uint32*)bufIn; for (j = 0 ; j < imWidth ; j++) *lp++ = *lpi++; break; case 64: dp = (double*)(buffp[k]) + l*imWidth; dpi = (double*)bufIn; for (j = 0 ; j < imWidth ; j++) *dp++ = *dpi++; break; } } } break; default: LIARerror("Unrecognized pixel configuration"); for (i = 0 ; i < samplesperpixel ; i++) free(buffp[i]); _TIFFfree(bufIn); TIFFClose(tif); return(16); } /* apply the palette if needs be */ /* reduce everything to an 8bit RGB image. Too hard otherwise */ if ((photometric == PHOTOMETRIC_PALETTE) && (*bps == 8) && (*spp == 1)) { uint8 *pR, *pG, *pB, *q; uint8 **outbuffp; outbuffp = (uint8 **) malloc(3 * sizeof(void *)); pR = outbuffp[0] = (uint8 *)malloc(imLength*imWidth*sizeof(uint8)); pG = outbuffp[1] = (uint8 *)malloc(imLength*imWidth*sizeof(uint8)); pB = outbuffp[2] = (uint8 *)malloc(imLength*imWidth*sizeof(uint8)); q = (uint8*)(buffp[0]); for (i = 0 ; i < imLength * imWidth ; i++) { (*pR) = (255*red_cm[*q])/range; (*pG) = (255*green_cm[*q])/range; (*pB) = (255*blue_cm[*q])/range; pR++; pG++; pB++; q++; } free(buffp[0]); free(buffp); /* change the interpretation */ *spp = 3; /* RGB */ *pi = PHOTOMETRIC_RGB; /* same */ *inbuffp = outbuffp; } else { /* return the allocated buffer */ *inbuffp = buffp; } /* at the moment, no CLUT Hugues Talbot 11 Dec 1996 */ *ncolours = 0; colourmap[0] = colourmap[1] = colourmap[2] = 0; TIFFClose(tif); _TIFFfree(bufIn); return 0; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/loadtiff.h�������������������������������������������������������������������������0000644�0000765�0000765�00000002032�07653237121�016346� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/*------------------------------------------------------------------------ * * * Decodes the TIFF format * * *-----------------------------------------------------------------------*/ #ifndef LOADTIFF_H #define LOADTIFF_H #include <tiffio.h> int getTiffType(int pi, int sf, int spp, int bps, pixtype *pixeltype, imgtype *imagetype); int load_tiff(const char *fname, /* file name */ int imageindex, /* image index in the file to load */ int start[3], /* dimensions start */ int end[3], /* dimensions end */ int *pi, /* photometric interpretation */ int *sf, /* storage format */ int *spp, /* samples per pixel */ int *bps, /* bits per pixel */ unsigned short *colourmap[3], /* RGB lut */ long *ncolours, /* nb of colours in the lut */ void **inbuffp); /* data buffer for this image */ #endif /* defined(LOADTIFF_H) */ ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/Makefile.in������������������������������������������������������������������������0000644�0000765�0000765�00000004320�10730372353�016451� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- Makefile -*- # Hand-generated makefile for the I/O parts of ImView # Hugues Talbot 23 Apr 1998 # SHELL = /bin/sh VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ subdirs = @subdirs@ top_srcdir = @top_srcdir@ srcdir = @srcdir@ bindir = $(exec_prefix)/bin infodir = $(prefix)/info libdir = $(prefix)/lib/gnudl mandir = $(prefix)/man/man1 # compilers and flags CC = @CC@ CXX = @CXX@ CPPFLAGS = @CPPFLAGS@ CFLAGS = $(CPPFLAGS) @CFLAGS@ CXXFLAGS = $(CPPFLAGS) @CXXFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ INSTALL = @INSTALL@ # program to make the archive: LIBNAME = @LIBNAME@ LIBCOMMAND = @LIBCOMMAND@ RANLIB = @RANLIB@ DSONAME = @DSONAME@ DSOCOMMAND = @DSOCOMMAND@ # Extra linking stuff needed by some compilers LIBXTRA = @LIBXTRA@ # we are building a library TOP = ${top_srcdir} #include ${FLDIR}/makeinclude TARGET = imview_io.a # so as to include the class declarations and config.h CXXFLAGS += -I${TOP} -I.. CPPFILES = \ readjpeg.cxx \ readgif.cxx \ readtiff.cxx \ readZimage.cxx \ readics.cxx \ readpnm.cxx \ cpostscript.cxx \ savetiff.cxx \ saveZimage.cxx \ imSystem.cxx \ gplot2.cxx \ newprefio.cxx \ readsocket.cxx \ readraw.cxx \ readmat5.cxx \ readMagick.cxx \ writeMagick.cxx \ readps.cxx \ readpng.cxx \ readmeta.cxx OBJECTS = $(CPPFILES:.cxx=.o) ## rules for C and H files to be generated from .fl files .SUFFIXES : .cxx .o .cc # DEC Unix has some .cc files to be included. Do not compile them .cc: @echo "Do nothing with $<" .cxx.o : $(CXX) $(CXXTRA) $(CXXFLAGS) -c $< $(TARGET) : $(OBJECTS) $(LIBCOMMAND) $(TARGET) $(OBJECTS) $(LIBXTRA) $(RANLIB) $(TARGET) all: $(TARGET) test: @echo "CPP files:\t" $(CPPFILES) @echo "Object files:\t" $(OBJECTS) @echo "Target: \t" $(TARGET) @echo "Libxtra: \t" $(LIBXTRA) clean: - @rm *.a *.o cxx_repository/*.o realclean: - @rm *.o *.a *~ *.da *.bb *.bbg .ix[0-9]* .inslog* @touch makedepend depend: ${CPPFILES} ${CFILES} $(CXX) $(CXXTRA) $(CXXFLAGS) -M $^ > makedepend makedepend: touch makedepend include makedepend # dependencies ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/newprefio.cxx����������������������������������������������������������������������0000644�0000765�0000765�00000015512�10637222145�017132� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: newprefio.cxx,v 1.7 2007/06/23 13:47:17 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * New preference I/O mechanism, using the FLTK facilities. * * Hugues Talbot 2 Jun 2003 * *-----------------------------------------------------------------------*/ #include <string.h> #include <assert.h> #include <FL/Fl.H> #include <FL/Fl_Preferences.H> #include <FL/filename.H> #include "imview.hxx" #include "imnmspc.hxx" // namespace, etc #include "newprefio.hxx" imprefs::imprefs() { dbgprintf("imprefs constructed\n"); imPrefs_ = new Fl_Preferences(Fl_Preferences::USER, "hugues.talbot_csiro.au", "imview"); // memory for char stuff prefsPath_ = new char[FL_PATH_MAX]; gspath_ = new char[DFLTSTRLEN]; gvpath_ = new char[DFLTSTRLEN]; xorBreakLines_ = new char[SMALSTRLEN]; xorProfileLines_ = new char[SMALSTRLEN]; // set default values defaultPrefs(); } imprefs::~imprefs() { delete[] gspath_; delete[] gvpath_; delete[] xorBreakLines_; delete[] xorProfileLines_; delete imPrefs_; dbgprintf("imprefs destructed\n"); } void imprefs::defaultPrefs() { // general strcpy(prefsPath_, ""); smoothZoomout_ = false; // performance keepPoints_ = false; // most logical? mouseZoomType_ = ZOOM_CONSTRAINED; overlayTransparency_ = 0.8; // Postscript strcpy(gspath_, "gs"); strcpy(gvpath_, "ghostview"); psRenderRes_ = 150.0; // speed psDisplayRes_ = 75.0; // looks good psRenderDepth_ = PSREND_COLOUR; // looks best psRenderSmooth_ = true; // looks over performance psAntialiasRender_ = true; // same here psBoundingBox_ = PAGESIZE_AUTO; // server pollFrequency_ = 100.0; requirePassword_ = false; // not implemented yet locahostOnly_ = false; // doesn't work anyway // expert stuff #ifdef MACOSX_CARBON hideMenu_ = true; // on Macs we use the system menu. #else hideMenu_ = false; // default not an expert #endif // debug stuff strcpy(xorBreakLines_,"0xffffeffe"); strcpy(xorProfileLines_, "0x1b2dc3a4"); // esoteric } // pretty obvious int imprefs::readprefs(const char *) { int ival; assert(imPrefs_ != 0); imPrefs_->getUserdataPath(prefsPath_, FL_PATH_MAX); dbgprintf("Data path = (%s)\n", prefsPath_); Fl_Preferences imGeneral(*imPrefs_, "General"); imGeneral.get("smoothZoomOut", ival, 0); smoothZoomout_ = (ival > 0); imGeneral.get("keepPoints", ival, 0); keepPoints_ = (ival > 0); imGeneral.get("mouseZoomType", ival, 0); mouseZoomType_ = (zoomtype)ival; imGeneral.get("overlayTransparency", overlayTransparency_, 0.8); Fl_Preferences imPostscript(*imPrefs_, "Postscript"); imPostscript.get("gspath", gspath_, "gs", DFLTSTRLEN-1); imPostscript.get("gvpath", gvpath_, "ghostview", DFLTSTRLEN-1); imPostscript.get("psRenderRes", psRenderRes_, 150.0); imPostscript.get("psDiplayRes", psDisplayRes_, 75.0); imPostscript.get("psRenderDepth", ival, 0); psRenderDepth_ = (psrendertype)ival; imPostscript.get("psRenderSmooth", ival, 0); psRenderSmooth_ = (ival>0); imPostscript.get("psAntialiasRender", ival, 0); psAntialiasRender_ = (ival > 0); int psbb = psBoundingBox_; imPostscript.get("psBoundingBox", psbb, 0); Fl_Preferences imServer(*imPrefs_, "Server"); imServer.get("pollFrequency", pollFrequency_, 100.0); imServer.get("requirePassword", ival, 0); requirePassword_ = (ival>0); imServer.get("locahostOnly", ival, 0); locahostOnly_ = (ival > 0); Fl_Preferences imExpert(*imPrefs_, "Expert"); imExpert.get("hideMenu", ival, 0); hideMenu_ = (ival > 0); Fl_Preferences imDebug(*imPrefs_, "Debug"); imDebug.get("xorBreakLines", xorBreakLines_, "0xffffeffe", SMALSTRLEN-1); imDebug.get("xorProfileLines", xorProfileLines_, "0x1b2dc3a4", SMALSTRLEN-1); return 0; } // even more obvious int imprefs::writeprefs(const char *) { assert(imPrefs_ != 0); Fl_Preferences imGeneral(*imPrefs_, "General"); imGeneral.set("smoothZoomOut", (int)smoothZoomout_); imGeneral.set("keepPoints", (int)keepPoints_); imGeneral.set("mouseZoomType", (int)mouseZoomType_); imGeneral.set("overlayTransparency", overlayTransparency_); Fl_Preferences imPostscript(*imPrefs_, "Postscript"); imPostscript.set("gspath", gspath_); imPostscript.set("gvpath", gvpath_); imPostscript.set("psRenderRes", psRenderRes_); imPostscript.set("psDiplayRes", psDisplayRes_); imPostscript.set("psRenderDepth", (int)psRenderDepth_); imPostscript.set("psRenderSmooth", (int)psRenderSmooth_); imPostscript.set("psAntialiasRender", (int)psAntialiasRender_); imPostscript.set("psBoundingBox", (int)psBoundingBox_); Fl_Preferences imServer(*imPrefs_, "Server"); imServer.set("pollFrequency", pollFrequency_); imServer.set("requirePassword", (int)requirePassword_); imServer.set("locahostOnly", (int)locahostOnly_); Fl_Preferences imExpert(*imPrefs_, "Expert"); imExpert.set("hideMenu", (int)hideMenu_); Fl_Preferences imDebug(*imPrefs_, "Debug"); imDebug.set("xorBreakLines", xorBreakLines_); imDebug.set("xorProfileLines", xorProfileLines_); imPrefs_->flush(); dbgprintf("Preferences flushed\n"); return 0; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/newprefio.hxx����������������������������������������������������������������������0000644�0000765�0000765�00000013004�10065604403�017125� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: newprefio.hxx,v 1.5 2004/06/21 16:12:51 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * New preference I/O mechanism, using the FLTK facility this time, * unfortunately not STL-based. * * Hugues Talbot 2 Jun 2003 * * * *-----------------------------------------------------------------------*/ #ifndef NEWPREFIO_H #define NEWPREFIO_H #include <string.h> #include <FL/Fl.H> #include <FL/Fl_Preferences.H> typedef enum {PSREND_COLOUR=0,PSREND_GREY, PSREND_BW} psrendertype; typedef enum {ZOOM_UNCONSTRAINED = 0, ZOOM_CONSTRAINED} zoomtype; // the imview preferences class imprefs { public: imprefs(); ~imprefs(); // setters // data in (from the dialog) void prefspath(const char *p) {strncpy(prefsPath_, p, DFLTSTRLEN-1);} void smoothZoomout(bool s) {smoothZoomout_ = s;} void keepPoints(bool s) { keepPoints_ = s;} void mouseZoomType(zoomtype z) {mouseZoomType_ = z;} void overlayTransparency(double t) {overlayTransparency_ = t;} void gspath(const char *s) {strncpy(gspath_, s,DFLTSTRLEN-1);} void psRenderRes(double r) {psRenderRes_ = r;} void psDisplayRes(double r) {psDisplayRes_ = r;} void psBoundingBox(page_size b) {psBoundingBox_ = b;} void gvpath(const char *s) {strncpy(gvpath_, s,DFLTSTRLEN-1);} void psRenderDepth(psrendertype p) {psRenderDepth_ = p;} void psRenderSmooth(bool s) {psRenderSmooth_ = s;} void psAntialiasRender(bool s) {psAntialiasRender_ =s;} void pollFrequency(double f) {pollFrequency_ = f;} void requirePassword(bool p) {requirePassword_ = p;} void localhostOnly(bool l) {locahostOnly_ = l;} void hideMenu(bool h) {hideMenu_ = h;} void xorBreakLines(const char *s) {strncpy(xorBreakLines_, s, SMALSTRLEN-1);} void xorProfileLines(const char *s) {strncpy(xorProfileLines_, s, SMALSTRLEN-1);} // getters // to the user const char *prefspath(void) {return prefsPath_;} bool smoothZoomout(void) {return smoothZoomout_;} bool keepPoints(void) {return keepPoints_;} zoomtype mouseZoomType(void) {return mouseZoomType_;} double overlayTransparency(void) {return overlayTransparency_;} const char *gspath(void) {return gspath_;} const char *gvpath(void) {return gvpath_;} double psRenderRes(void) {return psRenderRes_;} double psDisplayRes(void) {return psDisplayRes_;} psrendertype psRenderDepth(void) {return psRenderDepth_;} page_size psBoundingBox(void) {return psBoundingBox_;} bool psRenderSmooth(void) {return psRenderSmooth_;} bool psAntialiasRender(void) {return psAntialiasRender_;} const char *xorBreakLines(void) {return xorBreakLines_;} const char *xorProfileLines(void) {return xorProfileLines_;} bool requirePassword(void) {return requirePassword_;} bool localhostOnly(void) {return locahostOnly_;} bool hideMenu(void) {return hideMenu_;} double pollFrequency(void) {return pollFrequency_;} void defaultPrefs(void); int readprefs(const char *fromfile); int writeprefs(const char *tofile); private: // one per tab Fl_Preferences *imPrefs_; // general stuff char *prefsPath_; bool smoothZoomout_, keepPoints_; zoomtype mouseZoomType_; double overlayTransparency_; // Postscript char *gspath_, *gvpath_; double psRenderRes_, psDisplayRes_; psrendertype psRenderDepth_; page_size psBoundingBox_; bool psRenderSmooth_, psAntialiasRender_; // server double pollFrequency_; bool requirePassword_, locahostOnly_; // expert stuff bool hideMenu_; // debug stuff char *xorBreakLines_, *xorProfileLines_; }; #endif // NEWPREFIO_H ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readgif.cxx������������������������������������������������������������������������0000644�0000765�0000765�00000032304�10054565124�016533� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readgif.cxx,v 4.1 2004/05/25 06:40:20 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ // readgif.C // adapted for my own purposed by Hugues Talbot 21 Jan 1998 // in particular got rid of the silly conversion to pixmap! // now returns the data in a simple GL or RGB buffer // Extensively modified from original code for gif2ras by // Patrick J. Naughton of Sun Microsystems. The original // copyright notice follows: /* gif2ras.c - Converts from a Compuserve GIF (tm) image to a Sun Raster image. * * Copyright (c) 1988 by Patrick J. Naughton * * Author: Patrick J. Naughton * naughton@wind.sun.com * * Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, * provided that the above copyright notice appear in all copies and that * both that copyright notice and this permission notice appear in * supporting documentation. * */ #include "imnmspc.hxx" // name space definition if needed #include <stdio.h> #include <stdlib.h> #include <string.h> #include "imview.hxx" #include "imSystem.hxx" #include "imageIO.hxx" #include "readgif.hxx" extern imageIO *IOBlackBox; // DEC cxx doesn't like that! static uchar *loadGifImage(FILE *GifFile, int *imWidth,int *imHeight, int *imDepth, int inumber=0); int readGifImage(const char *GifFileName, // file to read int inumber) // which image in movie (0 = first) { FILE *fp; uchar *outbuf; int imWidth, imHeight, imDepth; if ((fp = im_fopen(GifFileName, "rb")) == 0) { errprintf("Cannot open %s\n", GifFileName); return 0; } outbuf = loadGifImage(fp, &imWidth, &imHeight, &imDepth, inumber); // this will require no translation IOBlackBox->setImData(outbuf); IOBlackBox->setCurrImgWidth(imWidth); IOBlackBox->setCurrImgHeight(imHeight); IOBlackBox->setCurrImgThickness(1); IOBlackBox->setXOffset(0); IOBlackBox->setYOffset(0); IOBlackBox->setZOffset(0); IOBlackBox->setCurrImgNbComps(1); // only a single image in a GIF file IOBlackBox->setCurrImgNbSamples(imDepth); IOBlackBox->setCurrImgSpp(imDepth); // needed here because no currBuffp IOBlackBox->setCurrPixType(IM_UINT1); IOBlackBox->setCurrImgType((imDepth == 3) ? IM_RGB : IM_SPECTRUM); IOBlackBox->setImgDesc("GIF"); fclose(fp); return (outbuf == 0); } #define NEXTBYTE getc(GifFile) #define GETSHORT(var) var = NEXTBYTE; var += NEXTBYTE << 8 // This function returns the number of frames // in an animated GIF file. Negative numbers indicate // errors int gifnbsubfiles(const char *fname) { int i; FILE *GifFile; int inumber = 0; if ((GifFile = im_fopen(fname, "rb")) == NULL) return -1; // can't read the file { char b[6]; if (fread(b,1,6,GifFile)<6) return 0; /* quit on eof */ if (b[0]!='G' || b[1]!='I' || b[2] != 'F') { dbgprintf("not a GIF file!\n"); return 0;} if (b[3]!='8' || b[4]>'9' || b[5]!= 'a') dbgprintf("GIF version %c%c%c. May cause trouble\n",b[3],b[4],b[5]); } int Width; GETSHORT(Width); int Height; GETSHORT(Height); uchar ch = NEXTBYTE; char HasColormap = ((ch & 0x80) != 0); int BitsPerPixel = (ch & 7) + 1; int ColorMapSize = 1 << BitsPerPixel; // int OriginalResolution = ((ch>>4)&7)+1; // int SortedTable = (ch&8)!=0; NEXTBYTE; // Background Color index NEXTBYTE; // Aspect ratio is N/64 // Read in global colormap: uchar transparent_pixel = 0; char has_transparent = 0; if (HasColormap) { for (i=0; i < ColorMapSize; i++) { NEXTBYTE; NEXTBYTE; NEXTBYTE; } } else { dbgprintf("File does not have a colormap.\n"); } int CodeSize; /* Code size, init from GIF header, increases... */ char Interlace; for (;;) { i = NEXTBYTE; if (i<0) {dbgprintf("reached EOF\n"); break;} int blocklen; if (i == 0x21) { // a "gif extension" ch = NEXTBYTE; blocklen = NEXTBYTE; if (ch==0xF9 && blocklen==4) { // Netscape animation extension char bits; bits = NEXTBYTE; NEXTBYTE; NEXTBYTE; // GETSHORT(delay); transparent_pixel = NEXTBYTE; if (bits & 1) has_transparent = 1; blocklen = NEXTBYTE; } else if (ch == 0xFF) { ; // Netscape repeat count } else { dbgprintf("unknown gif extension 0x%02x\n", ch); } } else if (i == 0x2c) { // an image NEXTBYTE; NEXTBYTE; // GETSHORT(x_position); NEXTBYTE; NEXTBYTE; // GETSHORT(y_position); GETSHORT(Width); GETSHORT(Height); ch = NEXTBYTE; Interlace = ((ch & 0x40) != 0); if (ch&0x80) { // skip over local color map int n = 1<<((ch&7)+1); // does this replace ColorMapSize ?? for (i=0; i < n; i++) { NEXTBYTE; NEXTBYTE; NEXTBYTE; } } CodeSize = NEXTBYTE+1; inumber++; // count the next block blocklen = NEXTBYTE; } else { dbgprintf("unknown gif code 0x%02x, piking out.\n", i); blocklen = 0; break; // taking no chance there. } // skip the data: while (blocklen>0) {while (blocklen--) {NEXTBYTE;} blocklen=NEXTBYTE;} } fclose(GifFile); return inumber; } static uchar *loadGifImage(FILE *GifFile, // file to read int *imWidth, int *imHeight, int *imDepth, int inumber // which image in movie (0 = first) ) { uchar *outbuf = 0; int i; { char b[6]; if (fread(b,1,6,GifFile)<6) return 0; /* quit on eof */ if (b[0]!='G' || b[1]!='I' || b[2] != 'F') { dbgprintf("not a GIF file!\n"); return 0;} if (b[3]!='8' || b[4]>'9' || b[5]!= 'a') dbgprintf("GIF version %c%c%c. May cause trouble\n",b[3],b[4],b[5]); } int Width; GETSHORT(Width); int Height; GETSHORT(Height); uchar ch = NEXTBYTE; char HasColormap = ((ch & 0x80) != 0); int BitsPerPixel = (ch & 7) + 1; int ColorMapSize = 1 << BitsPerPixel; // int OriginalResolution = ((ch>>4)&7)+1; // int SortedTable = (ch&8)!=0; NEXTBYTE; // Background Color index NEXTBYTE; // Aspect ratio is N/64 // Read in global colormap: uchar transparent_pixel = 0; char has_transparent = 0; uchar Red[256], Green[256], Blue[256]; /* color map */ if (HasColormap) { for (i=0; i < ColorMapSize; i++) { Red[i] = NEXTBYTE; Green[i] = NEXTBYTE; Blue[i] = NEXTBYTE; } } else { dbgprintf("File does not have a colormap.\n"); for (i = 0; i < ColorMapSize; i++) Red[i] = Green[i] = Blue[i] = (i*256+ColorMapSize-1)/ColorMapSize; } int CodeSize; /* Code size, init from GIF header, increases... */ char Interlace; for (;;) { i = NEXTBYTE; if (i<0) {dbgprintf("unexpected EOF\n"); return 0;} int blocklen; // if (i == 0x3B) return 0; eof code if (i == 0x21) { // a "gif extension" ch = NEXTBYTE; blocklen = NEXTBYTE; if (ch==0xF9 && blocklen==4) { // Netscape animation extension char bits; bits = NEXTBYTE; NEXTBYTE; NEXTBYTE; // GETSHORT(delay); transparent_pixel = NEXTBYTE; if (bits & 1) has_transparent = 1; blocklen = NEXTBYTE; } else if (ch == 0xFF) { ; // Netscape repeat count } else { dbgprintf("unknown gif extension 0x%02x\n", ch); } } else if (i == 0x2c) { // an image NEXTBYTE; NEXTBYTE; // GETSHORT(x_position); NEXTBYTE; NEXTBYTE; // GETSHORT(y_position); GETSHORT(Width); GETSHORT(Height); ch = NEXTBYTE; Interlace = ((ch & 0x40) != 0); if (ch&0x80) { // read local color map int n = 1<<((ch&7)+1); // does this replace ColorMapSize ?? for (i=0; i < n; i++) { Red[i] = NEXTBYTE; Green[i] = NEXTBYTE; Blue[i] = NEXTBYTE; } } CodeSize = NEXTBYTE+1; if (!inumber--) break; // okay, this is the image we want blocklen = NEXTBYTE; } else { dbgprintf("unknown gif code 0x%02x\n", i); blocklen = 0; } // skip the data: while (blocklen>0) {while (blocklen--) {NEXTBYTE;} blocklen=NEXTBYTE;} } uchar *Image = new uchar[Width*Height]; if (!Image) { errprintf("Insufficient memory\n"); return(outbuf); } int YC = 0, Pass = 0; /* Used to de-interlace the picture */ uchar *p = Image; uchar *eol = p+Width; int InitCodeSize = CodeSize; int ClearCode = (1 << (CodeSize-1)); int EOFCode = ClearCode + 1; int FirstFree = ClearCode + 2; int FinChar = 0; int ReadMask = (1<<CodeSize) - 1; int FreeCode = FirstFree; int OldCode = ClearCode; // tables used by LZW decompresser: short int Prefix[4096]; uchar Suffix[4096]; int blocklen = NEXTBYTE; uchar thisbyte = NEXTBYTE; blocklen--; int frombit = 0; for (;;) { /* Fetch the next code from the raster data stream. The codes can be * any length from 3 to 12 bits, packed into 8-bit bytes, so we have to * maintain our location as a pointer and a bit offset. * In addition, gif adds totally useless and annoying block counts * that must be correctly skipped over. */ int CurCode = thisbyte; if (frombit+CodeSize > 7) { if (blocklen <= 0) { blocklen = NEXTBYTE; if (blocklen <= 0) break; } thisbyte = NEXTBYTE; blocklen--; CurCode |= thisbyte<<8; } if (frombit+CodeSize > 15) { if (blocklen <= 0) { blocklen = NEXTBYTE; if (blocklen <= 0) break; } thisbyte = NEXTBYTE; blocklen--; CurCode |= thisbyte<<16; } CurCode = (CurCode>>frombit)&ReadMask; frombit = (frombit+CodeSize)%8; if (CurCode == ClearCode) { CodeSize = InitCodeSize; ReadMask = (1<<CodeSize) - 1; FreeCode = FirstFree; OldCode = ClearCode; continue; } if (CurCode == EOFCode) break; uchar OutCode[1025]; // temporary array for reversing codes uchar *tp = OutCode; if (CurCode < FreeCode) i = CurCode; else if (CurCode == FreeCode) {*tp++ = FinChar; i = OldCode;} else {dbgprintf("LZW Barf!\n"); break;} while (i >= ColorMapSize) {*tp++ = Suffix[i]; i = Prefix[i];} *tp++ = FinChar = i; while (tp > OutCode) { *p++ = *--tp; if (p >= eol) { if (!Interlace) YC++; else switch (Pass) { case 0: YC += 8; if (YC >= Height) {Pass++; YC = 4;} break; case 1: YC += 8; if (YC >= Height) {Pass++; YC = 2;} break; case 2: YC += 4; if (YC >= Height) {Pass++; YC = 1;} break; case 3: YC += 2; break; } if (YC>=Height) YC=0; /* cheap bug fix when excess data */ p = Image + YC*Width; eol = p+Width; } } if (OldCode != ClearCode) { Prefix[FreeCode] = OldCode; Suffix[FreeCode] = FinChar; FreeCode++; if (FreeCode > ReadMask) { if (CodeSize < 12) { CodeSize++; ReadMask = (1 << CodeSize) - 1; } else FreeCode--; } } OldCode = CurCode; } // We are done reading the file, now convert to xpm: // transparent pixel must be zero, swap if it isn't: if (has_transparent && transparent_pixel != 0) { // swap transparent pixel with zero p = Image+Width*Height; while (p-- > Image) { if (*p==transparent_pixel) *p = 0; else if (!*p) *p = transparent_pixel; } uchar t; t = Red[0]; Red[0] = Red[transparent_pixel]; Red[transparent_pixel] = t; t =Green[0];Green[0]=Green[transparent_pixel];Green[transparent_pixel]=t; t =Blue[0];Blue[0] =Blue[transparent_pixel];Blue[transparent_pixel] = t; } // is the image colour or Grey-level? *imDepth = 1; for (i = 0 ; i < ColorMapSize ; i++) { if ((Red[i] != Green[i]) || (Red[i] != Blue[i])) { *imDepth = 3; break; } } *imWidth = Width; *imHeight = Height; int nbBytes = (*imWidth)*(*imHeight)*(*imDepth); outbuf = new uchar[nbBytes]; if (outbuf != 0) { uchar *end; uchar *q = Image; p = outbuf; end = p + nbBytes; // interprets the colour LUT if (*imDepth == 1) { while (p != end) { *p++ = Red[*q++]; } } else { while (p != end) { *p++ = Red[*q]; *p++ = Green[*q]; *p++ = Blue[*q++]; } } } delete[] Image; return outbuf; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readgif.hxx������������������������������������������������������������������������0000644�0000765�0000765�00000003750�07653237122�016550� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readgif.hxx,v 4.0 2003/04/28 14:44:34 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * readgif.H * * decodes a GIF file. Hugues Talbot 9 Jan 1998 * * * *-----------------------------------------------------------------------*/ #ifndef READGIF_H #define READGIF_H int readGifImage(const char *name, int whichFrame=0); int gifnbsubfiles(const char *name); #endif // READGIF_H ������������������������imview-1.1.9c/io/readics.cxx������������������������������������������������������������������������0000644�0000765�0000765�00000057602�07653237122�016561� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readics.cxx,v 4.0 2003/04/28 14:44:34 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /* * readics () - reads in ICS images * * Hugues Talbot 26 Mar 1998, based on * liar code by same author 18 Dec 1997 * itself based on Z-IMAGE code by Leanne Bischof */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <errno.h> #include <math.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include "imunistd.h" #include "imview.hxx" #include "imageIO.hxx" #include "ics.hxx" #include "readics.hxx" #define TRUE 1 #define FALSE 0 extern imageIO *IOBlackBox; /*--declarations of locally defined functions--*/ static int read_ics_header(char *filename, ICS *icsheader); static int read_ids_char(char *filename, unsigned char *dest, int length); static int read_ids_double(char *filename, double *dest, int length, int need_to_swap); static int read_ids_short(char *filename, short *dest, int length, int need_to_swap); static void swap_short(char *from, char *to, int nbytes); static void swap_float(char *from, char *to, int nbytes); int readICSImage(const char *name) { void *p, **pp; int res, nx, ny, nz; pixtype thepixtype; // call the low-level TIFF reader res = load_ics(name, &p, &thepixtype, &nx, &ny, &nz); pp = (void **)malloc(sizeof(void *)); pp[0] = p; if (res == 0) { // all went well // now reprocess that according to content // the new buffer needs to be set first before // the dimensions are changed because the previous buffer // might be freed, and we will need its dimensions. IOBlackBox->setCurrBuffp(pp); IOBlackBox->setCurrImgWidth(nx); IOBlackBox->setCurrImgHeight(ny); IOBlackBox->setCurrImgThickness(nz); IOBlackBox->setXOffset(0); IOBlackBox->setYOffset(0); IOBlackBox->setZOffset(0); IOBlackBox->setCurrImgType(IM_SPECTRUM); IOBlackBox->setCurrPixType((pixtype)thepixtype); IOBlackBox->setCurrImgNbComps(1); // best default here IOBlackBox->setCurrImgNbSamples(1); IOBlackBox->setCurrImgColourMap(0); IOBlackBox->setCurrImgNbColours(0); IOBlackBox->setImgDesc("ICS"); } return res; } // returns the number of frames in an ICS file int icsnbsubfiles(const char *) { return 1; // that was easy. } /* check endianness */ static int check_endian(void) /* no argument */ { /** returns the endianness of the current CPU RETURN VALUE: int Returns IS_BIGENDIAN (1) if the CPU is big-endian (Sun, SGI) Returns IS_LITTLEENDIAN (2) if the CUP is little-endian (DEC, Intel) DESCRIPTION: Returns the endianness of the current CPU HISTORY: Written by Hugues Talbot 22 Dec 1997 TESTS: REFERENCES: KEYWORDS: **/ union { long l; char c[sizeof (long)]; } u; u.l = 1; if (u.c[sizeof (long) - 1] == 1) return IS_BIGENDIAN; else return IS_LITTLEENDIAN; } /* SWAP_SHORT --------------------------------------------------------------- | | Description of sub-routine function... | |----------------------------------------------------------------------------*/ /* nbytes should be divisible by 2 */ void swap_short(char *from, char *to, int nbytes) /* char *from; char *to; int nbytes; */ { register int i; register char c; for (i = 0; i < nbytes; i+=2) { c = from[i]; to[i] = from[i+1]; to[i+1] = c; } } /* SWAP_FLOAT --------------------------------------------------------------- | | Description of sub-routine function... | |----------------------------------------------------------------------------*/ /* nbytes should be divisible by 4 */ static void swap_float(char *from, char *to, int nbytes) /* char *from; char *to; int nbytes; */ { register int i; register char c; for (i = 0; i < nbytes; i+=4) { c = from[i]; to[i] = from[i+3]; to[i+3] = c; c = from[i+1]; to[i+1] = from[i+2]; to[i+2] = c; } } static int read_ics_header(char *filename, /* input filename */ ICS *icsheader) /* ICS header */ { /** Reads the ICS header RETURN VALUE: int DESCRIPTION: Read the the ICS header file into the dataset description structure. char *filename : name of the file to be read ICS *icsheader : pointer to the dataset description structure int err : 0 = success -1 = allocation error -2 = file open error -3 = file read error -4 = not an ICS file -5 = illegal order in ICS file (layout variables missing or not defined at top) -6 = too high dimensional data HISTORY: Damir Sudar Copyright (c) University of California San Francisco TESTS: REFERENCES: KEYWORDS: **/ int fd, cat; unsigned int length, n_read, ui; char *buffer1, *buffer2, *end; char temp1[100],temp2[100]; int i; char *t, *tg, *bp; char delim1, delim2; static int kwrds = 14; static char *keywrdtable[] = { "parameters", "order", "sizes", "coordinates", "significant_bits", "format", "sign", "compression", "origin", "scale", "labels", "units", "byte_order", "SCIL_TYPE" }; /* make the proper filename and open the ICS file */ strcpy(temp1,filename); strcat(temp1,".ics"); if ((fd = open(temp1,O_RDONLY)) < 0) return(-2); /* get the length of the ICS file and rewind */ length = (unsigned int)lseek(fd,0L,2); lseek(fd,0L,0); /* allocate space for all data from the ICS file */ if ((buffer1 = (char *)malloc(length)) == NULL) { close(fd); return(-1); } /* allocate space for the unresolved data from the ICS file */ if ((buffer2 = (char *)malloc(length)) == NULL) { close(fd); free(buffer1); return(-1); } /* read the data into buffer1 and close the file */ if ((n_read = read(fd,buffer1,length)) != length) { close(fd); free(buffer1); free(buffer2); return(-3); } close(fd); /* initialisations */ icsheader->valid_filename = FALSE; icsheader->valid_parameters = FALSE; icsheader->valid_order = FALSE; icsheader->valid_sizes = FALSE; icsheader->valid_sigbits = FALSE; icsheader->valid_origin = FALSE; icsheader->valid_scale = FALSE; icsheader->valid_label = FALSE; icsheader->valid_units = FALSE; icsheader->valid_coord = FALSE; icsheader->valid_format = FALSE; icsheader->valid_sign = FALSE; icsheader->valid_compression = FALSE; icsheader->valid_byteorder = FALSE; icsheader->valid_SCIL_TYPE = FALSE; bp = buffer1; end = bp + length; /* EOF */ *buffer2 = '\0'; /* initially empty */ delim1 = *bp++; /* field delimiter */ delim2 = *bp++; /* record delimiter */ t = temp1; /* check if written by ICS */ while (*bp != delim2) *t++ = *bp++; bp++; *t = '\0'; if (strncmp(temp1,"ICS",3) && strncmp(temp1,"ics",3)) { free(buffer1); free(buffer2); return(-4); } /* get the filename from the ICS file */ t = temp1; while (*bp != delim2) *t++ = *bp++; bp++; *t = '\0'; t = strchr(temp1,delim1); strcpy(icsheader->filename,t); *t = '\0'; if (strcmp(temp1,"filename")) { free(buffer1); free(buffer2); return(-5); } icsheader->valid_filename = TRUE; /* check the following records one by one and try to resolve the information per record */ while (bp < end) /* until EOF */ { /* get the next record into temp1 */ t = temp1; while (*bp != delim2 && bp < end) /* dont read beyond EOF */ *t++ = *bp++; bp++; *t = '\0'; /* get the category into temp2 */ t = temp1; tg = temp2; while (*t != delim1) *tg++ = *t++; t++; *tg = '\0'; /* check if it is one of the decodable categories */ cat = 0; if (!strcmp(temp2,"layout")) cat = 1; if (!strcmp(temp2,"representation")) cat = 2; if (!strcmp(temp2,"parameter")) cat = 3; if (cat == 0) { /* if not concatenate record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); continue; } /* get the next field from this record */ tg = temp2; while (*t != delim1) *tg++ = *t++; t++; *tg = '\0'; /* find this item in the keyword table */ for (i = 0; i < kwrds; i++) if (!strcmp(temp2,keywrdtable[i])) break; if (i == kwrds) { /* not found in the keyword table */ /* concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); continue; } /* switch to the right value handling routine */ switch (i) { case 0: /* parameters */ if (cat != 1) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } tg = temp2; while (*t != '\0') *tg++ = *t++; *tg = '\0'; t++; icsheader->parameters = atoi(temp2); if (icsheader->parameters > MAXDIM) { /* if necessary change MAXDIM in ics.h */ free(buffer1); free(buffer2); return(-6); } icsheader->valid_parameters = TRUE; break; case 1: /* order */ if (cat != 1) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } if (icsheader->parameters == 0) { /* need to know the number of parameters first */ free(buffer1); free(buffer2); return(-5); } for (i = 0; i < icsheader->parameters; i++) { tg = temp2; while (*t != delim1 && *t != '\0') *tg++ = *t++; *tg = '\0'; t++; strcpy(icsheader->order[i],temp2); } icsheader->valid_order = TRUE; break; case 2: /* sizes */ if (cat != 1) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } if (icsheader->parameters == 0) { /* need to know the number of parameters first */ free(buffer1); free(buffer2); return(-5); } for (i = 0; i < icsheader->parameters; i++) { tg = temp2; while (*t != delim1 && *t != '\0') *tg++ = *t++; *tg = '\0'; t++; icsheader->sizes[i] = atoi(temp2); } icsheader->valid_sizes = TRUE; break; case 3: /* coord */ if (cat != 1) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } tg = temp2; while (*t != '\0') *tg++ = *t++; *tg = '\0'; t++; strcpy(icsheader->coord,temp2); icsheader->valid_coord = TRUE; break; case 4: /* significant bits */ if (cat != 1) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } tg = temp2; while (*t != '\0') *tg++ = *t++; *tg = '\0'; t++; icsheader->sigbits = atoi(temp2); icsheader->valid_sigbits = TRUE; break; case 5: /* format */ if (cat != 2) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } tg = temp2; while (*t != '\0') *tg++ = *t++; *tg = '\0'; t++; strcpy(icsheader->format,temp2); icsheader->valid_format = TRUE; break; case 6: /* signed or unsigned */ if (cat != 2) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } tg = temp2; while (*t != '\0') *tg++ = *t++; *tg = '\0'; t++; if (!strcmp(temp2,"unsigned")) icsheader->sign = UNSIGNED; else icsheader->sign = SIGNED; icsheader->valid_sign = TRUE; break; case 7: /* packing */ if (cat != 2) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } tg = temp2; while (*t != '\0') *tg++ = *t++; *tg = '\0'; t++; strcpy(icsheader->compression,temp2); icsheader->valid_compression = TRUE; break; case 8: /* origin */ if (cat != 3) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } if (icsheader->parameters == 0) { /* need to know the number of parameters first */ free(buffer1); free(buffer2); return(-5); } for (i = 0; i < icsheader->parameters; i++) { tg = temp2; while (*t != delim1 && *t != '\0') *tg++ = *t++; *tg = '\0'; t++; icsheader->origin[i] = (float)atof(temp2); } icsheader->valid_origin = TRUE; break; case 9: /* scale */ if (cat != 3) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } if (icsheader->parameters == 0) { /* need to know the number of parameters first */ free(buffer1); free(buffer2); return(-5); } for (i = 0; i < icsheader->parameters; i++) { tg = temp2; while (*t != delim1 && *t != '\0') *tg++ = *t++; *tg = '\0'; t++; icsheader->scale[i] = (float)atof(temp2); } icsheader->valid_scale = TRUE; break; case 10: /* labels */ if (cat != 3) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } if (icsheader->parameters == 0) { /* need to know the number of parameters first */ free(buffer1); free(buffer2); return(-5); } for (i = 0; i < icsheader->parameters; i++) { tg = temp2; while (*t != delim1 && *t != '\0') *tg++ = *t++; *tg = '\0'; t++; strcpy(icsheader->label[i],temp2); } icsheader->valid_label = TRUE; break; case 11: /* units */ if (cat != 3) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } if (icsheader->parameters == 0) { /* need to know the number of parameters first */ free(buffer1); free(buffer2); return(-5); } for (i = 0; i < icsheader->parameters; i++) { tg = temp2; while (*t != delim1 && *t != '\0') *tg++ = *t++; *tg = '\0'; t++; strcpy(icsheader->units[i],temp2); } icsheader->valid_units = TRUE; break; case 12: /* byteorder */ if (cat != 2) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } if (icsheader->sizes[0] == 0) { /* need to know the number of bits first */ free(buffer1); free(buffer2); return(-5); } length = icsheader->sizes[0] / 8; for (ui = 0; ui < length; ui++) { tg = temp2; while (*t != delim1 && *t != '\0') *tg++ = *t++; *tg = '\0'; t++; icsheader->byteorder[ui] = atoi(temp2); } icsheader->valid_byteorder = TRUE; break; case 13: /* SCIL_TYPE */ if (cat != 2) { /* wrong category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } tg = temp2; while (*t != '\0') *tg++ = *t++; *tg = '\0'; t++; strcpy(icsheader->SCIL_TYPE,temp2); icsheader->valid_SCIL_TYPE = TRUE; break; default: /* unknown category concatenate this record to buffer2 */ strcat(buffer2,temp1); strcat(buffer2,"\n"); break; } } /* clean up and return */ free(buffer1); free(buffer2); return(0); } /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ static int read_ids_char(char *filename, unsigned char *dest, int length) { int fd, tot, num; char *dp; char temp1[100]; /* make the proper filename and open the IDS file */ strcpy(temp1,filename); strcat(temp1,".ids"); if ((fd = open(temp1,O_RDONLY)) < 0) return(-2); /* get the length of the IDS file and rewind */ tot = lseek(fd,0L,2); lseek(fd,0L,0); /* check if lengths are the same */ if (tot > length) tot = length; dp = (char *)dest; /* read the data into destination */ while ((num = read(fd,dp,512)) > 0) { dp += num; tot -= num; if (tot < 512) break; } if ((num = read(fd,dp,tot)) != tot) { close(fd); return(-3); } close(fd); return(0); } /*---------------------------------------------------------------------------*/ static int read_ids_short(char *filename, short *dest, int length, int need_to_swap) { int i, fd, tot, num; short int *temp, *t; char temp1[100]; /* make the proper filename and open the IDS file */ strcpy(temp1,filename); strcat(temp1,".ids"); if ((fd = open(temp1,O_RDONLY)) < 0) return(-2); /* get the length of the IDS file and rewind */ tot = lseek(fd,0L,2); lseek(fd,0L,0); /* check if lengths are the same */ if (tot > length) tot = length*sizeof(short int); temp = (short int *) calloc(sizeof(short int),512); /* read the data into destination */ while ((num = read(fd,temp,512*sizeof(short int))) > 0) { if (need_to_swap) swap_short((char*)temp,(char*)temp,num); t = temp; tot -= num; for (i=0; i<(int)(num/sizeof(short int)); i++) *dest++ = (short)(*t++); if (tot < (int)(512*sizeof(short int))) break; } if ((num = read(fd,temp,tot)) == tot) { if (need_to_swap) swap_short((char*)temp,(char*)temp,num); t = temp; for (i=0; i<(int)(num/sizeof(short int)); i++) *dest++ = (short)(*t++); } else { free(temp); close(fd); return(-3); } free(temp); close(fd); return(0); } /*---------------------------------------------------------------------------*/ static int read_ids_double(char *filename, double *dest, int length, int need_to_swap) { int i, fd, tot, num; float *temp, *t; char temp1[100]; /* make the proper filename and open the IDS file */ strcpy(temp1,filename); strcat(temp1,".ids"); if ((fd = open(temp1,O_RDONLY)) < 0) return(-2); /* get the length of the IDS file and rewind */ tot = lseek(fd,0L,2); lseek(fd,0L,0); /* check if lengths are the same */ if (tot > length) tot = length*sizeof(float); temp = (float *) calloc(sizeof(float),512); /* read the data into destination */ while ((num = read(fd,temp,512*sizeof(float))) > 0) { if (need_to_swap) swap_float((char*)temp,(char*)temp,num); t = temp; tot -= num; for (i=0; i<(int)(num/sizeof(float)); i++) *dest++ = (double)(*t++); if (tot < (int)(512*sizeof(float))) break; } if ((num = read(fd,temp,tot)) == tot) { if (need_to_swap) swap_float((char*)temp,(char*)temp,num); t = temp; for (i=0; i<(int)(num/sizeof(float)); i++) *dest++ = (double)(*t++); } else { free(temp); close(fd); return(-3); } free(temp); close(fd); return(0); } /*---------------------------------------------------------------------------*/ /* front-end code for the LIAR, Hugues Talbot 18 Dec 1997 */ int load_ics(const char *fname, void **imdata, pixtype *datatype, int *nx, int *ny, int *nz) { int res = 0, size, need_to_swap=-1; /*char text[81];*/ static char tmpfname[1024]; static char tmp1[1024]; char *tp; int err; ICS icsheader; dbgprintf("Loading %s as an ICS image", fname); /* Check if IDS data file exists */ strcpy(tmpfname, fname); if (((tp = strrchr(tmpfname, '.')) != 0) && ((strncmp(tp, ".ics", 4) == 0) || (strncmp(tp, ".ids", 4) == 0))) { // remove this extension, which we shall add later! tp[0] = '\0'; } /* make the proper filename and open (& close) the IDS file */ strcpy(tmp1, tmpfname); strcat(tmp1,".ids"); if ( (access(tmp1,R_OK)) != 0) { /* we can't read the data ! */ errprintf("IDS file \"%s.ids\" is unreadable:\n%s.",tmpfname, strerror(errno)); return (20); } /* read ICS header file */ err = (int) read_ics_header(tmpfname,&icsheader); if (err == -2){ errprintf("ICS file \"%s.ics\" does not exist.",tmpfname); return (21); } else if (err!=0){ errprintf("Error %d in reading %s.ics",err,tmpfname); return (22); } /* Test if header values are valid - at present can only read ^^^^^^^^^ <- you can tell this is Leanne writing here... 8bit unsigned & 16bit signed integers, & 32bit float files */ if (!((icsheader.valid_parameters) && (icsheader.valid_sizes) && (icsheader.valid_format) && (icsheader.valid_sign))) { errprintf("ICS header file contains invalid parameters."); return 23; } if (icsheader.parameters == 3) { *nx = icsheader.sizes[1]; *ny = icsheader.sizes[2]; *nz = 1; } else if (icsheader.parameters == 4) { *nx = icsheader.sizes[1]; *ny = icsheader.sizes[2]; *nz = icsheader.sizes[3]; } else { errprintf("ICS header file indicates data file is not a 2D or 3D image."); return 24; } if ((icsheader.sizes[0]==8) && (!strcmp(icsheader.format,"integer")) && (icsheader.sign==UNSIGNED)) *datatype = IM_UINT1; else if((icsheader.sizes[0]==16)&&(!strcmp(icsheader.format,"integer")) && (icsheader.sign==SIGNED)) *datatype = IM_INT2; else if((icsheader.sizes[0]==32) && (!strcmp(icsheader.format,"real")) && (icsheader.sign==SIGNED)) *datatype = IM_DOUBLE; else { errprintf("Data type must be 8bit unsigned int, 16bit signed int or 32bit float."); return 25; } if ((*datatype == IM_INT2) || (*datatype == IM_DOUBLE)) { need_to_swap = FALSE; /* work out if we need to swap the data */ if (check_endian() == IS_LITTLEENDIAN) { /* machine is a DEC or a PC, say */ if (icsheader.byteorder[0] != 1) { need_to_swap = TRUE; dbgprintf("Need to swap data endianness"); } } else { /* machine is a Sun or an SGI, say */ if (icsheader.byteorder[0] == 1) { need_to_swap = TRUE; dbgprintf("Need to swap data endianness"); } } } size = (*nx) * (*ny) * (*nz); switch(*datatype) { case IM_UINT1: size *= sizeof(char); (*imdata) = (char *)malloc(size * sizeof(char)); read_ids_char(tmpfname,(unsigned char *)*imdata,size); break; case IM_INT2: size *= sizeof(short); (*imdata) = (short *)malloc(size * sizeof(short)); read_ids_short(tmpfname,(short *)(*imdata),size,need_to_swap); break; case IM_DOUBLE: size *= sizeof(double); (*imdata) = (double *)malloc(size * sizeof(double)); read_ids_double(tmpfname,(double *)(*imdata),size,need_to_swap); break; default: errprintf("ICS reader: pixel type %d not handled yet\n", *datatype); return 30; } return res; } ������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readics.hxx������������������������������������������������������������������������0000644�0000765�0000765�00000004114�07653237123�016555� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readics.hxx,v 4.0 2003/04/28 14:44:35 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * * readICS.H * * Decodes the ICS format (SCILimage) * *-----------------------------------------------------------------------*/ #ifndef READICS_H #define READICS_H #define IS_BIGENDIAN 1 #define IS_LITTLEENDIAN 2 int readICSImage(const char *name); int load_ics(const char *fname, void **imdata, pixtype *datatype, int *nx, int *ny, int *nz); int icsnbsubfiles(const char *name); #endif ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readjpeg.cxx�����������������������������������������������������������������������0000644�0000765�0000765�00000013603�10054565124�016714� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readjpeg.cxx,v 4.1 2004/05/25 06:40:20 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Read the JPEG format * Thanks to the excellent jpeg library, this is the * easiest formats of all. * * Hugues Talbot 22 Jan 1998 * Modification : Hugues Talbot 29 Apr 1998 * Well: except for the error handling code... * *-----------------------------------------------------------------------*/ #include "imview.hxx" #ifdef HAVE_JPEG // if the JPEG library is available #include <stdio.h> #include <setjmp.h> #include "imSystem.hxx" #include "../imageIO.hxx" #include "readjpeg.hxx" // Read using jpeg library: extern "C" { #include "jpeglib.h" } extern imageIO *IOBlackBox; static uchar *loadJpegImage(FILE *infile, int *w, int *h, int *d); int readJpegImage(const char *name) /* file name */ { FILE *fp; uchar *outbuf; int w, h, d; fp = im_fopen(name, "rb"); if (!fp) { errprintf("readJpegImage: can't open file %s\n", name); return 0; } outbuf = loadJpegImage(fp, &w, &h, &d); if (outbuf != 0) { IOBlackBox->setImData(outbuf); IOBlackBox->setCurrImgWidth(w); IOBlackBox->setCurrImgHeight(h); IOBlackBox->setCurrImgThickness(1); IOBlackBox->setXOffset(0); IOBlackBox->setYOffset(0); IOBlackBox->setZOffset(0); IOBlackBox->setCurrImgNbComps(1); // only a single image in a JPEG file IOBlackBox->setCurrImgNbSamples(d); IOBlackBox->setCurrImgSpp(d); // needed here because no currBuffp IOBlackBox->setCurrPixType(IM_UINT1); IOBlackBox->setCurrImgType((d == 3) ? IM_RGB : IM_SPECTRUM); IOBlackBox->setImgDesc("JPEG"); } fclose(fp); return (outbuf == 0); } // returns the number of frames present in // a JPEG file int jpegnbsubfiles(const char *) { return 1; // not too strenuous an effort here... } struct my_error_mgr { struct jpeg_error_mgr pub; /* "public" fields */ jmp_buf setjmp_buffer; /* for return to caller */ }; typedef struct my_error_mgr * my_error_ptr; METHODDEF(void) my_output_message (j_common_ptr cinfo) { char buffer[JMSG_LENGTH_MAX]; /* Create the message */ (*cinfo->err->format_message) (cinfo, buffer); /* Send it to stderr, adding a newline */ errprintf("%s\n", buffer); } /* * Here's the routine that will replace the standard error_exit method: */ METHODDEF(void) my_error_return (j_common_ptr cinfo) { /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ my_error_ptr myerr = (my_error_ptr) cinfo->err; /* Always display the message. */ /* We could postpone this until after returning, if we chose. */ my_output_message(cinfo); /* Return control to the setjmp point */ longjmp(myerr->setjmp_buffer, 1); } static uchar *loadJpegImage(FILE *infile, /* file name */ int *w, /* x dimension */ int *h, /* y dimension */ int *d /* depth of the image */ ) { /** read a JPEG image file RETURN VALUE: unsigned char * DESCRIPTION: This function read a JPEG image HISTORY: quickly adapted from demo code in FL library Hugues Talbot 28 Oct 1997 TESTS: REFERENCES: KEYWORDS: **/ struct jpeg_decompress_struct cinfo; struct my_error_mgr jerr; unsigned char *ibuffer, *rp; /* We set up the normal JPEG error routines, then override error_exit. */ cinfo.err = jpeg_std_error(&jerr.pub); jerr.pub.error_exit = my_error_return; /* Establish the setjmp return context for my_error_exit to use. */ if (setjmp(jerr.setjmp_buffer)) { /* If we get here, the JPEG code has signaled an error. * We need to clean up the JPEG object, close the input file, and return. */ jpeg_destroy_decompress(&cinfo); return 0; } jpeg_create_decompress(&cinfo); jpeg_stdio_src(&cinfo, infile); jpeg_read_header(&cinfo, TRUE); jpeg_start_decompress(&cinfo); *w = cinfo.output_width; *h = cinfo.output_height; *d = cinfo.output_components; ibuffer = new unsigned char[(*w)*(*h)*(*d)]; rp = ibuffer; while (rp < ibuffer + (*w)*(*h)*(*d)) { jpeg_read_scanlines(&cinfo, &rp, 1); rp += (*w)*(*d); } jpeg_finish_decompress(&cinfo); jpeg_destroy_decompress(&cinfo); return ibuffer; } #else // HAVE_JPEG // stubs int readJpegImage(const char *name) { errprintf("This version of imview cannot read JPEG images\n"); return 1; } int jpegnbsubfiles(const char *name) { return 0; } #endif �����������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readjpeg.hxx�����������������������������������������������������������������������0000644�0000765�0000765�00000003766�07653237124�016741� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readjpeg.hxx,v 4.0 2003/04/28 14:44:36 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Read the JPEG format * Easy format thanks to the jpeg library * * Hugues Talbot 22 Jan 1998 * *-----------------------------------------------------------------------*/ #ifndef READJPEG_H #define READJPEG_H int readJpegImage(const char *name); int jpegnbsubfiles(const char *name); #endif // READJPEG_H ����������imview-1.1.9c/io/readMagick.cxx���������������������������������������������������������������������0000644�0000765�0000765�00000022064�10754360060�017162� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readMagick.cxx,v 4.3 2008/02/12 18:06:40 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Interface to the Image Magick Library. * * This library reads squillions of formats. Too good to be true. * Hugues Talbot 22 Jul 2000 * * Yeah, too good to be true: the API keeps changing from under me, it's * a real nightmare! 14 May 2002 * *-----------------------------------------------------------------------*/ #include "imview.hxx" #ifdef HAVE_MAGICK #include <stdio.h> #include <setjmp.h> #include <time.h> #include <errno.h> #include <sys/types.h> #include <cstring> #include "../imageIO.hxx" extern imageIO *IOBlackBox; // typical simple C solution #include <magick/api.h> static ImageInfo *image_info = 0; static Image *magickImage = 0; static char currentName[1024]; jmp_buf magick_jmp; static void MagickWarningHandler(const ExceptionType warning, const char *message,const char *qualifier); static void MagickErrorHandler(const ExceptionType error, const char *message, const char *qualifier); #ifdef MAGICK_NEEDS_MORE_EXCEPTION # define myIsGrayImage IsGrayImage # define myDispatchImage DispatchImage #else /* extra exception argument not expected */ # define myIsGrayImage(X,Y) IsGrayImage(X) # define myDispatchImage(A,B,C,D,E,F,G,H,I) DispatchImage(A,B,C,D,E,F,G,H) #endif void initImageMagick(char *path) { dbgprintf("Image Magick Library initialized\n"); #ifdef MAGICK_USES_INIT // #$#@%! InitializeMagick(path); #else MagickIncarnate(path); #endif SetErrorHandler(MagickErrorHandler); SetWarningHandler(MagickWarningHandler); } // returns the number of frames present // in a Magick File int magicknbsubfiles(const char *) { int nbframes; Image *p; // there is no other way than reading all the frames here for (p=magickImage, nbframes = 0; p != (Image *) NULL; p=p->next) { nbframes++; } return nbframes; // not too strenuous an effort here... } // this function tests if an image can be read with the ImageMagick library // the idea is to call ReadImage only once. It's slow enough as it is... bool testMagickImage(const char *name) { ExceptionInfo exception; dbgprintf("Test Magick called. Can ImageMagick read this image?\a"); GetExceptionInfo(&exception); if (image_info == 0) image_info=CloneImageInfo((ImageInfo *) NULL); strcpy(image_info->filename, name); magickImage=ReadImage(image_info,&exception); // so far so good if (magickImage == 0) { #ifdef MAGICK_USES_REASON // I hate gratuitous API changes // for ImageMagick 5.2.7-2 (on RH7.1) MagickWarning(exception.severity,exception.reason,exception.description); #else // for other ImageMagick versions < 5.2.7-2 MagickWarning(exception.severity,exception.message,exception.qualifier); #endif DestroyImageInfo(image_info); // not needed anymore image_info = 0; dbgprintf("... No\b"); return false; // can not read } else { strncpy(currentName, name, 1024); dbgprintf("... Yes!\b"); return true; // can read } } int readMagickImage(const char *name, int frame) { ExceptionInfo exception; Image *p; int retval = 0; uchar *outbuf; int w, h, d, frameId; static char desc[100]; dbgprintf("ReadMagickImage called\n"); if (setjmp(magick_jmp)) { // if we get here, ImageMagick has detected an error. Bail out if (magickImage) { DestroyImage(magickImage); magickImage = 0; } if (image_info) { DestroyImageInfo(image_info); image_info = 0; } return 100; } // initializes the exception information GetExceptionInfo(&exception); if ((magickImage == 0) || (strncmp(currentName, name, 1024) != 0)) { // we need to read the image again if (image_info == 0) image_info=CloneImageInfo((ImageInfo *) NULL); strcpy(image_info->filename, name); magickImage=ReadImage(image_info,&exception); // so far so good } if (magickImage != 0) { for (p=magickImage, frameId = 0; (p != (Image *) NULL) && (frameId != frame) ; p=p->next) { frameId++; } w = p->columns; h = p->rows; if (myIsGrayImage(p,&exception)) { d = 1; outbuf = (uchar *) malloc(w*h*d*sizeof(uchar)); myDispatchImage(p, 0, 0, w, h, "R", CharPixel, outbuf,&exception); } else { d = 3; outbuf = (uchar *) malloc(w*h*d*sizeof(uchar)); myDispatchImage(p, 0, 0, w, h, "RGB", CharPixel, outbuf, &exception); } // talk to the black box IOBlackBox->setImData(outbuf); IOBlackBox->setCurrImgWidth(w); IOBlackBox->setCurrImgHeight(h); IOBlackBox->setCurrImgThickness(1); IOBlackBox->setXOffset(0); IOBlackBox->setYOffset(0); IOBlackBox->setZOffset(0); IOBlackBox->setCurrImgNbComps(1); // only a single image in a Magick file IOBlackBox->setCurrImgNbSamples(d); IOBlackBox->setCurrImgSpp(d); // needed here because no currBuffp IOBlackBox->setCurrPixType(IM_UINT1); IOBlackBox->setCurrImgType((d == 1) ? IM_SINGLE : ((d == 3) ? IM_RGB : IM_SPECTRUM)); strncpy(desc, magickImage->magick, 100); IOBlackBox->setImgDesc(desc); DestroyImage(magickImage); currentName[0] = '\0'; magickImage = 0; // so we know it has not been read yet. } else { #ifdef MAGICK_USES_REASON // God I hate gratuitous API changes // for ImageMagick 5.2.7-2 (on RH7.1) MagickError(exception.severity,exception.reason,exception.description); #else // for other ImageMagick versions < 5.2.7-2 MagickError(exception.severity,exception.message,exception.qualifier); #endif } DestroyImageInfo(image_info); image_info = 0; return retval; } // Runs wa static void MagickErrorHandler(const ExceptionType error, const char *message, const char *qualifier) { char errMsg[1024], tmpMsg[1024]; int msglen; // No longer needed ? DestroyDelegateInfo(); if (message == (char *) NULL) { errprintf("ImageMagick reports NULL error message...\n"); longjmp(magick_jmp, 1); } (void) snprintf(errMsg, 1024,"%.256s: %s\n",SetClientName((char *) NULL), message); msglen = strlen(errMsg); if (qualifier != (char *) NULL) { snprintf(tmpMsg, 1024-msglen, "(%s)\n", qualifier); strcat(errMsg, tmpMsg); msglen = strlen(errMsg); } if ((error != OptionError) && errno) { snprintf(tmpMsg, 1024-msglen, "[%.1024s]",strerror(errno)); strcat(errMsg, tmpMsg); } errprintf(errMsg); longjmp(magick_jmp,1); } static void MagickWarningHandler(const ExceptionType warning, const char *message,const char *qualifier) { char errMsg[1024], tmpMsg[1024]; int msglen; if (message == (char *) NULL) return; snprintf(errMsg, 1024, "%.256s: %s\n",SetClientName((char *) NULL), message); msglen = strlen(errMsg); if (qualifier != (char *) NULL) { snprintf(tmpMsg, 1024-msglen, "(%s)\n",qualifier); strcat(errMsg, tmpMsg); msglen = strlen(errMsg); } if ((warning != OptionWarning) && errno) { snprintf(tmpMsg, 1024-msglen, "[%.1024s]",strerror(errno)); strcat(errMsg, tmpMsg); } warnprintf(errMsg); return; } #else // HAVE_MAGICK void initImageMagick(char *) { // nothing to do } bool testMagickImage(const char *) { return false; // we can do nothing } int readMagickImage(const char *, int) { errprintf("This application was not linked with the ImageMagick Library\n"); return 1; } int magicknbsubfiles(const char *) { return 0; } #endif // HAVE_MAGICK ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readMagick.hxx���������������������������������������������������������������������0000644�0000765�0000765�00000003753�07653237122�017201� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readMagick.hxx,v 4.0 2003/04/28 14:44:34 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Interfact to Image Magick * Hugues Talbot 22 Jul 2000 * * *-----------------------------------------------------------------------*/ void initImageMagick(char *path); bool testMagickImage(const char *name); int readMagickImage(const char *name, int frame); int magicknbsubfiles(const char *); ���������������������imview-1.1.9c/io/readmat5.cxx�����������������������������������������������������������������������0000644�0000765�0000765�00000026451�10115104071�016626� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Read data from Matlab level 5 MAT-files * * Teemu Ikonen 16 Aug 2004 * * *-----------------------------------------------------------------------*/ #include <fstream> #include "imnmspc.hxx" // name space definition if needed #include "imunistd.h" #include "imview.hxx" #include "imageIO.hxx" #include "machine.hxx" // portability stuff #include "readmat5.hxx" #include "byte-swap.h" #define PAD(l) (((l)<=4)?4:(((l)+7)/8)*8) #define TAGLENGTH(l) ((l)<=4?4:8) #define X_CAST(T, E) (T) (E) extern imageIO *IOBlackBox; typedef uchar uint8; typedef char int8; typedef ushort uint16; typedef short int16; typedef uint uint32; typedef int int32; //typedef unsigned long uint64; //typedef long int64; typedef float single; // typedef double double; enum mat5_data_type { miINT8 = 1, // 8 bit signed miUINT8, // 8 bit unsigned miINT16, // 16 bit signed miUINT16, // 16 bit unsigned miINT32, // 32 bit signed miUINT32, // 32 bit unsigned miSINGLE, // IEEE 754 single precision float miRESERVE1, miDOUBLE, // IEEE 754 double precision float miRESERVE2, miRESERVE3, miINT64, // 64 bit signed miUINT64, // 64 bit unsigned miMATRIX // MATLAB array }; enum arrayclasstype { mxCELL_CLASS=1, // cell array mxSTRUCT_CLASS, // structure mxOBJECT_CLASS, // object mxCHAR_CLASS, // character array mxSPARSE_CLASS, // sparse array mxDOUBLE_CLASS, // double precision array mxSINGLE_CLASS, // single precision floating point mxINT8_CLASS, // 8 bit signed integer mxUINT8_CLASS, // 8 bit unsigned integer mxINT16_CLASS, // 16 bit signed integer mxUINT16_CLASS, // 16 bit unsigned integer mxINT32_CLASS, // 32 bit signed integer mxUINT32_CLASS // 32 bit unsigned integer }; int read_mat5_binary_file_header (std::istream& is, bool& swap); static int read_mat5_tag (std::istream& is, bool swap, int& type, int& bytes); int read_mat5_binary_data (std::istream& is, void **&buf, int len, int matcount, bool swap, mat5_data_type type, pixtype &imtype); void read_int32 (std::istream& is, bool swap_bytes, int32& val); int mat5nbsubfiles(const char *ident) { return 1; // we may start to support more frames in the future } int readMat5(const char *ident, int index) { void **buf; bool swap; int res; int type, bytes, len; dbgprintf("Read Mat5 called\n"); std::ifstream is(ident); if(!is) { errprintf("readmat5: Cannot open file %s\n", ident); return 10; } res = read_mat5_binary_file_header (is, swap); if(res) return res; dbgprintf("readmat5: byte-swap is %s.\n", swap ? "on" : "off"); read_mat5_tag (is, swap, type, bytes); if(type != miMATRIX) { errprintf("Only matrix type MAT5-datafiles supported.\n"); return 100; } // array flags subelement if (read_mat5_tag (is, swap, type, len) || type != miUINT32 || len != 8) { errprintf ("readmat5: invalid array flags subelement\n"); return 100; } int32 flags; read_int32(is, swap, flags); bool imag = (flags & 0x0800) != 0; // has an imaginary part? if(imag) { errprintf ("readmat5: complex arrays not supported\n"); return 100; } // bool global = (flags & 0x0400) != 0; // global variable? // bool logicalvar = (flags & 0x0200) != 0; enum arrayclasstype arrayclass = (arrayclasstype)(flags & 0xff); int32 junk; read_int32 (is, swap, junk); // an "undefined" entry // dimensions array subelement int32 dim_len; if (read_mat5_tag (is, swap, type, dim_len) || type != miINT32) { errprintf ("readmat5: invalid dimensions array subelement"); return 100; } int ndims = dim_len / 4; if(ndims != 2) { errprintf ("readmat5: only two-dimensional arrays supported"); return 100; } int32 xsize; read_int32 (is, swap, xsize); int32 ysize; read_int32 (is, swap, ysize); dbgprintf("readmat5: matrix has size %d x %d\n", xsize, ysize); std::streampos tmp_pos = is.tellg (); is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (dim_len) - dim_len)); if (read_mat5_tag (is, swap, type, len) || type != miINT8) { errprintf ("readmat5: invalid array name subelement\n"); return 100; } tmp_pos = is.tellg (); char name[len+1]; if (len) { if (! is.read (name, len )) return 100; is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len))); } pixtype imtype = IM_INVALID; switch (arrayclass) { case mxDOUBLE_CLASS: case mxSINGLE_CLASS: case mxINT8_CLASS: case mxUINT8_CLASS: case mxINT16_CLASS: case mxUINT16_CLASS: case mxINT32_CLASS: case mxUINT32_CLASS: // read real data subelement if (read_mat5_tag (is, swap, type, len)) { errprintf ("readmat5: error reading matrix data.\n"); return 100; } dbgprintf("readmat5: data has length %d\n", len); tmp_pos = is.tellg (); res = read_mat5_binary_data(is, buf, len, xsize*ysize, swap, (mat5_data_type) type, imtype); if(res) return res; is.seekg (tmp_pos + static_cast<std::streamoff> (PAD (len))); break; default: errprintf ("readmat5: unsupported array class.\n"); return 100; } if (res == 0) { IOBlackBox->setCurrBuffp(buf); IOBlackBox->setCurrImgWidth(xsize); IOBlackBox->setCurrImgHeight(ysize); IOBlackBox->setCurrImgThickness(1); IOBlackBox->setXOffset(0); IOBlackBox->setYOffset(0); IOBlackBox->setZOffset(0); IOBlackBox->setCurrZPos(0); // first plane IOBlackBox->setCurrImgType(IM_SINGLE); IOBlackBox->setCurrPixType(imtype); IOBlackBox->setCurrImgNbComps(1); IOBlackBox->setCurrImgNbSamples(1); IOBlackBox->setImgDesc("MAT5"); } return res; } // Code below is adapted from GNU Octave (www.octave.org) int read_mat5_binary_file_header (std::istream& is, bool& swap) { uint16 version=0, magic=0; is.seekg (124, std::ios::beg); is.read ((char *) &version, 2); is.read ((char *) &magic, 2); if (magic == 0x4d49) swap = 0; else if (magic == 0x494d) swap = 1; else { errprintf ("readmat5: can't read binary file"); return 10; } if (! swap) // version number is inverse swapped! version = ((version >> 8) & 0xff) + ((version & 0xff) << 8); if (version != 1) dbgprintf ("readmat5: found version %d binary MAT file, but only prepared for version 1"); return 0; } // Read one element tag from stream IS, // place the type code in TYPE and the byte count in BYTES // return nonzero on error static int read_mat5_tag (std::istream& is, bool swap, int& type, int& bytes) { unsigned int upper; int32 temp; if (! is.read ((char *) &temp, 4 )) goto data_read_error; if (swap) swap_4_bytes ((char *)&temp); upper = (temp >> 16) & 0xffff; type = temp & 0xffff; if (upper) { // "compressed" format bytes = upper; } else { if (! is.read (X_CAST (char *, &temp), 4 )) goto data_read_error; if (swap) swap_4_bytes ((char *)&temp); bytes = temp; } return 0; data_read_error: return 1; } #define swap_1_bytes(x, y) #define LS_DO_READ(swap, data, size, len, stream) \ do \ { \ if (len > 0) \ { \ stream.read (X_CAST (char *, data), size * len); \ if (swap) \ swap_ ## size ## _bytes (data, len); \ } \ } \ while (0) // Return the data read from a mat5 array in buf[0] and the type of // a pixel in imtype. If the expected array size given in matcount // does not match the binary array length, return a non-zero errorcode. int read_mat5_binary_data (std::istream& is, void **&buf, int len, int matcount, bool swap, mat5_data_type type, pixtype &imtype) { buf = (void **)calloc(1, sizeof(void *)); if(buf == NULL) { errprintf("readmat5: Out of memory\n"); return 20; } void *data = malloc(len); if(data == NULL) { errprintf("readmat5: Out of memory\n"); free(buf); return 20; } int count; switch (type) { case miINT8: count = len / 1; LS_DO_READ (swap, ((int8 *) data), 1, count, is); imtype = IM_INT1; break; case miUINT8: count = len / 1; LS_DO_READ (swap, ((uint8 *)data), 1, count, is); imtype = IM_UINT1; break; case miINT16: count = len / 2; LS_DO_READ (swap, ((int16 *)data), 2, count, is); imtype = IM_INT2; break; case miUINT16: count = len / 2; LS_DO_READ (swap, ((uint16 *)data), 2, count, is); imtype = IM_UINT2; break; case miINT32: count = len / 4; LS_DO_READ (swap, ((int32 *)data), 4, count, is); imtype = IM_INT4; break; case miUINT32: count = len / 4; LS_DO_READ (swap, ((uint32 *)data), 4, count, is); imtype = IM_UINT4; break; case miSINGLE: count = len / 4; is.read (X_CAST (char *, data), 4 * count); if(swap) swap_4_bytes(data, count); imtype = IM_FLOAT; break; case miDOUBLE: count = len / 8; is.read (X_CAST (char *, data), 8 * count); if(swap) swap_8_bytes(data, count); imtype = IM_DOUBLE; break; case miRESERVE1: case miRESERVE2: case miRESERVE3: case miINT64: case miUINT64: case miMATRIX: default: free(buf); free(data); return 100; break; } if(count != matcount) { errprintf("readmat5: array sizes do not match.\n"); free(buf); free(data); return 100; } *buf = data; return 0; } void read_int32 (std::istream& is, bool swap_bytes, int32& val) { is.read (X_CAST (char *, &val), sizeof (int32)); if (swap_bytes) { swap_4_bytes ((char *) &val); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readmat5.hxx�����������������������������������������������������������������������0000644�0000765�0000765�00000003666�10115104071�016636� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Read data from Matlab level 5 MAT-files * * Teemu Ikonen 16 Aug 2004 * *-----------------------------------------------------------------------*/ // prototypes #ifndef READMAT5_H #define READMAT5_H int mat5nbsubfiles(const char *ident); int readMat5(const char *ident, int index); #endif // READMAT5 ��������������������������������������������������������������������������imview-1.1.9c/io/readmeta.cxx�����������������������������������������������������������������������0000644�0000765�0000765�00000017746�10736150570�016733� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readmeta.cxx,v 1.1 2007/12/31 11:24:40 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /* * readmeta () - reads in ITK Meta Images * * Hugues Talbot 12 Dec 2007 */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include <errno.h> #include <math.h> #include <sys/types.h> #include <sys/stat.h> #include <string> // STL #include <iostream> #include <fstream> #include <sstream> #include <fcntl.h> #include "imunistd.h" #include "imview.hxx" #include "nocase.hxx" #include "imageIO.hxx" #include "imtranslate.hxx" #include "readraw.hxx" #include "readmeta.hxx" #define TRUE 1 #define FALSE 0 extern imageIO *IOBlackBox; /*--declarations of locally defined functions--*/ int readMETAImage(const char *name, int index) { void **buf; RAWFILE_HEADER myHeader; int res; // call the low-level META reader res = readmetadata(name, myHeader, buf); if (res == 0) { IOBlackBox->setCurrBuffp(buf); IOBlackBox->setCurrImgWidth(myHeader.nx); IOBlackBox->setCurrImgHeight(myHeader.ny); IOBlackBox->setCurrImgThickness(myHeader.nz); IOBlackBox->setXOffset(0); IOBlackBox->setYOffset(0); IOBlackBox->setZOffset(0); IOBlackBox->setCurrZPos(0); // first plane // only guessing there. if (myHeader.spp > 1) IOBlackBox->setCurrImgType(IM_SPECTRUM); else IOBlackBox->setCurrImgType(IM_SINGLE); IOBlackBox->setCurrPixType(myHeader.pixt); IOBlackBox->setCurrImgNbComps(1); IOBlackBox->setCurrImgNbSamples(myHeader.spp); IOBlackBox->setImgDesc("META"); // now that we swap the byte order on demand, // we need to read the byte order } return res; } // returns the number of frames in an ICS file int metanbsubfiles(const char *) { return 1; // that was easy. } static string trimlastblanks(string &s) { string ret; string::size_type pos; if ((pos = s.find_first_of(" ")) != string::npos) { ret = s.substr(0,pos); } else { ret = s; } return ret; } static string trimfirstblanks(string &s) { string ret; string::size_type pos; if ((pos = s.find_first_not_of(" ")) != string::npos) { ret = s.substr(pos); } else { ret = s; } return ret; } static int parse_meta_header(const char *filename, /* input filename */ RAWFILE_HEADER &myHeader) /* RAW header */ { /** Reads the META header, fills a RAW header RETURN VALUE: int DESCRIPTION: Read the the ITK Meta header file into the dataset description structure. HISTORY: Hugues Talbot, ESIEE 2007 TESTS: REFERENCES: KEYWORDS: **/ int nbdims = 0; int nx, ny, nz, skip; pixtype ptype=IM_INVALID; endianness endian=ENDIAN_LITTLE; bool retval = false; std::ifstream headerfile(filename); if (headerfile) { string currentline; string::size_type pos; dbgprintf("Loading header for ITK Meta image %s\n", filename); do { getline(headerfile, currentline); // look for the = sign if ((pos = currentline.find("=")) != string::npos) { string tmpkey = currentline.substr(0,pos); string key = trimlastblanks(tmpkey); string tmpval = currentline.substr(pos+1); string value = trimfirstblanks(tmpval); dbgprintf("Key=<%s>, value = <%s>\n", key.c_str(), value.c_str()); if (cmp_nocase(key, "ndims") == 0) { nbdims = atoi(value.c_str()); dbgprintf("Nb of dimensions = %d\n", nbdims); continue; } if (cmp_nocase(key, "dimsize") == 0) { std::istringstream isk(value); nx = ny = nz = 1; if (nbdims >= 3) { isk >> nx >> ny >> nz; } else if (nbdims == 2) { isk >> nx >> ny; } else { dbgprintf("Cannot read dimensions\n"); retval = 1; break; } dbgprintf("Dimensions : nx = %d, ny = %d, nz=%d\n", nx,ny,nz); continue; } if (cmp_nocase(key, "elementtype") == 0) { ptype = IM_INVALID; if (cmp_nocase(value, "met_uchar") == 0) ptype = IM_UINT1; if (cmp_nocase(value, "met_ushort") == 0) ptype = IM_UINT2; if (cmp_nocase(value, "met_int") == 0) ptype = IM_INT4; if (cmp_nocase(value, "met_double") == 0) ptype = IM_DOUBLE; dbgprintf("Pixel type : %s\n", IOBlackBox->typeName(ptype)); continue; } if (cmp_nocase(key, "binarydatabyteordermsb") == 0) { endian = ENDIAN_LITTLE; if (cmp_nocase(value, "true") == 0) { endian = ENDIAN_BIG; } dbgprintf("Endianness : %d\n", (int)endian); } if (cmp_nocase(key, "elementdatafile") == 0) { dbgprintf("End of header\n"); break; } dbgprintf("Unknown key !\n"); } } while (!currentline.empty()); // where are we in the file ? skip = headerfile.tellg(); dbgprintf("We need to skip %d bytes\n", skip); headerfile.close(); // fill the header if (retval == 0) { myHeader.nx = nx; myHeader.ny = ny; myHeader.nz = nz; myHeader.spp = 1; myHeader.byo = endian; myHeader.itl = 0; myHeader.pixt = ptype; myHeader.skip = skip; } } return retval; } /*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/ /* front-end code for the LIAR, Hugues Talbot 18 Dec 1997 */ int readmetadata(const char *fname, RAWFILE_HEADER &myHeader, void **&buf) { int res = 0; if ((res = parse_meta_header(fname, myHeader)) == 0) { res = readrawdata(fname, myHeader, buf); } return res; } ��������������������������imview-1.1.9c/io/readmeta.hxx�����������������������������������������������������������������������0000644�0000765�0000765�00000004045�10736150570�016724� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readmeta.hxx,v 1.1 2007/12/31 11:24:40 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * * readmeta.hxx * * Decodes the ITK Meta format * *-----------------------------------------------------------------------*/ #ifndef READMETA_H #define READMETA_H int readMETAImage(const char *name, int index); int metanbsubfiles(const char *name); int readmetadata(const char *fname, RAWFILE_HEADER &myHeader, void **&buffp); #endif // READMETA_H �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readpng.cxx������������������������������������������������������������������������0000644�0000765�0000765�00000013610�10745372616�016562� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readpng.cxx,v 4.4 2008/01/22 13:54:22 hut66au Exp $ * * Imview, the portable image analysis application * http://imview.sourceforge.net * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2007 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Read PNG natively. * A very important codec. * * This code shamelessly taken from FLTK. * * Hugues Talbot 9 Jun 2007 * * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" // name space definition if needed #include <stdio.h> #include <stdlib.h> //#include <setjmp.h> #include "imview.hxx" #if defined(HAVE_PNG) && defined(HAVE_LIBZ) # include <zlib.h> # include <png.h> #endif // HAVE_LIBPNG && HAVE_LIBZ #include "imageIO.hxx" extern imageIO *IOBlackBox; int pngnbcomp(const char *ident) { return 1; // we need to use MNG if we want movies } // read a PNG image, the index is always ignored. // Limitations : // - we do not read 16-bit images correctly (they get cast to 8-bit) // - we do not yield separate buffers per components. // int readPNGImage(const char *pngfilename, int index) // I - File to read { int retval = 0; #if defined(HAVE_PNG) && defined(HAVE_LIBZ) int i; // Looping var FILE *fp; // File pointer int channels; // Number of color channels png_structp pp; // PNG read pointer png_infop info; // PNG info pointers png_bytep *rows; // PNG row pointers int w, h, d; uchar *array; // Open the PNG file... if ((fp = fopen(pngfilename, "rb")) == NULL) { errprintf("readPNGimage : cannot open file %s\n", pngfilename); return 102; } // Setup the PNG data structures... pp = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); info = png_create_info_struct(pp); if (setjmp(pp->jmpbuf)) { errprintf("PNG file \"%s\" contains errors!\n", pngfilename); return 103; } // Initialize the PNG read "engine"... png_init_io(pp, fp); // Get the image dimensions and convert to grayscale or RGB... png_read_info(pp, info); if (info->color_type == PNG_COLOR_TYPE_PALETTE) png_set_expand(pp); if (info->color_type & PNG_COLOR_MASK_COLOR) channels = 3; else channels = 1; if ((info->color_type & PNG_COLOR_MASK_ALPHA) || info->num_trans) channels ++; w = (int)(info->width); h = (int)(info->height); d = channels; if (info->bit_depth < 8) { png_set_packing(pp); png_set_expand(pp); } // we ought to read the 16-bit data correctly, since we can ! else if (info->bit_depth == 16) png_set_strip_16(pp); # if defined(HAVE_PNG_GET_VALID) && defined(HAVE_PNG_SET_TRNS_TO_ALPHA) // Handle transparency... if (png_get_valid(pp, info, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(pp); # endif // HAVE_PNG_GET_VALID && HAVE_PNG_SET_TRNS_TO_ALPHA array = new uchar[w * h * d]; // Allocate pointers... rows = new png_bytep[h]; for (i = 0; i < h; i ++) rows[i] = (png_bytep)(array + i * w * d); // Read the image, handling interlacing as needed... for (i = png_set_interlace_handling(pp); i > 0; i --) png_read_rows(pp, rows, NULL, h); #ifdef WIN32 // Some Windows graphics drivers don't honor transparency when RGB == white if (channels == 4) { // Convert RGB to 0 when alpha == 0... uchar *ptr = (uchar *)array; for (i = w * h; i > 0; i --, ptr += 4) if (!ptr[3]) ptr[0] = ptr[1] = ptr[2] = 0; } #endif // WIN32 // Free memory and return... delete[] rows; png_read_end(pp, info); png_destroy_read_struct(&pp, &info, NULL); // this will require no translation IOBlackBox->setImData(array); IOBlackBox->setCurrImgWidth(w); IOBlackBox->setCurrImgHeight(h); IOBlackBox->setCurrImgThickness(1); IOBlackBox->setXOffset(0); IOBlackBox->setYOffset(0); IOBlackBox->setZOffset(0); IOBlackBox->setCurrImgNbComps(1); // only a single image in a PNG file IOBlackBox->setCurrImgNbSamples(d); IOBlackBox->setCurrImgSpp(d); // needed here because no currBuffp IOBlackBox->setCurrPixType(IM_UINT1); IOBlackBox->setCurrImgType((d == 1) ? IM_SINGLE : ((d == 3) ? IM_RGB : IM_SPECTRUM)); IOBlackBox->setImgDesc("PNG"); fclose(fp); #else errprintf("This version of imview cannot read PNG files\n"); retval = 101; // not supported #endif // HAVE_PNG && HAVE_LIBZ return retval; } ������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readpng.hxx������������������������������������������������������������������������0000644�0000765�0000765�00000003723�10632377322�016565� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readpng.hxx,v 4.1 2007/06/09 01:13:54 hut66au Exp $ * * Imview, the portable image analysis application * http://imview.sourceforge.net * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2007 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * readpng.H * * decodes a PNG file. Hugues Talbot 9/06/2007 * * * *-----------------------------------------------------------------------*/ #ifndef READPNG_H #define READPNG_H int pngnbcomp(const char *ident); int readPNGImage(const char *pngfilename, int index); #endif // READPNG_H ���������������������������������������������imview-1.1.9c/io/readpnm.cxx������������������������������������������������������������������������0000644�0000765�0000765�00000054262�10754360060�016566� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readpnm.cxx,v 4.13 2008/02/12 18:06:40 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Reads the pbm, pgm and ppm formats * This will be particularly useful for reading just about anything * thanks to the ppm library (netpbm or whaterver...) * * Based on similar readers in Z-IMAGE * * Hugues Talbot 28 Jul 1998 * *-----------------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <sys/types.h> #include <cstring> #include "imview.hxx" #include "imSystem.hxx" #include "../imageIO.hxx" #include "readpnm.hxx" extern imageIO *IOBlackBox; static int load_pbm_ascii(FILE *fp, int start[3], int end[3], pixtype *pixtype, imgtype *imgtype, void **inbuffp); static int load_pbm_raw(FILE *fp, int start[3], int end[3], pixtype *pixtype, imgtype *imgtype, void **inbuffp); static int load_pgm_ascii(FILE *fp, int start[3], int end[3], pixtype *pixtype, imgtype *imgtype, void **inbuffp); static int load_pgm_raw(FILE *fp, int start[3], int end[3], pixtype *pixtype, imgtype *imgtype, void **inbuffp); static int load_ppm_ascii(FILE *fp, int start[3], int end[3], pixtype *pixtype, imgtype *imgtype, void **inbuffp); static int load_ppm_raw(FILE *fp, int start[3], int end[3], pixtype *pixtype, imgtype *imgtype, void **inbuffp); static int load_MC_long_ppm_raw(FILE *fp, int start[3], int end[3], pixtype *thepixeltype, imgtype *theimgtype, void **inbuffp); static int getint(FILE *fp, toberead optional=IV_MANDATORY); static bool garbage; static long numgot; int readPNMImage(const char *name) { void *p=0; int start[3], end[3], nbsamples = 0; pixtype thepixtype; imgtype theimgtype; FILE *fp; char magic_num[3]; int retval = 0; if ((fp = im_fopen(name,"rb")) == NULL) return 1; /* in case nothing is read */ start[0] = start[1] = start[2] = 0; end[0] = end[1] = end[2] = 0; thepixtype = IM_UINT1; theimgtype = IM_SINGLE; fscanf (fp,"%2s",magic_num); switch(magic_num[1]) { case '1': retval = load_pbm_ascii(fp, start, end, &thepixtype, &theimgtype, &p); nbsamples = 1; break; case '2': retval = load_pgm_ascii(fp, start, end, &thepixtype, &theimgtype, &p); nbsamples = 1; break; case '3': retval = load_ppm_ascii(fp, start, end, &thepixtype, &theimgtype, &p); nbsamples = 3; break; case '4': retval = load_pbm_raw(fp, start, end, &thepixtype, &theimgtype, &p); nbsamples = 1; break; case '5': retval = load_pgm_raw(fp, start, end, &thepixtype, &theimgtype, &p); nbsamples = 1; break; case '6': retval = load_ppm_raw(fp, start, end, &thepixtype, &theimgtype, &p); nbsamples = 3; break; #ifdef HAVE_PINK_PGM_EXTENSIONS case '7': errprintf("readPNMImage: obsolete PINK PGM format\n"); break; case '8': dbgprintf("Michel Couprie's raw long PGM\n"); retval = load_MC_long_ppm_raw(fp, start, end, &thepixtype, &theimgtype, &p); break; // raw long 2D-3D case '9': // raw float 2D-3D warnprintf("PINK raw float PGM extension not implemented yet, nag the developer\n"); break; case 'A': // ascii float 2D-3D warnprintf("PINK ascii float PGM extension not implemented yet, nag the developer\n"); break; case 'B': // ascii long 2D-3D warnprintf("PINK ascii long PGM extension not implemented yet, nag the developer\n"); break; #endif default: errprintf("readPNMImage: Unsupported PNM format\n"); retval = 100; // unsupported format break; } if (retval == 0) { if (garbage) errprintf("readPNMImage: There was some garbage in this picture\n"); IOBlackBox->setCurrBuffp((void **)p); IOBlackBox->setCurrImgWidth(end[0]-start[0]+1); IOBlackBox->setCurrImgHeight(end[1]-start[1]+1); IOBlackBox->setCurrImgThickness(end[2]-start[2]+1); IOBlackBox->setXOffset(start[0]); IOBlackBox->setYOffset(start[1]); IOBlackBox->setZOffset(start[2]); IOBlackBox->setCurrImgType((imgtype)theimgtype); IOBlackBox->setCurrPixType((pixtype)thepixtype); IOBlackBox->setCurrImgNbComps(1); // only a single image in a PNM file IOBlackBox->setCurrImgNbSamples(nbsamples); IOBlackBox->setCurrImgColourMap(0); IOBlackBox->setImgDesc("PNM"); } fclose(fp); return retval; } // // read the next integer and returns true if it can. // if it can't it returns false // if optional is set to 1 or true, then if we encounter a carriage // return or EOF before, then the integer is not read // the function then returns 0. // if optional is set to '2', then a '\n' or '\r' or both are explicitely read static int getint(FILE *fp, toberead optional) { int c, i, firstchar; /* note: if it sees a '#' character, all characters from there to end of line are appended to the comment string */ /* skip forward to start of next number */ c = getc(fp); while (1) { /* eat comments */ if (c=='#') { /* if we're at a comment, read to end of line */ char cmt[256], *sp; // put the commment in the comment string. Probably useless sp = cmt; firstchar = 1; while (1) { c=getc(fp); if (firstchar && c == ' ') firstchar = 0; /* lop off 1 sp after # */ else { if (c == '\n' || c == EOF) break; if ((sp-cmt)<250) *sp++ = c; } } *sp++ = '\n'; *sp = '\0'; } if (c==EOF) return 0; if (c>='0' && c<='9') break; /* we've found what we were looking for */ if ((optional==IV_OPTIONAL) && ((c == '\n') || (c == '\r') || (c==' ') || (c=='\t'))) { dbgprintf("getint: whitespace read instead of optional char\n"); return 0; /* we found an end-of-line instead of a number but that's OK, we didn't really want it :-) */ } /* see if we are getting garbage (non-whitespace) */ if (c!=' ' && c!='\t' && c!='\r' && c!='\n' && c!=',') { garbage = true; } c = getc(fp); } /* we're at the start of a number, continue until we hit a non-number */ i = 0; while (1) { i = (i*10) + (c - '0'); c = getc(fp); if (c==EOF) return i; if (c<'0' || c>'9') { // this is necessary for the "optional read" logic // specs say last number (bit depth) is followed by a // single whitespace, which must get eaten if (optional != IV_FINAL) ungetc(c, fp); // if we don't unget, the \n or \r following a number will get eaten break; } } numgot++; return i; } int pnmnbsubfiles(const char *) { return 1; // particularly simple } static int load_pgm_ascii(FILE *fp, int start[3], int end[3], pixtype *pixtype, imgtype *imgtype, void **inbuffp) { int retval = 0; void **buffp; int ncol, nrow, maxgrey, j, i; unsigned char *cp; unsigned short *sp; garbage = false; numgot = 0; ncol = getint(fp); nrow = getint(fp); maxgrey = getint(fp, IV_FINAL); if (maxgrey <= 1) *pixtype = IM_BINARY; else if (maxgrey <= 255) *pixtype = IM_UINT1; else *pixtype = IM_UINT2; *imgtype = IM_SPECTRUM; // in all cases for a first approximation start[0] = 0; start[1] = 0; start[2] = 0; end[0] = ncol-1; end[1] = nrow-1; end[2] = 0; // no 3D data in there. buffp = (void **)malloc(sizeof(void *)); if ((*pixtype == IM_BINARY) || (*pixtype == IM_UINT1)) { // get all the data buffp[0] = malloc(ncol*nrow*sizeof(unsigned char)); cp = (unsigned char *)(buffp[0]); for (j = 0 ; j < ncol ; j++) { for (i = 0 ; i < nrow ; i++) { *cp++ = (unsigned char)getint(fp); } } } else { // short buffp[0] = malloc(ncol*nrow*sizeof(unsigned short)); sp = (unsigned short *)(buffp[0]); for (j = 0 ; j < nrow ; j++) { for (i = 0 ; i < ncol ; i++) { *sp++ = (unsigned short)getint(fp); } } } *inbuffp = buffp; return retval; } // // Read short values found in RAW pgm output. // // Specs http://netpbm.sourceforge.net/doc/pgm.html // says MSB is first (like sparcs, motorola 68k) // *unlike* PCs : shorts are read little-endian fashion static int getshort(FILE *fp) { int c1, c2; c1 = getc(fp); if (c1 == EOF) return 0; c2 = getc(fp); if (c2 == EOF) return 0; numgot++; return (c1 << 8) | c2; } // reads any signed value of given length, returned as long. // 64-bit maxi static long getanysigned(FILE *fp, unsigned int length) { int ci[8]; unsigned int i; long retval; assert((length <= sizeof(long)) && (length <= 8)); memset(ci, 0, 8); for (i = 0 ; i < length ; ++i) { ci[i] = getc(fp); if (ci[i] == EOF) return 0; numgot++; } retval = 0; for (i = 0 ; i < length ; ++i) { retval |= ci[i] << (8*i); } return retval; } static int load_pgm_raw(FILE *fp, int start[3], int end[3], pixtype *pixtype, imgtype *imgtype, void **inbuffp) { int retval = 0; void **buffp; int ncol, nrow, nslice, maxgrey, k, j, i; unsigned char *cp; unsigned short *sp; garbage = false; numgot = 0; ncol = getint(fp); nrow = getint(fp); nslice = getint(fp, IV_OPTIONAL); // optionnally read a 3rd dimension nslice = (nslice == 0) ? 1:nslice; // at least one slice maxgrey = getint(fp, IV_FINAL); dbgprintf("load_pgm_raw: (%dx%dx%d), %d grey-levels\n", ncol,nrow,nslice,maxgrey); if (maxgrey <= 1) *pixtype = IM_BINARY; else if (maxgrey <= 255) *pixtype = IM_UINT1; else *pixtype = IM_UINT2; // unsigned short int is the larger type *imgtype = IM_SPECTRUM; // in all cases for a first approximation start[0] = 0; start[1] = 0; start[2] = 0; end[0] = ncol-1; end[1] = nrow-1; end[2] = nslice-1; // maybe 3D data in there. buffp = (void **)malloc(sizeof(void *)); if ((*pixtype == IM_BINARY) || (*pixtype == IM_UINT1)) { // get all the data buffp[0] = malloc(ncol*nrow*nslice*sizeof(unsigned char)); cp = (unsigned char *)(buffp[0]); numgot = fread(cp, (size_t) 1, (size_t) nrow*ncol*nslice, fp); } else { // unsigned short buffp[0] = malloc(ncol*nrow*nslice*sizeof(unsigned short)); sp = (unsigned short *)(buffp[0]); for (k = 0 ; k < nslice ; ++k) { for (j = 0 ; j < nrow ; j++) { for (i = 0 ; i < ncol ; i++) { *sp++ = getshort(fp); } } } } *inbuffp = buffp; return retval; } static int getbit(FILE *fp) { int c; /* skip forward to start of next number */ c = getc(fp); while (1) { /* eat comments */ if (c=='#') { /* if we're at a comment, read to end of line */ char cmt[256], *sp; sp = cmt; while (1) { c=getc(fp); if (c == '\n' || c == EOF) break; if ((sp-cmt)<250) *sp++ = c; } *sp++ = '\n'; *sp = '\0'; } if (c==EOF) return 0; if (c=='0' || c=='1') break; /* we've found what we were looking for */ /* see if we are getting garbage (non-whitespace) */ if (c!=' ' && c!='\t' && c!='\r' && c!='\n' && c!=',') garbage=true; c = getc(fp); } numgot++; return(c-'0'); } static int load_pbm_ascii(FILE *fp, int start[3], int end[3], pixtype *pixtype, imgtype *imgtype, void **inbuffp) { int retval = 0; void **buffp; int ncol, nrow, nslice, j, i; unsigned char *cp; garbage = false; numgot = 0; ncol = getint(fp); nrow = getint(fp); nslice=getint(fp,IV_OPTIONAL); nslice = (nslice==0) ? 1:nslice; // at least one slice *pixtype = IM_BINARY; *imgtype = IM_SPECTRUM; // in all cases for a first approximation start[0] = 0; start[1] = 0; start[2] = 0; end[0] = ncol-1; end[1] = nrow-1; end[2] = nslice-1; // no 3D data in there. buffp = (void **)malloc(sizeof(void *)); // get all the data buffp[0] = malloc(ncol*nrow*nslice*sizeof(unsigned char)); cp = (unsigned char *)(buffp[0]); for (j = 0 ; j < nrow ; j++) { for (i = 0 ; i < ncol ; i++) { *cp++ = (unsigned char)getbit(fp); } } *inbuffp = buffp; return retval; } static int load_pbm_raw(FILE *fp, int start[3], int end[3], pixtype *pixtype, imgtype *imgtype, void **inbuffp) { int retval = 0; void **buffp; int ncol, nrow, nslice, l, k, j, i; unsigned char *cp; garbage = false; numgot = 0; ncol = getint(fp); nrow = getint(fp); nslice = getint(fp, IV_OPTIONAL); // get a third dimension if it is present in the file if (nslice == 0) // we didn't get a third number, but we do have one slice nslice = 1; *pixtype = IM_BINARY; *imgtype = IM_SPECTRUM; // in all cases for a first approximation start[0] = 0; start[1] = 0; start[2] = 0; end[0] = ncol-1; end[1] = nrow-1; end[2] = nslice-1; // maybe 3D data in there. buffp = (void **)malloc(sizeof(void *)); // get all the data buffp[0] = malloc(ncol * nrow * nslice * sizeof(unsigned char)); cp = (unsigned char *)(buffp[0]); for (l = 0 , k = 0 ; l < nslice ; ++l) { for (j = 0 ; j < nrow ; j++) { for (i = 0 ; i < ncol ; i++) { if (i%8 == 0) { // read one char, ignore errors k = getc(fp); if (k == EOF) garbage = true; } // read the leftmost bit *cp++ = (unsigned char)(k&0x80 ? 1: 0); k <<= 1; // double k } } } *inbuffp = buffp; return retval; } static int load_ppm_ascii(FILE *fp, int start[3], int end[3], pixtype *pixtype, imgtype *imgtype, void **inbuffp) { int retval = 0; void **buffp; int ncol, nrow, nslice, maxgrey, k, j, i; unsigned char *cpR, *cpG, *cpB; unsigned short *spR, *spG, *spB; garbage = false; numgot = 0; ncol = getint(fp); nrow = getint(fp); nslice = getint(fp, IV_OPTIONAL); // read optional 3rd dimension maxgrey = getint(fp, IV_FINAL); nslice = (nslice == 0) ? 1:nslice; // we do have one slice if (maxgrey <= 1) *pixtype = IM_BINARY; else if (maxgrey <= 255) *pixtype = IM_UINT1; else *pixtype = IM_UINT2; // unsigned short int is the larger type *imgtype = IM_RGB; // in all cases for a first approximation start[0] = 0; start[1] = 0; start[2] = 0; end[0] = ncol-1; end[1] = nrow-1; end[2] = nslice-1; // no 3D data in there. buffp = (void **)malloc(3*sizeof(void *)); if ((*pixtype == IM_BINARY) || (*pixtype == IM_UINT1)) { // get all the data buffp[0] = malloc(ncol*nrow*nslice*sizeof(unsigned char)); buffp[1] = malloc(ncol*nrow*nslice*sizeof(unsigned char)); buffp[2] = malloc(ncol*nrow*nslice*sizeof(unsigned char)); cpR = (unsigned char *)(buffp[0]); cpG = (unsigned char *)(buffp[1]); cpB = (unsigned char *)(buffp[2]); for (k = 0 ; k < nslice ; ++k) { for (j = 0 ; j < nrow ; j++) { for (i = 0 ; i < ncol ; i++) { *cpR++ = (unsigned char)getint(fp); *cpG++ = (unsigned char)getint(fp); *cpB++ = (unsigned char)getint(fp); } } } } else { // short buffp[0] = malloc(ncol*nrow*nslice*sizeof(unsigned short)); buffp[1] = malloc(ncol*nrow*nslice*sizeof(unsigned short)); buffp[2] = malloc(ncol*nrow*nslice*sizeof(unsigned short)); spR = (unsigned short *)(buffp[0]); spG = (unsigned short *)(buffp[1]); spB = (unsigned short *)(buffp[2]); for (k = 0 ; k < nslice ; ++k) { for (j = 0 ; j < nrow ; j++) { for (i = 0 ; i < ncol ; i++) { *spR++ = (unsigned short)getint(fp); *spG++ = (unsigned short)getint(fp); *spB++ = (unsigned short)getint(fp); } } } } *inbuffp = buffp; return retval; } /* this is fairly iffy */ /* Here are the assumptions : * 1- File contains either 2 or 3 dimensions, then a carriage return, then * the maxval, all in ASCII, then the data in binary form. * 2- The data is little-endian (x86 ordering) * 3- longs are in fact signed 32 bits integers here. */ static int load_MC_long_ppm_raw(FILE *fp, int start[3], int end[3], pixtype *pixtype, imgtype *imgtype, void **inbuffp) { int retval = 0, numread = 0; void **buffp = NULL; int ncol, nrow, nslice, maxgrey; garbage = false; numgot = 0; ncol = getint(fp); nrow = getint(fp); // read the next int unless we find a '\n' first nslice = getint(fp, IV_OPTIONAL); if (nslice == 0) nslice = 1; // we have at least one slice start[0] = 0; start[1] = 0; start[2] = 0; end[0] = ncol-1; end[1] = nrow-1; end[2] = nslice-1; // maybe some 3D data in there. maxgrey = getint(fp, IV_FINAL); *pixtype = IM_INT4; *imgtype = IM_SINGLE; // one buffer buffp = (void **)malloc(sizeof(void*)); buffp[1] = (void*) malloc(ncol*nrow*nslice*sizeof(int32_t)); numread = fread(buffp[1], sizeof(int32_t), ncol*nrow*nslice, fp); if (numread < ncol*nrow*nslice) { garbage = true; retval = -1; } else { numgot += numread; } *inbuffp = buffp; return retval; } static int load_ppm_raw(FILE *fp, int start[3], int end[3], pixtype *pixtype, imgtype *imgtype, void **inbuffp) { int retval = 0; void **buffp; int ncol, nrow, nslice, maxgrey, k, j, i; unsigned char *cpR, *cpG, *cpB; unsigned short *spR, *spG, *spB; garbage = false; numgot = 0; ncol = getint(fp); nrow = getint(fp); nslice = getint(fp, IV_OPTIONAL); // optionnally read a 3rd dimension. if (nslice == 0) nslice = 1; // we do have one slice maxgrey = getint(fp, IV_FINAL); dbgprintf("load_ppm_raw : dimensions=(%dx%dx%d), %d grey-levels\n",ncol,nrow,nslice, maxgrey); if (maxgrey <= 1) *pixtype = IM_BINARY; else if (maxgrey <= 255) *pixtype = IM_UINT1; else *pixtype = IM_UINT2; // short int is the larger type *imgtype = IM_RGB; // in all cases for a first approximation start[0] = 0; start[1] = 0; start[2] = 0; end[0] = ncol-1; end[1] = nrow-1; end[2] = nslice-1; // maybe 3D data in there. buffp = (void **)malloc(3*sizeof(void *)); if ((*pixtype == IM_BINARY) || (*pixtype == IM_UINT1)) { // get all the data // get all the data buffp[0] = malloc(ncol*nrow*nslice*sizeof(unsigned char)); buffp[1] = malloc(ncol*nrow*nslice*sizeof(unsigned char)); buffp[2] = malloc(ncol*nrow*nslice*sizeof(unsigned char)); cpR = (unsigned char *)(buffp[0]); cpG = (unsigned char *)(buffp[1]); cpB = (unsigned char *)(buffp[2]); for (k = 0 ; k < nslice ; ++k) { for (j = 0 ; j < nrow ; j++) { for (i = 0 ; i < ncol ; i++) { *cpR++ = getc(fp); *cpG++ = getc(fp); *cpB++ = getc(fp); } } } } else { // short buffp[0] = malloc(ncol*nrow*nslice*sizeof(unsigned short)); buffp[1] = malloc(ncol*nrow*nslice*sizeof(unsigned short)); buffp[2] = malloc(ncol*nrow*nslice*sizeof(unsigned short)); spR = (unsigned short *)(buffp[0]); spG = (unsigned short *)(buffp[1]); spB = (unsigned short *)(buffp[2]); for (k = 0 ; k < nslice ; ++k) { for (j = 0 ; j < nrow ; j++) { for (i = 0 ; i < ncol ; i++) { *spR++ = getshort(fp); *spG++ = getshort(fp); *spB++ = getshort(fp); } } } } *inbuffp = buffp; return retval; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readpnm.hxx������������������������������������������������������������������������0000644�0000765�0000765�00000004024�10745372616�016574� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readpnm.hxx,v 4.2 2008/01/22 13:54:22 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Header information for PNM input * * Hugues Talbot 29 Jul 1998 * *-----------------------------------------------------------------------*/ #ifndef READPNM_H #define READPNM_H typedef enum { IV_MANDATORY = 0, IV_OPTIONAL , IV_FINAL } toberead; int readPNMImage(const char *name); int pnmnbsubfiles(const char *); #endif ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readps.cxx�������������������������������������������������������������������������0000644�0000765�0000765�00000015260�10066051562�016411� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readps.cxx,v 4.5 2004/06/22 15:42:42 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2004 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*----------------------------------------------------------------------- * Utility function to help parse Postscript Files. * * Hugues Talbot 20 Jun 2004 */ #include <string> #include <iostream> #include <fstream> // file streams #include <sstream> // string stream #include <stdio.h> // still needed for sscanf #include <assert.h> #include "imunistd.h" #include "imview.hxx" #include "machine.hxx" #include "newprefio.hxx" #include "readps.hxx" using std::ifstream; using std::ofstream; using std::ostringstream; using std::getline; using std::string; using std::exception; using std::endl; using std::ios_base; extern imprefs *fileprefs; extern float page_formats[][2]; // default constructor psinfo::psinfo() { init(); } psinfo::psinfo(const char *fn) { init(); filename_ = fn; imtempnam(tmpfn_); // temporary file name (nothing is opened yet) } psinfo::~psinfo() { dbgprintf("Deleting file %s\n", tmpfn_); unlink(tmpfn_); // delete the temporary file if it exists } void psinfo::init(void) { Ox_ = Oy_ = 1e6; // outrageous number W_ = H_ = 0; // outrageous number filename_ = ""; BBcs_ = "%%%%BoundingBox: %f %f %f %f"; DocMedcs_ = "%%%%DocumentMedia: %*s %f %f"; PgBBcs_ = "%%%%PageBoundingBox: %f %f %f %f"; assert(fileprefs != 0); renderBB_ = fileprefs->psBoundingBox(); assert((renderBB_ < PAGESIZE_NB) && (renderBB_ >= 0)); } void psinfo::getBoundingBox(float &Ox, float &Oy, float &W, float &H) { if (renderBB_ == PAGESIZE_AUTO) { Ox = Ox_ ; Oy = Oy_ ; W = W_; H = H_; } else { Ox = Oy = 0; W = page_formats[renderBB_][0]; H = page_formats[renderBB_][1]; } return; } // to incrementally find the right BB. void psinfo::improveBB(float x1, float x2, float y1, float y2) { float bbw, bbh; // found a bounding box if (x1 < Ox_) Ox_ = x1; if (y1 < Oy_) Oy_ = y1; bbw = x2 - x1; if (bbw > W_) W_ = bbw; bbh = y2 - y1; if (bbh > H_) H_ = bbh; return; } void psinfo::parsefile(void) { dbgprintf("Parsing information from file %s\n", filename_); try { int nbscan = 0; bool hasShowpage = 0; ifstream PsFile(filename_); ofstream TmpFile(tmpfn_); if (PsFile) { string currentline; string showpage("showpage"); string::size_type i; float bbx1=0, bbx2=0, bby1=0, bby2=0; ostringstream os_translate; char c; unsigned int cpl = showpage.length(); // need to recenter to zero if (renderBB_ == PAGESIZE_AUTO) { dbgprintf("Leaving enough room for the final translation\n"); TmpFile << bbx1 << " " << bby1 << " translate " << endl; } //while (getline(PsFile, currentline)) { currentline.erase(); while (PsFile.get(c)) { // this is to support Mac, PC and Unix terminations alike if ((c != '\n') && (c != '\r')) { currentline.push_back(c); continue; } const char *pchline = currentline.c_str(); // parsing for BoundingBox if ((nbscan = sscanf(pchline,BBcs_, &bbx1, &bby1, &bbx2, &bby2)) == 4) { dbgprintf("Found bounding box %s\n", pchline); improveBB(bbx1, bbx2, bby1, bby2); } // parsing for PageBoundingBox if ((nbscan = sscanf(pchline, PgBBcs_, &bbx1, &bby1, &bbx2, &bby2)) == 4) { dbgprintf("Found page bounding box %s\n", pchline); improveBB(bbx1, bbx2, bby1, bby2); } // parsing for DocumentMedia if ((nbscan = sscanf(pchline, DocMedcs_, &bbx2, &bby2)) == 2) { dbgprintf("Found document media %s\n", pchline); improveBB(Ox_, bbx2, Oy_, bby2); } if (!hasShowpage && ((i =currentline.find(showpage)) != string::npos)) { if ((i==0) // start of line && ((currentline.length() == cpl) // End of line || (currentline[cpl] == '\r') // Whitespace || (currentline[cpl] == '\n') || (currentline[cpl] == '\t') || (currentline[cpl] == ' '))) { hasShowpage = true; dbgprintf("Found 'showpage' in file, line %s\n", pchline); } else { dbgprintf("Found non-'showpage' ignored\n"); } } // copy the line TmpFile << currentline << endl; // empty the string and start again currentline.erase(); } dbgprintf("PS file dimensions are: (%f, %f), %f x %f\n", Ox_, Oy_, W_, H_); if (!hasShowpage) { // add a showpage at the end TmpFile << showpage << endl; } if (renderBB_ == PAGESIZE_AUTO) { os_translate << -Ox_ << " " << -Oy_ << " translate"; dbgprintf("going back to beginning and shifting the origin\n"); TmpFile.seekp(0, ios_base::beg); TmpFile << os_translate.str() << endl; dbgprintf("Writing %s at the begining\n", os_translate.str().c_str()); } } // files are closed when destructed } catch (exception &e) { ostringstream osm; osm << "Error: " << e.what() ; warnprintf("Exception in psinfo::parsefile -> %s", osm.str().c_str()); Ox_ = Oy_ = W_ = H_ = -1; } return; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readps.hxx�������������������������������������������������������������������������0000644�0000765�0000765�00000004657�10065604403�016423� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readps.hxx,v 4.4 2004/06/21 16:12:51 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*----------------------------------------------------------------------- * Utility function to help parse Postscript Files. * * Hugues Talbot 20 Jun 2004 */ #ifndef READPS_HXX #define READPS_HXX #define DEFAULT_PS_RES 72.0 // default Postscript resolution = 72dpi class psinfo { public: psinfo(const char *fn); ~psinfo(); void getBoundingBox(float &Ox, float &Oy, float &W, float &H); const char *getTmpFilename(void) {return tmpfn_;} void parsefile(void); private: psinfo(); // not allowed to construct without a filename void init(void); void improveBB(float x1, float x2, float y1, float y2); const char *filename_; char tmpfn_[DFLTSTRLEN]; const char *BBcs_, *DocMedcs_, *PgBBcs_ ; float Ox_, Oy_, W_, H_; // boundingbox page_size renderBB_; }; #endif // READPS_HXX ���������������������������������������������������������������������������������imview-1.1.9c/io/readraw.cxx������������������������������������������������������������������������0000644�0000765�0000765�00000024761�10720437045�016567� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readraw.cxx,v 4.4 2007/11/20 01:53:41 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Read raw buffers, for example coming from a socket or a pipe... * * Hugues Talbot 6 Mar 2000 * * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" // name space definition if needed #include <string.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include "imunistd.h" #include <errno.h> #include <map> // STL #include "imview.hxx" #include "imageIO.hxx" #include "machine.hxx" // portability stuff #include "rawImage.hxx" #include "readraw.hxx" #include "byte-swap.h" using std::map; extern imageIO *IOBlackBox; extern map <string, RAWFILE_HEADER> rawfilemap; typedef map<string, RAWFILE_HEADER>::iterator rfhmi; // raw file header map iterator // prototypes for static functions template<class T>int readrawbuf(int rfd, RAWFILE_HEADER const &myheader, T **&buffp); int rawnbcomp(const char *ident) { return 1; // we may change that later, don't know. } int readRaw(const char *ident, int index) { int res = 0; rfhmi p; void **buf; dbgprintf("Read raw called\n"); p = rawfilemap.find(ident); if (p == rawfilemap.end()) { errprintf("Header not found\n"); res = 2; } else { RAWFILE_HEADER &myheader = p->second; dbgprintf("Header found\n"); // read the actual data res = readrawdata(ident, myheader, buf); if (res == 0) { IOBlackBox->setCurrBuffp(buf); IOBlackBox->setCurrImgWidth(myheader.nx); IOBlackBox->setCurrImgHeight(myheader.ny); IOBlackBox->setCurrImgThickness(myheader.nz); IOBlackBox->setXOffset(0); IOBlackBox->setYOffset(0); IOBlackBox->setZOffset(0); IOBlackBox->setCurrZPos(0); // first plane // only guessing there. if (myheader.spp > 1) IOBlackBox->setCurrImgType(IM_SPECTRUM); else IOBlackBox->setCurrImgType(IM_SINGLE); IOBlackBox->setCurrPixType(myheader.pixt); IOBlackBox->setCurrImgNbComps(1); IOBlackBox->setCurrImgNbSamples(myheader.spp); IOBlackBox->setImgDesc("RAW"); // now that we swap the byte order on demand, // we need to read the byte order } } return res; } int readrawdata(const char *fname, RAWFILE_HEADER const &myheader, void **&buffp) { int retval = 0; int rfd; // raw file descriptor rfd = open(fname, O_RDONLY | O_BINARY); if (rfd > 0) { switch(myheader.pixt) { case IM_BINARY: case IM_INT1: case IM_UINT1: { uchar **ch_buf; retval = readrawbuf(rfd, myheader, ch_buf); buffp = (void **)ch_buf; } break; case IM_INT2: { short **sh_buf; retval = readrawbuf(rfd, myheader, sh_buf); buffp = (void **)sh_buf; } break; case IM_UINT2: { ushort **ush_buf; retval = readrawbuf(rfd, myheader, ush_buf); buffp = (void **)ush_buf; } break; case IM_INT4: { int **int_buf; retval = readrawbuf(rfd, myheader, int_buf); buffp = (void **)int_buf; } break; case IM_UINT4: { uint **uint_buf; retval = readrawbuf(rfd, myheader, uint_buf); buffp = (void **)uint_buf; } break; case IM_FLOAT: { float **flt_buf; retval = readrawbuf(rfd, myheader, flt_buf); buffp = (void **)flt_buf; } break; case IM_DOUBLE: { double **dbl_buf; retval = readrawbuf(rfd, myheader, dbl_buf); buffp = (void **)dbl_buf; } break; default: errprintf("readrawdata: Unsupported pixel type %s\n", IOBlackBox->typeName(myheader.pixt)); retval = 1; break; } close(rfd); } else { errprintf("Could not open %s, %s\n", fname, strerror(errno)); retval = 10; } return retval; } // template function! template<class T>int readrawbuf(int rfd, RAWFILE_HEADER const &myheader, T **&buffp) { T **cbuf; int nx, ny, nz; int spp; int i, j, p, l, interleave; ssize_t nbread = 0; int retval = 0; bool swap = false; nx = myheader.nx; ny = myheader.ny; nz = myheader.nz; spp = myheader.spp; cbuf = (T **)calloc(spp, sizeof(T*)); if (cbuf == 0) { return 20; // out of memory } for (i = 0 ; i < spp ; i++) { cbuf[i] = (T *)malloc(nx*ny*nz*sizeof(T)); if (cbuf[i] == 0) { for (j = 0 ; j < i ; j++) free(cbuf[i]); return 21; // out of memory too! } } // if spp is 1, we use the BSQ interleaving, as it is the most efficient interleave = (spp == 1) ? rawimage::BSQ : myheader.itl; // skip the header if (lseek(rfd, myheader.skip, SEEK_SET) < 0) { errprintf("Cannot skip %d bytes (header size): %s\n", strerror(errno)); for (i = 0 ; i < spp ; i++) free(cbuf[i]); free(cbuf); *buffp = 0; return 50; // header not skipped, nothing read } switch(interleave) { case rawimage::BIL : { // line interleave int *index; index = (int *)calloc(spp, sizeof(int)); for (p = 0; p < nz ; p++) { for (l = 0 ; l < ny ; l++) { for (i = 0 ; i < spp ; i++) { nbread = read(rfd, cbuf[i] + index[i] , nx); if (nbread != nx) { errprintf("Incomplete read, %s\n", (nbread < 0) ? strerror(errno) : "but no other error"); retval = 3; goto fail_bil; } index[i] += nx; } } } fail_bil: free(index); // we will still endeavour to read something. } break; case rawimage::BIP : { // pixel interleave T **q; T *aLine, *pl; int n; q = (T **) malloc(spp * sizeof(T*)); aLine = (T *) malloc(nx * spp * sizeof(T)); for (i = 0 ; i < spp ; i++) q[i] = cbuf[i]; for (p = 0 ; p < nz ; p++) { for (l = 0 ; l < ny ; l++) { nbread = read(rfd, aLine, nx * spp * sizeof(T)); if (nbread != (int)(nx * spp * sizeof(T))) { errprintf("Incomplete read, %s\n", (nbread < 0) ? strerror(errno) : "but no other error"); retval = 4; goto fail_bip; } pl = aLine; for (n = 0 ; n < nx ; n++) for (i = 0 ; i < spp ; i++) { *(q[i])++ = *pl++; } } } fail_bip: free(aLine); free(q); } break; case rawimage::BSQ : // block interleave for (i = 0 ; i < spp ; i++) { int totalread = 0; int mustread = nx*ny*nz*sizeof(T); // of course the read might be short, we read as much as we can in one go while ((totalread < mustread) && ((nbread = read(rfd, cbuf[i]+totalread, mustread-totalread)) > 0)) totalread += nbread; if (totalread != mustread) { errprintf("Incomplete read, %d bytes missing: %s\n", mustread-totalread, (nbread < 0) ? strerror(errno) : "but no other error"); retval = 2; break; } } break; } if ((myheader.byo != ENDIAN_DEFAULT) && (myheader.byo != checkendian())) { swap = true; } if(swap) { dbgprintf("Readraw: swapping the endianness of the buffer\n"); switch(sizeof(T)) { case 2: for(j = 0; j < spp; j++) swap_2_bytes((void *) cbuf[j], nx*ny*nz); break; case 4: for(j = 0; j < spp; j++) swap_4_bytes((void *) cbuf[j], nx*ny*nz); break; case 8: for(j = 0; j < spp; j++) swap_8_bytes((void *) cbuf[j], nx*ny*nz); break; } } buffp = cbuf; return retval; } ���������������imview-1.1.9c/io/readraw.hxx������������������������������������������������������������������������0000644�0000765�0000765�00000004112�07653237124�016567� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readraw.hxx,v 4.0 2003/04/28 14:44:36 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Read raw data coming from a file (headerless images) * * Hugues Talbot 28 May 2000 * *-----------------------------------------------------------------------*/ // prototypes #ifndef READRAW_H #define READRAW_H int rawnbcomp(const char *ident); int readRaw(const char *ident, int index); int readrawdata(const char *fname, RAWFILE_HEADER const &myheader, void **&buffp); #endif // READRAW ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readsocket.cxx���������������������������������������������������������������������0000644�0000765�0000765�00000017464�07653237124�017277� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readsocket.cxx,v 4.0 2003/04/28 14:44:36 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Read raw buffers, for example coming from a socket or a pipe... * * Hugues Talbot 6 Mar 2000 * * *-----------------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <vector> // STL #include "imview.hxx" #include "../imageIO.hxx" extern imageIO *IOBlackBox; static inline short swap2(short u); static inline int swap4(int i); static inline double swap8(double d); int socketnbcomp(const char *ident) { IMAGE_HEADER *myheader; int retval = 0; // find the corresponding data received through the socket myheader = IOBlackBox->findHeader(ident); if (myheader != 0) { retval = myheader->nbc; } return retval; } static inline short swap2(short u) { char *in, *out; short ret; in = (char *)&u; out = (char *)&ret; out[1] = in[0]; out[0] = in[1]; return ret; } static inline int swap4(int i) { char *in, *out; int ret; in = (char *)&i; out = (char *)&ret; out[3] = in[0]; out[2] = in[1]; out[1] = in[2]; out[0] = in[3]; return ret; } static inline double swap8(double d) { char *in, *out; double ret; in = (char *)&d; out = (char *)&ret; out[7] = in[0]; out[6] = in[1]; out[5] = in[2]; out[4] = in[3]; out[3] = in[4]; out[2] = in[5]; out[1] = in[6]; out[0] = in[7]; return ret; } static void byteSwap(IMAGE_HEADER *myheader) { // does the data need swapping? if (myheader->needswap) { int i, j; IMAGECOMP_HEADER *cmp; dbgprintf("Pixels have the wrong byte order, they need to be swapped\n"); for (i = 0 ; i <myheader->nbc ; i++) { cmp = &(myheader->comp[i]); switch(cmp->pixt) { case IM_BINARY: case IM_CHAR: case IM_UINT1: break; // no need to do anything case IM_INT2: case IM_UINT2: for (j = 0 ; j < cmp->spp ; j++) { short *p = (short *)(cmp->buffp[j]); short *end = p + cmp->nx * cmp->ny * cmp->nz; while (p < end) { *p = swap2(*p); p++; } } break; case IM_INT4: case IM_UINT4: case IM_FLOAT: for (j = 0 ; j < cmp->spp ; j++) { int *p = (int *)(cmp->buffp[j]); int *end = p + cmp->nx * cmp->ny * cmp->nz; while (p < end) { *p = swap4(*p); p++; } } break; case IM_INT8: case IM_UINT8: case IM_DOUBLE: for (j = 0 ; j < cmp->spp ; j++) { double *p = (double *)(cmp->buffp[j]); double *end = p + cmp->nx * cmp->ny * cmp->nz; while (p < end) { *p = swap8(*p); p++; } } break; default: errprintf("Image received from socket with invalid pixel type"); break; } } myheader->needswap = false; // we only need to do this once } } int readSocket(const char *ident, int index) { int res = 0; IMAGE_HEADER *myheader; dbgprintf("Read socket called\n"); // find the corresponding data received through the socket myheader = IOBlackBox->findHeader(ident); if (myheader == 0) { errprintf("Header not found\n"); res = 2; } else if (myheader->rawdata == 0) { errprintf("No data attached to header\n"); res = 3; } else if ((index < 0) || (index >= myheader->nbc)) { errprintf("Component number out of range\n"); res = 4; } else { dbgprintf("Header id: %d\n", myheader->unique_id); // set the current buffer as untouchable IOBlackBox->setCurrBuffp((myheader->comp[index]).buffp, true); IOBlackBox->setCurrImgWidth((myheader->comp[index]).nx); IOBlackBox->setCurrImgHeight((myheader->comp[index]).ny); IOBlackBox->setCurrImgThickness((myheader->comp[index]).nz); IOBlackBox->setXOffset((myheader->comp[index]).ox); IOBlackBox->setYOffset((myheader->comp[index]).oy); IOBlackBox->setZOffset((myheader->comp[index]).oz); IOBlackBox->setCurrZPos(0); // first plane IOBlackBox->setCurrImgType((myheader->comp[index]).imgt); IOBlackBox->setCurrPixType((myheader->comp[index]).pixt); IOBlackBox->setCurrImgNbComps(myheader->nbc); IOBlackBox->setCurrImgNbSamples((myheader->comp[index]).spp); IOBlackBox->setImgDesc("SOCKET"); // swap byte ordering if needed byteSwap(myheader); } return res; } int readSocketOverlay(const char *name) { int res = 0; IMAGE_HEADER *myheader; dbgprintf("Read overlay from socket called\n"); // find the corresponding data received through the socket myheader = IOBlackBox->findHeader(name); if (myheader == 0) { errprintf("Header not found\n"); res = 2; } else if (myheader->rawdata == 0) { errprintf("No data attached to header\n"); res = 3; } else { dbgprintf("Header id: %d\n", myheader->unique_id); // // set the current buffer as untouchable // IOBlackBox->setCurrBuffp((myheader->comp[index]).buffp, true); // IOBlackBox->setCurrImgWidth((myheader->comp[index]).nx); // IOBlackBox->setCurrImgHeight((myheader->comp[index]).ny); // IOBlackBox->setCurrImgThickness((myheader->comp[index]).nz); // IOBlackBox->setXOffset((myheader->comp[index]).ox); // IOBlackBox->setYOffset((myheader->comp[index]).oy); // IOBlackBox->setZOffset((myheader->comp[index]).oz); // IOBlackBox->setCurrZPos(0); // first plane // IOBlackBox->setCurrImgType((myheader->comp[index]).imgt); // IOBlackBox->setCurrPixType((myheader->comp[index]).pixt); // IOBlackBox->setCurrImgNbComps(myheader->nbc); // IOBlackBox->setCurrImgNbSamples((myheader->comp[index]).spp); // IOBlackBox->setImgDesc("SOCKET"); void *p = (myheader->comp[0]).buffp; int start[3], end[3]; // swap byte ordering if needed byteSwap(myheader); start[0] = (myheader->comp[0]).ox; end[0] = start[0] + (myheader->comp[0]).nx - 1; start[1] = (myheader->comp[0]).oy; end[1] = start[1] + (myheader->comp[0]).ny - 1; start[2] = (myheader->comp[0]).oz; end[2] = start[2] + (myheader->comp[0]).nz - 1; res = IOBlackBox->renderOverlay(name, p, myheader->nbc, start, end, (myheader->comp[0]).pixt); // DONT free these buffers. Only when the overlay // is closed or when another image by the same name is uploaded. } return res; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readsocket.hxx���������������������������������������������������������������������0000644�0000765�0000765�00000004601�07653237124�017271� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readsocket.hxx,v 4.0 2003/04/28 14:44:36 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * * readsocket.H * * Interface from the GUI to the socket I/O. The GUI cannot access * socket I/O directly. By design it happens in a different thread, * and FLTK is not thread-safe. * * When socket I/O completes, a message is passed to the GUI to display * a new image. This image is made available through calls declared in * this file. * * Hugues Talbot 8 Mar 2000 * *-----------------------------------------------------------------------*/ #ifndef READSOCKET_H #define READSOCKET_H // bacically this looks `exactly' like normal file I/O. int socketnbcomp(const char *ident); int readSocket(const char *ident, int index); int readSocketOverlay(const char *name); #endif // READSOCKET_H �������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readtiff.cxx�����������������������������������������������������������������������0000644�0000765�0000765�00000014573�10054565124�016726� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readtiff.cxx,v 4.2 2004/05/25 06:40:20 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Decodes the TIFF format. * Should be able to read any data format. Will deal with non-char * data * * Based on `loadtiff.c' by the same author * * Hugues Talbot 10 Jan 1998 * *-----------------------------------------------------------------------*/ #include "imview.hxx" #ifdef HAVE_TIFF #include <stdio.h> #include <stdlib.h> #include <tiffio.h> #include <stdarg.h> #include "imageIO.hxx" #include "readtiff.hxx" extern imageIO *IOBlackBox; // we need to retain this information from one call to the next static bool handlersInPlace = false; // // these are the handlers for TIFF Warnings void imviewTiffWarningHandler(const char *module, const char *fmt, va_list ap); void imviewTiffErrorHandler(const char *module, const char *fmt, va_list ap); int readTiffImage(const char *name, int imageindex) { void *p; int res, start[3], end[3]; int impi, imsf, imspp, imbps; imgtype theimgtype; pixtype thepixtype; unsigned short *cmap[3]; long nbcolours; if (!handlersInPlace) { TIFFSetErrorHandler(imviewTiffErrorHandler); TIFFSetWarningHandler(imviewTiffWarningHandler); handlersInPlace = true; } // call the low-level TIFF reader res = load_tiff(name, imageindex, start, end, &impi, &imsf, &imspp, &imbps, cmap, &nbcolours, &p); if (res == 0) { // all went well // now reprocess that according to content if ((res = getTiffType(impi, imsf, imspp, imbps, &thepixtype, &theimgtype)) == 0) { // the new buffer needs to be set first before // the dimensions are changed because the previous buffer // might be freed, and we will need its dimensions. IOBlackBox->setCurrBuffp((void **)p); IOBlackBox->setCurrImgWidth(end[0]-start[0]+1); IOBlackBox->setCurrImgHeight(end[1]-start[1]+1); IOBlackBox->setCurrImgThickness(end[2]-start[2]+1); IOBlackBox->setXOffset(start[0]); IOBlackBox->setYOffset(start[1]); IOBlackBox->setZOffset(start[2]); IOBlackBox->setCurrImgType((imgtype)theimgtype); IOBlackBox->setCurrPixType((pixtype)thepixtype); IOBlackBox->setCurrImgNbComps(1); // TIFF supports multiple image in a single file, but we read them here as a time series IOBlackBox->setCurrImgNbSamples(imspp); IOBlackBox->setCurrImgColourMap(cmap); IOBlackBox->setCurrImgNbColours(nbcolours); IOBlackBox->setImgDesc("TIFF"); } } return res; } // // read and render in an 8-bit buffer // int readTiffOverlay(const char *name) { void *p; int res, start[3], end[3]; int impi, imsf, imspp, imbps; unsigned short *cmap[3]; long nbcolours; imgtype theimgtype; pixtype thepixtype; // call the low-level TIFF reader res = load_tiff(name, 0, start, end, &impi, &imsf, &imspp, &imbps, cmap, &nbcolours, &p); if (res == 0) { if ((res = getTiffType(impi, imsf, imspp, imbps, &thepixtype, &theimgtype)) == 0) { // image that has just been read should have the same dimensions // as the image currently displayed. res = IOBlackBox->renderOverlay(name, p, imspp, start, end, thepixtype); IOBlackBox->freeRawBuffers(p, imspp); } } return res; } #define LIARerror errprintf #define LIARdebug dbgprintf // this functions walks the TIFF files and counts // the number of subfiles. // returns a positive number if file is OK and has // at least one subfile, // and a negative number in case of error int tiffnbsubfiles(const char *fname) { TIFF *tif; int imageindex = 0; if ((tif = TIFFOpen(fname, "r")) == NULL) { LIARerror("Cannot open file %s", fname); return(-1); } while (TIFFSetDirectory(tif, imageindex)) imageindex++; TIFFClose(tif); return imageindex; } void imviewTiffWarningHandler(const char *module, const char *fmt, va_list ap) { char buff[1024], newfmt[200]; if (module) { sprintf(newfmt, "%s: %s", module, fmt); vsprintf(buff, newfmt, ap); warnprintf(buff); } else { vsprintf(buff, fmt, ap); warnprintf(buff); } return; } void imviewTiffErrorHandler(const char *module, const char *fmt, va_list ap) { char buff[1024], newfmt[200]; if (module) { sprintf(newfmt, "%s: %s", module, fmt); vsprintf(buff, newfmt, ap); errprintf(buff); } else { vsprintf(buff, fmt, ap); errprintf(buff); } return; } #include "loadtiff-code.h" #else // HAVE_TIFF // stubs int readTiffImage(const char *, int) { errprintf("This version of Imview cannot read TIFF images\n"); return 1; } int tiffnbsubfiles(const char *) { return 0; } // // read and render in an 8-bit buffer // int readTiffOverlay(const char *) { return 0; } #endif �������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readtiff.hxx�����������������������������������������������������������������������0000644�0000765�0000765�00000004401�07653237125�016730� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readtiff.hxx,v 4.0 2003/04/28 14:44:37 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * readtiff.H * * Decodes the TIFF format * * *-----------------------------------------------------------------------*/ #ifndef READTIFF_H #define READTIFF_H int readTiffImage(const char *name, int whichComponent = 0); // a TIFF file may have more that one image in it. int readTiffOverlay(const char *name); int tiffnbsubfiles(const char *fname); #ifdef HAVE_TIFF #include "loadtiff.h" void imviewTiffWarningHandler(char *module, char *fmt, va_list ap); void imviewTiffErrorHandler(char *module, char *fmt, va_list ap); #endif #endif // defined(READTIFF_H) ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readZimage.cxx���������������������������������������������������������������������0000644�0000765�0000765�00000064234�10720351523�017205� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readZimage.cxx,v 4.2 2007/11/19 18:17:55 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Z-image reader. * * Based on the Z-image reader for XV by the same author * * Hugues Talbot 14 Jan 1998 * *-----------------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <errno.h> #include "imview.hxx" #include "imSystem.hxx" #include "../imageIO.hxx" #include "readZimage.hxx" #include "../machine.hxx" extern imageIO *IOBlackBox; /* prototypes for static functions */ static void *readCHARZimage(FILE *fp, int nx, int ny, int nz); static void *readINTZimage(FILE *fp, int nx, int ny, int nz, endianness e); static void *readDOUBLEZimage(FILE *fp, int nx, int ny, int nz, endianness e); static int needswapint(int *buf, long buflen); static int swapint(int i); static int needswapdouble(double *buf, long buflen); static double swapdouble(double i); // the `arithmetic exception' signal handler static void arithExceptHandler(int sig); // portable longjump buffer im_jmp_buf AEenv; int readZImage(const char *fname, int imageindex) { int res, start[3], end[3]; int thepixtype, theimgtype, spp, nbcomp; void *buffp; // call the low-level Z-IMAGE reader res = load_zimage(fname, imageindex, start, end, &thepixtype, &theimgtype, &spp, &nbcomp, &buffp); if (res == 0) { // all went well // the new buffer needs to be set first before // the dimensions are changed because the previous buffer // might be freed, and we will need its dimensions. IOBlackBox->setCurrBuffp((void **)buffp); IOBlackBox->setCurrImgWidth(end[0]-start[0]+1); IOBlackBox->setCurrImgHeight(end[1]-start[1]+1); IOBlackBox->setCurrImgThickness(end[2]-start[2]+1); IOBlackBox->setXOffset(start[0]); IOBlackBox->setYOffset(start[1]); IOBlackBox->setZOffset(start[2]); IOBlackBox->setCurrZPos(0); // first plane IOBlackBox->setCurrImgType((imgtype)theimgtype); IOBlackBox->setCurrPixType((pixtype)thepixtype); IOBlackBox->setCurrImgNbComps(nbcomp); // Z-IMAGE supports multiple independent images in a single file IOBlackBox->setCurrImgNbSamples(spp); IOBlackBox->setImgDesc("Z-IMAGE"); } return res; } int readZOverlay(const char *fname) { void *p; int res, start[3], end[3]; int thepixtype, theimgtype, imspp, nbcomp; // call the low-level Z-IMAGE reader res = load_zimage(fname, 0, start, end, &thepixtype, &theimgtype, &imspp, &nbcomp, &p); if (res == 0) { res = IOBlackBox->renderOverlay(fname, p, imspp, start, end, (pixtype)thepixtype); IOBlackBox->freeRawBuffers(p, imspp); } return res; } // This function returns the number of frames // in a Z-IMAGE file. See description of load_zimage // to understand what a `frame' is in the context // of Z-IMAGE. This is in general NOT returning the number // or components in the image, but rather the // number of image `groups', or number of multicomponent sets. // returns a negative number in case of error. int zimagenbsubfiles(const char *fname) { FILE *fp; int nbread, Zversion, firstcomp; int *firstR, *lastR, *firstC, *lastC, *firstP, *lastP, *imKind; int i, n, nbim; long filesize; char alias[12], kind[10]; fp = im_fopen(fname, "rb"); if (!fp) { dbgprintf("zimagenbsubfiles: cannot read file %s\n", fname); return -1; } /* compute file length */ fseek(fp, 0L, SEEK_END); filesize = ftell(fp); fseek(fp, 0L, SEEK_SET); /* read the Header now */ nbread = fscanf(fp, "CSIROZ version %d\n", &Zversion); if (nbread != 1) { errprintf("zimagenbsubfiles: faulty Z-IMAGE format %s\n", fname); return(-2); } /* read the number of images in the file */ if ((nbread = fscanf(fp, "%d\n", &nbim)) != 1) { errprintf("zimagenbsubfiles: can't read nb of components in %s\n", fname); return(3); } /* now read all the data in the headers */ firstR = new int[nbim]; lastR = new int[nbim]; firstC = new int[nbim]; lastC = new int[nbim]; firstP = new int[nbim]; lastP = new int[nbim]; imKind = new int[nbim]; /* read component images */ for (i = 0 ; i < nbim ; i++) { if ((nbread = fscanf(fp, "%d %s %d %d %d %d ", &n, alias, firstR+i, lastR+i, firstC+i, lastC+i )) != 6) { delete[] firstR; delete[] lastR; delete[] firstC; delete[] lastC; delete[] firstP; delete[] lastP; delete[] imKind; errprintf("zimagenbsubfiles: error in first part of image header for component %d, file %s\n", i,fname); return(-4); } else { /* now try to decide whether this is a 3D image */ if ((nbread = fscanf(fp, "%d %d %s\n", firstP+i, lastP+i, kind)) != 3) { /* this is not a 3D image, try again */ firstP[i] = 0; lastP[i] = 0; if ((nbread = fscanf(fp, "%s\n", kind)) != 1) { /* now this is an error */ delete[] firstR; delete[] lastR; delete[] firstC; delete[] lastC; delete[] firstP; delete[] lastP; delete[] imKind; errprintf("zimagenbsubfiles: error in second part of image header for component %d, file %s\n", i, fname); return(-5); } } if (strcmp(kind, "BINARY") == 0) imKind[i] = IM_BINARY; else if ((strcmp(kind, "CHAR") == 0) || (strcmp(kind, "GREY") == 0)) imKind[i] = IM_UINT1; // UNSIGNED char is the default! else if (strcmp(kind, "INT") == 0) imKind[i] = IM_INT; else if (strcmp(kind, "DOUBLE") == 0) imKind[i] = IM_DOUBLE; else { delete[] firstR; delete[] lastR; delete[] firstC; delete[] lastC; delete[] firstP; delete[] lastP; delete[] imKind; errprintf("zimagenbsubfiles: broken header for component %d, file %s\n", i, fname); return(-6); } } } int tmpindex = 0, imageindex = 0; i = 1; do { firstcomp = tmpindex; while (i < nbim) { if (imKind[tmpindex] != imKind[i]) break; if ((lastR[i] != lastR[tmpindex]) || (lastC[i] != lastC[tmpindex]) || (lastP[i] != lastP[tmpindex])) break; if ((firstR[i] != firstR[tmpindex]) || (firstC[i] != firstC[tmpindex]) || (firstP[i] != firstP[tmpindex])) break; i++; } tmpindex = i; imageindex++; } while (i < nbim); // cleanup fclose(fp); delete[] firstR; delete[] lastR; delete[] firstC; delete[] lastC; delete[] firstP; delete[] lastP; delete[] imKind; return imageindex; } int load_zimage(const char *fname, /* input file name */ int imageindex, /* index in the image file */ int start[3], /* coordinates of the starting point */ int end[3], /* coordinates of the end point */ int *thepixtype, /* pixel type (BINARY, CHAR, etc) */ int *theimgtype, /* image type (MULTI, RGB, etc) */ int *spp, /* samples per pixels (read number of components) */ int *nbcomp, /* total number of components in file, including unread ones */ void **inbuffp) /* pixel data (will be allocated) */ { /** Reads a multispectral Z-IMAGE file format RETURN VALUE: int DESCRIPTION: This function reads a Z-IMAGE file and returns a multispectral image in a series of buffers. The difficulties with Z-IMAGE is that the format does not indicate either the bit ordering or the image interpretation (RGB, etc). What this function does is try to work out both of these with the following strategy (heuristics): 1) guess the bit ordering for INT and DOUBLE by finding out which is yielding the smallest range 2) guess the photometric interpretation by reading the header information and collating together all the sub-images which have the same x,y and z dimensions, and the same offsets. If there are 3 such images, the image is deemed RGB, if there are more than one (but not 3), it is deemed a MULTISPECTRAL image, if there is only one such image, it is deemed a SINGLE component image. If there are more components after the last one that has been interpreted as being part of a multispectral image, they are just ignored. It is possible to read all the sub-images in a file by specifying an image index `n' greater than 0. The caller will get the nth multispectral set. HISTORY: Written by Hugues Talbot 19 Jan 1998 TESTS: REFERENCES: KEYWORDS: **/ FILE *fp; char alias[12], kind[10], marker; int res = 0; int i, nbim, n, firstcomp, lastcomp, nbread, Zversion; long filesize; int *firstR, *lastR, *firstC, *lastC, *firstP, *lastP; int *imKind; void **buffp = 0; int nx, ny, nz; long offs = 0; endianness e; fp = im_fopen(fname, "rb"); if (!fp) { dbgprintf("load_zimage: cannot read file %s\n", fname); return 1; } /* compute file length */ fseek(fp, 0L, SEEK_END); filesize = ftell(fp); fseek(fp, 0L, SEEK_SET); /* read the Header now */ nbread = fscanf(fp, "CSIROZ version %d\n", &Zversion); dbgprintf("CSIRO Z version %d\n", Zversion); if (nbread != 1) { errprintf("load_zimage: faulty Z-IMAGE format %s\n", fname); return(2); } /* read the number of images in the file */ if ((nbread = fscanf(fp, "%d\n", &nbim)) != 1) { errprintf("load_zimage: can't read nb of components in %s\n", fname); return(3); } /* now read all the data in the headers */ firstR = new int[nbim]; lastR = new int[nbim]; firstC = new int[nbim]; lastC = new int[nbim]; firstP = new int[nbim]; lastP = new int[nbim]; imKind = new int[nbim]; /* read component images */ for (i = 0 ; i < nbim ; i++) { if ((nbread = fscanf(fp, "%d %s %d %d %d %d ", &n, alias, firstR+i, lastR+i, firstC+i, lastC+i )) != 6) { delete[] firstR; delete[] lastR; delete[] firstC; delete[] lastC; delete[] firstP; delete[] lastP; delete[] imKind; errprintf("load_zimage: error in first part of image header for component %d, file %s\n", i,fname); return(4); } else { /* now try to decide whether this is a 3D image */ if ((nbread = fscanf(fp, "%d %d %s\n", firstP+i, lastP+i, kind)) != 3) { /* this is not a 3D image, try again */ firstP[i] = 0; lastP[i] = 0; if ((nbread = fscanf(fp, "%s\n", kind)) != 1) { /* now this is an error */ delete[] firstR; delete[] lastR; delete[] firstC; delete[] lastC; delete[] firstP; delete[] lastP; delete[] imKind; errprintf("load_zimage: error in second part of image header for component %d, file %s\n", i, fname); return(5); } } if (strcmp(kind, "BINARY") == 0) imKind[i] = IM_BINARY; else if ((strcmp(kind, "CHAR") == 0) || (strcmp(kind, "GREY") == 0)) imKind[i] = IM_UINT1; // Unsigned char is the default! else if (strcmp(kind, "INT") == 0) imKind[i] = IM_INT; else if (strcmp(kind, "DOUBLE") == 0) imKind[i] = IM_DOUBLE; else { delete[] firstR; delete[] lastR; delete[] firstC; delete[] lastC; delete[] firstP; delete[] lastP; delete[] imKind; errprintf("load_zimage: broken header for component %d, file %s\n", i, fname); return(6); } } } // endianness issue if (Zversion > 5) { if (strncmp(alias, "\"(null)\"", 8) == 0) { dbgprintf("File advertises little-endian data\n"); e = ENDIAN_LITTLE; } else { dbgprintf("File advertises big-endian data\n"); e = ENDIAN_BIG; } } else { dbgprintf("Z version too old, unknown data endianness\n"); e = ENDIAN_UNKNOWN; } /* now work out what to do */ if (imageindex >= nbim) { dbgprintf("load_zimage: required image index greater than number of components: %d >= %d\n", imageindex, nbim); imageindex = 0; } int tmpindex = 0; i = 1; *nbcomp = 0; do { firstcomp = tmpindex; while (i < nbim) { if (imKind[tmpindex] != imKind[i]) break; if ((lastR[i] != lastR[tmpindex]) || (lastC[i] != lastC[tmpindex]) || (lastP[i] != lastP[tmpindex])) break; if ((firstR[i] != firstR[tmpindex]) || (firstC[i] != firstC[tmpindex]) || (firstP[i] != firstP[tmpindex])) break; i++; } (*nbcomp)++; tmpindex = i; } while ((imageindex-- > 0) && (i < nbim)); if ((imageindex != -1) && (i==nbim)) { // caller asked for a component beyond the end of the file // this is legitimate! just an error code reported // cleanup fclose(fp); delete[] firstR; delete[] lastR; delete[] firstC; delete[] lastC; delete[] firstP; delete[] lastP; delete[] imKind; *inbuffp = 0; return(7); } lastcomp = i-1; *spp = lastcomp-firstcomp+1; // this is the real number of samples per pixel *thepixtype = imKind[firstcomp]; if (*spp == 3) *theimgtype = IM_RGB; // could be IM_HLS, but there is no way of knowing else *theimgtype = IM_SPECTRUM; // this includes single-component images start[1] = firstR[firstcomp]; end[1] = lastR[firstcomp]; start[0] = firstC[firstcomp]; end[0] = lastC[firstcomp]; start[2] = firstP[firstcomp]; end[2] = lastP[firstcomp]; nx = end[0] - start[0] +1; ny = end[1] - start[1] +1; nz = end[2] - start[2] +1; // start reading the data // we must skip over the nth first components, // which are of no interest to us... dbgprintf("Position in Z file: %ld\n", ftell(fp)); // apparently Win32 eats the 0 by itself. This is weird // but first we have to jump over this nasty '\0' if ((marker = skipzero(fp)) != '\0') { errprintf("load_zimage: wrong first data byte in file: got %d\n", marker); return 8; } dbgprintf("Position in Z file after eating '\\0': %ld\n", ftell(fp)); for (i = 0 ; i < firstcomp ; i++) { int nnx = lastR[i] - firstR[i] + 1; int nny = lastC[i] - firstC[i] + 1; int nnz = lastP[i] - firstP[i] + 1; switch(imKind[i]) { case IM_BINARY: case IM_CHAR: case IM_UINT1: offs = nnx*nny*nnz*sizeof(char); break; case IM_UINT4: case IM_INT4: offs = nnx*nny*nnz*sizeof(int); break; case IM_DOUBLE: offs = nnx*nny*nnz*sizeof(double); break; default: offs = 0; break; } if ((res = fseek(fp, offs, SEEK_CUR)) != 0) { errprintf("Can't jump over unwanted components\n%s", strerror(errno)); // cleanup fclose(fp); delete[] firstR; delete[] lastR; delete[] firstC; delete[] lastC; delete[] firstP; delete[] lastP; delete[] imKind; *inbuffp = 0; return(9); } } dbgprintf("Position in Z file after skipping unwanted components: %ld\n", ftell(fp)); dbgprintf("Should have skipped %ld bytes\n", offs); buffp = (void **) malloc(*spp * sizeof(void **)); for (i = firstcomp ; i <= lastcomp ; i++) { switch (*thepixtype) { case IM_BINARY: case IM_UINT1: case IM_INT1: buffp[i-firstcomp] = readCHARZimage(fp, nx, ny, nz); break; case IM_UINT4: case IM_INT4: buffp[i-firstcomp] = readINTZimage(fp, nx, ny, nz, e); break; case IM_DOUBLE: buffp[i-firstcomp] = readDOUBLEZimage(fp, nx, ny, nz, e); break; default: errprintf("load_zimage: type %d reader not implemented yet\n", *thepixtype); break; } if (buffp[i-firstcomp] == 0) { // an error occured for (int j = firstcomp ; j < i ; j++) free(buffp[i-firstcomp]); free(buffp); buffp = 0; res = 10; } } // cleanup fclose(fp); delete[] firstR; delete[] lastR; delete[] firstC; delete[] lastC; delete[] firstP; delete[] lastP; delete[] imKind; *inbuffp = buffp; return res; } static void *readCHARZimage(FILE *fp, int nx, int ny, int nz) { uchar *retbuf; long imlength, nbread; imlength = nx*ny*nz; retbuf = (uchar *)malloc(nx*ny*nz * sizeof(uchar)); // stupid malloc, to be compatible with the TIFF reader if (retbuf == 0) { errprintf("readCHARZimage: not enough memory to load file\n"); return 0; } nbread = fread(retbuf, sizeof(uchar), imlength, fp); if (nbread != imlength) { errprintf("load_zimage: incomplete image\n"); // this is only a warning, complete with zeroes memset(retbuf+nbread, 0, (imlength-nbread)*sizeof(uchar)); } return retbuf; } // this is not as easy because of the big-endian vs. little-endian stuff static void *readINTZimage(FILE *fp, int nx, int ny, int nz, endianness e) { int *retbuf; long imlength, nbread; imlength = nx*ny*nz; retbuf = (int *)malloc(nx*ny*nz * sizeof(int)); // stupid malloc, to be compatible with the TIFF reader if (retbuf == 0) { errprintf("readINTZimage: not enough memory to load file\n"); return 0; } nbread = fread(retbuf, sizeof(int), imlength, fp); if (nbread != imlength) { errprintf("load_zimage: incomplete image\n"); // this is only a warning, complete with zeroes memset(retbuf+nbread, 0, (imlength-nbread)*sizeof(int)); } if (((e != ENDIAN_UNKNOWN) && (e != checkendian())) || ((e == ENDIAN_UNKNOWN) && (needswapint(retbuf, imlength)))) { dbgprintf("Image buffer will be swapped\n"); swapintbuf(retbuf, imlength); // in-place processing } else dbgprintf("Image buffer will not be swapped\n"); return retbuf; } // this is not as easy because of the big-endian vs. little-endian stuff static void *readDOUBLEZimage(FILE *fp,int nx, int ny, int nz, endianness e) { double *retbuf; int ns; long imlength, nbread; imlength = nx*ny*nz; retbuf = (double *)malloc(nx*ny*nz * sizeof(double)); // stupid malloc, to be compatible with the TIFF reader if (retbuf == 0) { errprintf("readDOUBLEZimage: not enough memory to load file\n"); return 0; } nbread = fread(retbuf, sizeof(double), imlength, fp); if (nbread != imlength) { errprintf("readDOUBLEZimage: incomplete image\n"); // this is only a warning, complete with zeroes memset(retbuf+nbread, 0, (imlength-nbread)*sizeof(double)); } ns = 2; if (((e != ENDIAN_UNKNOWN) && (e != checkendian())) || ((e == ENDIAN_UNKNOWN) && ((ns = needswapdouble(retbuf, imlength)) == 1))) { dbgprintf("Image buffer will be swapped\n"); swapdoublebuf(retbuf, imlength); // in-place processing } else if (ns == -1) { /* if needswapdouble was called but caused SIGFPE on both swapped and unswapped versions */ errprintf("readDoubleZImage: cannot make sense of image\n because of invalid double precision values present\n"); free(retbuf); retbuf = 0; } else { dbgprintf("Image buffer will not be swapped\n"); } return retbuf; } static int needswapint(int *buf, long buflen) { int *p, swp, *end, minval, maxval; int swminval, swmaxval; unsigned int range, swrange; int sample = trivmin((buflen/503 + 1), 997); // largish prime number p = buf; end = buf+buflen; minval = maxval = *p; // try the unswapped version while (p < end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p += sample; // no need to sample all the pixels... } range = maxval - minval; dbgprintf("needswapint: unswapped range = %u\n", range); // now do the same thing with swap on p = buf; swmaxval = swminval = swapint(*p); while (p < end) { swp = swapint(*p); if (swp > swmaxval) swmaxval = swp; if (swp < swminval) swminval = swp; p += sample; // no need to sample all the pixels... } swrange = swmaxval - swminval; dbgprintf("needswapint: swapped range = %u\n", swrange); if ((swrange == 0) && (range == 0)) return 0; // we don't know so we don't swap else if (swrange < range) return 1; // yes, need swapping! else if ((swrange == range) && (swmaxval < maxval)) return 1 ; // yes: still need swapping else return 0; // no need to swap } static void arithExceptHandler(int sig) { // reset the signal handler signal(sig, arithExceptHandler); im_longjmp(AEenv, 1); } // log are used in there otherwise FP exception // might be raised when comparing extreme numbers // that would only be possible with loss of precision // I.e: comparing 10^-300 and 10^+300 typedef void (signalHandler)(int); static int needswapdouble(double *buf, long buflen) { volatile void *vp; double *p, lp, swp, lswp, *end, minval, maxval; vp = &p; vp = &lp; vp = &swp; vp = &lswp; vp= &end; vp = &minval; vp = &maxval; double swminval, swmaxval; vp = &swminval; vp = &swmaxval; double range, swrange; vp = &range ; vp = &swrange; int sample = trivmin((buflen/503 + 1),997); vp = &sample;// largish prime number bool raisedWhenSwapped, raisedWhenNotSwapped; vp = &raisedWhenSwapped; vp = &raisedWhenNotSwapped; int retval = 0; vp = &retval; p = buf; end = buf+buflen; signalHandler *oldHandler = signal(SIGFPE, arithExceptHandler); if (oldHandler == SIG_ERR) { errprintf("needswapdouble: Could not set up FP exception handler.\n"); // continue anyway! } if (im_setjmp(AEenv, 1) == 0) { // try the unswapped version minval = maxval = 0; // look for first non-null pixel, if any while (p < end) { if (*p != 0.0) { lp = log(fabs(*p)); if ((lp > 1000) || (lp < -1000)) { p += sample; continue; } /* first value found */ minval = maxval = *p; break; } ++p; } while (p < end) { //skip the zeroes if (*p != 0.0) { lp = log(fabs(*p)); if ((lp > 1000) || (lp < -1000)) { p += sample; continue; } if (lp > maxval) maxval = lp; if (lp < minval) minval = lp; } p += sample; // no need to sample all the pixels... } range = maxval - minval; dbgprintf("needswapdouble: unswapped log range = %g\n", range); raisedWhenNotSwapped = false; } else { // we got there because of an exception: raisedWhenNotSwapped = true; } // now do the same thing with swap on p = buf; swmaxval = swminval = 0; if (im_setjmp(AEenv, 1) == 0) { // look for first non-null pixel, if any while (p < end) { swp = swapdouble(*p); if (swp != 0.0) { lswp = log(fabs(swp)); if ((lswp > 1000) || (lswp < -1000)) { p += sample; continue; } /* first value found */ minval = maxval = lswp; break; } ++p; } while (p < end) { swp = swapdouble(*p); // skip over the zeroes if (swp != 0.0) { lswp = log(fabs(swp)); if ((lswp > 1000) || (lswp < -1000)) { p += sample; continue; } if (lswp > swmaxval) swmaxval = lswp; if (lswp < swminval) swminval = lswp; } p += sample; // no need to sample all the pixels... } swrange = swmaxval - swminval; dbgprintf("needswapdouble: swapped log range = %g\n", swrange); raisedWhenSwapped = false; } else { raisedWhenSwapped = true; } // reset the FPE handler to its previous state if (oldHandler != SIG_ERR) { if (signal(SIGFPE, oldHandler) == SIG_ERR) { errprintf("needswapdouble: Could not restore original FP exception handler\n"); //continue anyway! } } if (raisedWhenSwapped && raisedWhenNotSwapped) retval = -1; // this image is basically unreadable else if (raisedWhenSwapped) retval = 0; // do not swap else if (raisedWhenNotSwapped) retval = 1; // do swap, then else if (swrange < range) retval = 1; // yes, need swapping! else if ((swrange == 0) && (range == 0)) retval = 0; // we have a constant value in the image, we don't swap because it could be anything else if ((swrange == range) && (swmaxval < maxval)) retval = 1 ; // yes: still need swapping else retval = 0; // no need to swap return retval; } static int swapint(int i) { uchar *from, *to; int j; from = (uchar *)&i; to = (uchar *)&j; to[0] = from[3]; to[1] = from[2]; to[2] = from[1]; to[3] = from[0]; // j = ((int)(p[0]) << 24) + // ((int)(p[1]) << 16) + // ((int)(p[2]) << 8) + // ((int)(p[3])); return j; } static double swapdouble(double d) { uchar *from, *to; double b; from = (uchar *)&d; to = (uchar *)&b; to[0] = from[7]; to[1] = from[6]; to[2] = from[5]; to[3] = from[4]; to[4] = from[3]; to[5] = from[2]; to[6] = from[1]; to[7] = from[0]; return b; } // no questions asked... // in-place processing void swapintbuf(int *buf, long buflen) { int *p, *end; dbgprintf("Swapping int buffer\n"); p = buf; end = p + buflen; while (p < end) { *p = swapint(*p); p++; } return; } void swapdoublebuf(double *buf, long buflen) { double *p, *end; dbgprintf("Swapping double buffer\n"); p = buf; end = p + buflen; while (p < end) { *p = swapdouble(*p); p++; } return; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/readZimage.hxx���������������������������������������������������������������������0000644�0000765�0000765�00000005051�10720351523�017202� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: readZimage.hxx,v 4.1 2007/11/19 18:17:55 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The Z-IMAGE image format reader. * * Hugues Talbot 14 Jan 1998 * *-----------------------------------------------------------------------*/ #ifndef READZIMAGE_H #define READZIMAGE_H #ifndef trivmin #define trivmin(x,y) ((x) > (y)) ? (y):(x) #endif int readZImage(const char *name, int whichComponent = 0); // a Zimage file may have more that one image in it. int readZOverlay(const char *name); int load_zimage(const char *fname, int imageindex, int start[3], int end[3], int *pixtype, int *imgtype, int *spp, int *nbcomp, void **inbuffp); int zimagenbsubfiles(const char *fname); // public global function (badbadbad) endianness checkendian(void); void swapintbuf(int *buf, long buflen); void swapdoublebuf(double *buf, long buflen); #endif // READZIMAGE_H ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/savetiff.cxx�����������������������������������������������������������������������0000644�0000765�0000765�00000030246�07653237125�016754� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: savetiff.cxx,v 4.0 2003/04/28 14:44:37 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------- * * SaveTiff - A function to write images using the TIFF * format. Supported compression schemes are * none (!), packbit and LZW for any image, * ccittg3 and ccittg4 for binary images. * * This program makes use of the TIFF * library by Sam.Leffler@Silicon_Graphics * based on a program for XLIM by Luc Vincent, * itself based on a program by Hugues Talbot (91). * Extended to RGB space. * * This function now allows subimages to be saved. * subimages are merely appended to an existing file. * Subimages in multi-subimage TIFF files must * therefore be written in order. * Unsupported compression default to no compression * * By Hugues Talbot 17 Jun 1997 * Based on Writetiff. Same author. * Modifications: Hugues Talbot 28 Apr 1998 * Slight changes to make it work with ImView * *-----------------------------------------------------------------------*/ #include "imview.hxx" // still needed even when TIFF is not compiled in char *comp_schemes[] = {"NONE", "LZW", "PACKBITS", "CCITTG3", "CCITTG4", "RLE", "RLEW", "THUNDER", "" }; #ifdef HAVE_TIFF #include <stdio.h> #include <stdlib.h> #include <tiffio.h> #include "savetiff.hxx" int setTifftype(int pixeltype, /* pixel type */ int imagetype, /* image type */ int *pi, /* photometric interpretation */ int *sf, /* sample format */ int *spp, /* samples per pixel (this parameter is I/O) */ int *bps) /* bits per sample */ { switch (pixeltype) { case IM_BINARY: *bps = 1; *sf = 2; break; case IM_INT1: *bps = 8; *sf = 1; // Should be 2, but we _never_ handle signed char. break; case IM_UINT1: *bps = 8; *sf = 1; break; case IM_INT2: *bps = 16; *sf = 2; break; case IM_UINT2: *bps = 16; *sf = 1; break; case IM_INT4: *bps = 32; *sf = 2; break; case IM_UINT4: *bps = 32; *sf = 1; break; case IM_FLOAT: *bps = 32; *sf = 3; break; case IM_DOUBLE: *bps = 64; *sf = 3; break; } /* the photometric interpretation */ if (*spp == 1 ) { if (pixeltype == IM_BINARY) *pi = 0; /* min is white */ else *pi = 1; /* min is black */ } /* number of component if not explicitely known */ if ((imagetype == IM_RGB) || (imagetype == IM_HLS)) { *spp = 3; *pi = 2; } /* *pi == 3 means CLUT */ /* *pi == 4 means Masked something ?? */ if ((*spp > 1) && (*pi != 2)) *pi = 5; /* basically, this means multispectral image */ /* 6 is CCIR */ /* 7 is not supported */ /* 8 is CIE L*a*b */ return 0; } int save_tiff(void **outbuffp, /* output buffer */ int imageindex, /* 0 = write, > 0 = append */ int start[2], /* dimension start */ int end[2], /* dimension end */ int pi, /* photometric interpretation */ int sf, /* storage format */ int spp, /* samples per pixels */ int bps, /* bits per pixel */ short colourmap[3], /* colour map (RGB) */ long ncolours, /* nb of colour in the LUT */ const char *fname, /* output file name */ int compression) /* compression scheme */ { TIFF *tif; uint32 rowsperstrip; int linebytes, sample; uint32 i, j; uint32 nbcols, nbrows; uint8 *theBufc, *pc; int16 *theBufs, *ps; int32 *theBufl, *pl; /* will serve for float and 32 bit ints */ double *theBufd, *pd; /* will serve for doubles and 64 bit ints */ int result=0; // this shuts gcc up. pc = 0; ps = 0; pl = 0; pd = 0; tif = 0; pc = 0; if (imageindex == 0) { if ((tif = TIFFOpen(fname, "w")) == 0) { errprintf("Tiff_save: couldn't open %s for writing", fname); result = 1; } /* the directory is set, we can start writing data to the TIFF file */ } else if (imageindex > 0) { if ((tif = TIFFOpen(fname, "a")) == 0) { errprintf("Tiff_save: couldn't open %s for appending", fname); result = 2; } /* I'm not quite sure that the above is sufficient. We'll test this */ } if (result == 0) { /* all is well, we can proceed */ /* write header information */ nbcols = end[0]-start[0]+1; nbrows = end[1]-start[1]+1; // indispensable stuff TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, nbcols); TIFFSetField(tif, TIFFTAG_IMAGELENGTH, nbrows); TIFFSetField(tif, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT); TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, (uint16)spp); TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, (uint16)bps); TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, (uint16)pi); // for some reason this is NOT optional! TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_SEPARATE); // optional stuff if ((start[0] != 0) ||(start[1] != 0) ) { TIFFSetField(tif, TIFFTAG_XPOSITION, (float)start[0]); TIFFSetField(tif, TIFFTAG_YPOSITION, (float)start[1]); } // we only output the sample format if bps > 8 // many tiff readers are put off by sf. if (bps > 8) TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, (uint16)sf); /* compression scheme */ switch (compression) { case TIFF_CMP_NONE: TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); break; case TIFF_CMP_LZW: TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW); break; case TIFF_CMP_PACKBITS: TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_PACKBITS); break; case TIFF_CMP_CCITTG3: if (bps == 1) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX3); else { errprintf("CCITT FAX Group 3 compression scheme applies only to BINARY images"); return(1); } break; case TIFF_CMP_CCITTG4: if (bps == 1) TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_CCITTFAX4); else { errprintf("CCITT FAX Group 4 compression scheme applies only to BINARY images"); return(1); } break; case TIFF_CMP_RLE: TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_CCITTRLE); break; case TIFF_CMP_RLEW: TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_CCITTRLEW); break; case TIFF_CMP_THUNDER: TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_THUNDERSCAN); break; default: errprintf("Unsupported compression, defaulting to no compression"); compression = 0; TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_NONE); break; } /* a little bit of black magic from ras2tiff.c */ linebytes = ((bps * nbcols + 15)>> 3) &~ 1; if (TIFFScanlineSize(tif) > linebytes) theBufc = (uint8 *)_TIFFmalloc(linebytes*sizeof(uint8)); else theBufc = (uint8 *)_TIFFmalloc(TIFFScanlineSize(tif)); rowsperstrip = (uint32) (8196/linebytes); TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, rowsperstrip == 0 ? (uint32)1 : rowsperstrip); if (compression != 0) { dbgprintf("TIFFwrite : Writing %d-bit, %d-component TIFF " "file %s: [%d]x[%d], pi=%d, sf=%d, \nwith %s compression\n", bps, spp, fname, nbcols, nbrows, pi, sf, comp_schemes[compression]); } else { dbgprintf("TIFFwrite : Writing %d-bit, %d-component TIFF " "file %s: [%d]x[%d], pi=%d, sf=%d, \nwith no compression\n", bps, spp, fname, nbcols, nbrows, pi, sf); } if (outbuffp != 0) { for (sample = 0 ; sample < spp ; sample++) { /* this switch sets up the input buffer according to type */ switch (bps) { case 1: case 8: pc = (uint8 *)outbuffp[sample]; break; case 16: ps = (int16 *)outbuffp[sample]; break; case 32: pl = (int32 *)outbuffp[sample]; break; case 64: pd = (double *)outbuffp[sample]; break; default: errprintf("save_tiff: unsupported bits per pixel size: %d", bps); result = 10; break; } /* we have to write the data to the buffer `theBufc' */ /* it has to be of the right size/format, hence the complication here */ for (i = 0 ; i < nbrows ; i++) { switch (bps) { case 1: for (j = 0 ; j < nbcols ; j++) { if (j%8 == 0) theBufc[j>>3] =0; if (!*pc++) // subtle change here: binary are displayed miniswhite theBufc[j>>3] |= 1 <<(7-j%8); } break; case 8: for (j = 0 ; j < nbcols ; j++) { theBufc[j] = (uint8) *pc++; } break; case 16: theBufs = (int16 *)theBufc; for (j = 0 ; j < nbcols ; j++) { theBufs[j] = (uint16) *ps++; } break; case 32: theBufl = (int32 *)theBufc; for (j = 0 ; j < nbcols ; j++) { theBufl[j] = (uint32) *pl++; } break; case 64: theBufd = (double *)theBufc; for (j = 0 ; j < nbcols ; j++) { theBufd[j] = (double) *pd++; } break; default: break; } if (TIFFWriteScanline(tif, theBufc, i, sample) < 0) { errprintf("Error writing line %d", i); result = 11; break; } } } } _TIFFfree(theBufc); TIFFClose(tif); } return result; } #else // HAVE_TIFF // stubs int setTifftype(int pixeltype, /* pixel type */ int imagetype, /* image type */ int *pi, /* photometric interpretation */ int *sf, /* sample format */ int *spp, /* samples per pixel (this parameter is I/O) */ int *bps) /* bits per sample */ { return 0; } int save_tiff(void **outbuffp, /* output buffer */ int imageindex, /* index to save to in the file being saved */ int start[2], /* dimension start */ int end[2], /* dimension end */ int pi, /* photometric interpretation */ int sf, /* storage format */ int spp, /* samples per pixels */ int bps, /* bits per pixel */ short colourmap[3], /* colour map (RGB) */ long ncolours, /* nb of colour in the LUT */ const char *fname, /* output file name */ int compression) /* compression scheme */ { errprintf("This version of Imview cannot save TIFF images\n"); return 1; } #endif // HAVE_TIFF ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/savetiff.hxx�����������������������������������������������������������������������0000644�0000765�0000765�00000006400�07653237125�016754� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: savetiff.hxx,v 4.0 2003/04/28 14:44:37 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The save tiff include file. * *-----------------------------------------------------------------------*/ #ifndef SAVETIFF_H #define SAVETIFF_H /* compression schemes */ enum { TIFF_CMP_NONE = 0, TIFF_CMP_LZW = 1, TIFF_CMP_PACKBITS = 2, // these 3 are for any format, the rest for binary only TIFF_CMP_CCITTG3 = 3, TIFF_CMP_CCITTG4 = 4, TIFF_CMP_RLE = 5, TIFF_CMP_RLEW = 6, TIFF_CMP_THUNDER = 7 }; /* prototypes */ int setTifftype(int pixeltype, /* pixel type */ int imagetype, /* image type */ int *pi, /* photometric interpretation */ int *sf, /* sample format */ int *spp, /* samples per pixel (this parameter is I/O) */ int *bps); /* bits per sample */ int save_tiff(void **outbuffp, /* output buffer */ int imageindex, /* index to save to in the file being saved */ int start[2], /* dimension start */ int end[2], /* dimension end */ int pi, /* photometric interpretation */ int sf, /* storage format */ int spp, /* samples per pixels */ int bps, /* bits per pixel */ short colourmap[3], /* colour map (RGB) */ long ncolours, /* nb of colour in the LUT */ const char *fname, /* output file name */ int compression); /* compression scheme */ /* here are the globals */ /* these are the names of the */ /* compression schemes */ #endif // SAVETIFF_H ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/saveZimage.cxx���������������������������������������������������������������������0000644�0000765�0000765�00000034502�07653237125�017237� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: saveZimage.cxx,v 4.0 2003/04/28 14:44:37 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Write a Z image file. * * Lousy format but useful nonetheless. * * By Stewart Heitmann, based on code by Hugues Talbot 17 Jan 1998 * Updated Hugues Talbot 29 Apr 1998 for ImView * Modified Hugues Talbot 3 Dec 2002 to handle type promotion * *-----------------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include "imview.hxx" #include "imSystem.hxx" #include "readZimage.hxx" const char HEADER3[]="CSIROZ version 3"; /* old header */ const char HEADER[]="CSIROZ version 5"; /* S-Z addition */ const char HEADER7[]="CSIROZ version 7"; /* endianness support */ #define LINESIZE 200 /* local functions */ static const char * zpixtypestr(int ptype); static int zpixsize(int ptype); static int zpixrealsize(int ptype); static int writeheader(FILE *fp, int n, int *nx, int *ny, int *nz, int *x0, int *y0, int *z0, int *ptype); static int writecomps(FILE *fp, int n, int *nx, int *ny, int *nz, int *ptype, void **pixbuff); static int promote_buffer(char *datain, int ptype, int nbpix, void **dataout); int save_zimage(const char *fname, /* input file name */ int numcomp, /* number of components */ int *nx, /* ptr to array of nx values (cols), one per component */ int *ny, /* ptr to array of ny values (rows), one per component */ int *nz, /* ptr to array of nz values (planes), one per component */ int *x0, /* ptr to array of x0 offsets, one per component */ int *y0, /* ptr to array of y0 offsets, one per component */ int *z0, /* ptr to array of z0 offsets, one per component */ int *ptype, /* ptr to array of pixel types, one per component */ void **pixbuff) /* ptr to array of pixel buffer pointers, one per component */ { /************************************************************ Saves a multicomponent image in Z-IMAGE file format RETURN VALUE: 0 upon success. 1 if file could not be created or written onto. DESCRIPTION: Saves the multi-component image described by the set of arrays nx[], ny[], nz[], x0[], y0[], z0[], ptype[], pixbuff[] into a Z-IMAGE file 'fname'. The user is responsible or creating the set of arrays. Consecutive elements in each array refers to consecutive components in the multi-component image. As such, all arrays must have the same number of elements; the user supplies this number in 'numcomp'. Components may be either 2D (ie:nz[i]=1) or 3D (ie:nz[i]>1). If any component is 3D then the Z-IMAGE file is automatically written using the version 5 Z-IMAGE file format necessary for 3D images, otherwise the version 3 Z-IMAGE file format is used. TESTS: REFERENCES: KEYWORDS: **************************************************************/ FILE *fp; /* open the image file for writing */ fp = im_fopen(fname, "wb"); if (!fp) return 1; /* write the header */ if( writeheader(fp,numcomp,nx,ny,nz,x0,y0,z0,ptype) != 0 ) { fclose(fp); return 1; } /* write the pixel data */ if( writecomps(fp,numcomp,nx,ny,nz,ptype,pixbuff) != 0 ) { fclose(fp); return 1; } fclose(fp); return 0; } /* local structures only */ struct Zpixcode { char *str; int code; int size; int realsize; }; /* handles promotion */ static struct Zpixcode Zpixtypes[] = { { "BINARY", IM_BINARY, sizeof(char), sizeof(char) }, /* IM_BINARY */ { "CHAR", IM_UINT1, sizeof(char), sizeof(char) }, /* IM_CHAR, IM_INT1 */ { "GREY", IM_INT1, sizeof(char), sizeof(char) }, { "INT", IM_INT2, sizeof(int), sizeof(short) }, { "INT", IM_UINT2, sizeof(int), sizeof(short) }, { "INT", IM_INT4, sizeof(int), sizeof(int) }, /* IM_INT4 */ { "INT", IM_UINT4, sizeof(int), sizeof(int) }, { "DOUBLE", IM_FLOAT, sizeof(double), sizeof(float) }, { "DOUBLE", IM_DOUBLE, sizeof(double), sizeof(double) } /* IM_DOUBLE */ }; static const char * zpixtypestr(int ptype) { /************************************************************ Returns ptr to a string corresponding to the Z-IMAGE pixel type code in 'ptype'. **************************************************************/ const int n = sizeof(Zpixtypes)/sizeof(struct Zpixcode); int i; for(i=0; i<n; i++) if(Zpixtypes[i].code == ptype) return(Zpixtypes[i].str); return(NULL); } static int zpixsize(int ptype) { /************************************************************ Returns number of bytes required to store a pixel with Z-IMAGE pixel type code 'ptype'. **************************************************************/ const int n = sizeof(Zpixtypes)/sizeof(struct Zpixcode); int i; for(i=0; i<n; i++) if(Zpixtypes[i].code == ptype) return(Zpixtypes[i].size); return 0; } static int zpixrealsize(int ptype) { /************************************************************ Returns number of bytes required to store a pixel with Z-IMAGE pixel type code 'ptype'. **************************************************************/ const int n = sizeof(Zpixtypes)/sizeof(struct Zpixcode); int i; for(i=0; i<n; i++) if(Zpixtypes[i].code == ptype) return(Zpixtypes[i].realsize); return 0; } static int maxdim(int n, int *nz) { /************************************************************ Scans the nz[] array for any values greater than 1. If one is found then returns 3 (for 3D) otherwise returns 2 for (2D) **************************************************************/ int i; for (i=0; i<n; i++) { if (nz[i]>1) return 3; } return 2; } static int writeheader(FILE *fp, int n, int *nx, int *ny, int *nz, int *x0, int *y0, int *z0, int *ptype) { /************************************************************ Writes a ZIMAGE header to the file fp according to the components given in the arrays nx[],ny[],nz[],etc. If any of the components is 3D then the image header is written using the version 5 ZIMAGE file format which supports 3D images. Otherwise the file is written using the version 3 file format which supports only 2D images. Components cannot be 4D. Note for version Z-7: we only write little-endian data, hence the keyword is always "(null)" returns 0 upon success. returns 1 if write failed. **************************************************************/ int i; if( maxdim(n,nz)==3 ) { /*-- write the version 5 header which supports 3D components --*/ if (fprintf(fp, "%s\n%d\n", HEADER7, n) < 0) { errprintf("saveZimage: Error writing first part of the header\n"); return 1; } for (i=0; i<n; i++) { const int firstR = y0[i]; const int lastR = y0[i] + ny[i] - 1; const int firstC = x0[i]; const int lastC = x0[i] + nx[i] - 1; const int firstP = z0[i]; const int lastP = z0[i] + nz[i] - 1; const char* ptypestr = zpixtypestr(ptype[i]); int res; res = fprintf(fp, "%d \"(null)\" %d %d %d %d %d %d %s\n", i, firstR,lastR,firstC,lastC,firstP,lastP,ptypestr); if (res<0) { errprintf("saveZimage: error writing header component %d\n", i); return 1; } } } else { /*-- write the version 3 header which supports 2D components only --*/ if (fprintf(fp, "%s\n%d\n", HEADER7, n) < 0) { errprintf("saveZimage: error writing first part of the header\n"); return 1; } for (i=0; i<n; i++) { const int firstR = y0[i]; const int lastR = y0[i] + ny[i] - 1; const int firstC = x0[i]; const int lastC = x0[i] + nx[i] - 1; const char* ptypestr = zpixtypestr(ptype[i]); int res; res = fprintf(fp, "%d \"(null)\" %d %d %d %d %s\n", i, firstR, lastR, firstC, lastC, ptypestr); if (res<0) { errprintf("saveZimage: error writing header component %d\n", i); return 1; } } } /*-- do the funny stuff that nobody can explain --*/ fprintf(fp, " "); fseek(fp, -2L, 1); putc('\0', fp); return 0; } /* promotes data into a static buffer */ static int promote_buffer(char *datain, int ptype, int nbpix, void **dataout) { static void *dataout_p = NULL; static int nbbytes = 0; int newsize, i, retval = 0; newsize = zpixsize(ptype) * nbpix; /* make sure we have enough room */ if (newsize != nbbytes) dataout_p = realloc(dataout_p, newsize); switch(ptype) { case IM_BINARY: case IM_INT1: case IM_UINT1: /* no promotion needed */ *dataout = datain; break; case IM_INT4: case IM_UINT4: /* no promotion needed */ *dataout = datain; if (checkendian() != ENDIAN_LITTLE) swapintbuf((int*)(*dataout), nbpix); break; case IM_DOUBLE: /* no promotion needed */ *dataout = datain; if (checkendian() != ENDIAN_LITTLE) swapdoublebuf((double*)(*dataout), nbpix); break; case IM_INT2: { short *in; int *out; /* promote short to int */ in = (short*)datain; out = (int*)dataout_p; /* straightforward copy */ for (i = 0 ; i < nbpix ; ++i) { *out++ = *in++; } *dataout = dataout_p; // further processing if (checkendian() != ENDIAN_LITTLE) swapintbuf((int*)(*dataout), nbpix); } break; case IM_UINT2: { unsigned short *in; int *out; /* promote short to int */ in = (unsigned short *)datain; out = (int *)dataout_p; /* straightforward copy */ for (i = 0 ; i < nbpix ; ++i) { *out++ = *in++; } *dataout = dataout_p; // further processing if (checkendian() != ENDIAN_LITTLE) swapintbuf((int*)(*dataout), nbpix); } break; case IM_FLOAT: { float *in; double *out; /* promote short to int */ in = (float *)datain; out = (double *)dataout_p; /* straightforward copy */ for (i = 0 ; i < nbpix ; ++i) { *out++ = *in++; } *dataout = dataout_p; if (checkendian() != ENDIAN_LITTLE) swapdoublebuf((double*)(*dataout), nbpix); } break; default: *dataout = NULL; retval = 1; break; } return retval; } static int writecomps(FILE *fp, int n, int *nx, int *ny, int *nz, int *ptype, void **pixbuff) { /************************************************************ Writes the pixel data buffers from each component to fp. The data is written one row at a time to be a bit gentler on the io buffer. returns 0 upon success. returns 1 if write failed. **************************************************************/ int i, nb; /*-- for each component ... --*/ for (i=0; i<n; i++) { const int pixsize = zpixsize(ptype[i]); const int realpixsize = zpixrealsize(ptype[i]); char *pbuff = (char *)(pixbuff[i]); void *prombuff = NULL; int row,plane; if (ptype[i] == IM_BINARY) { char *inverted = new char[nx[i]]; int k; /* binary images never need to be promoted */ for (plane=0; plane<nz[i]; plane++) for (row=0; row<ny[i]; row++) { for (k = 0 ; k < nx[i] ; k++) inverted[k] = !pbuff[k]; if( (nb=(int)(fwrite(inverted,pixsize,nx[i],fp))) != nx[i]) { errprintf("saveZimage: wrote %d bytes instead of expected %d\n" "row %, plane %d\n", nb, nx[i], row, plane); return 1; } pbuff += nx[i] * pixsize; } delete[] inverted; } else { for (plane=0; plane<nz[i]; plane++) for (row=0; row<ny[i]; row++) { if (promote_buffer(pbuff, ptype[i], nx[i], &prombuff) == 0) { if( (nb=(int)(fwrite(prombuff,pixsize,nx[i],fp))) != nx[i]) { errprintf("saveZimage: wrote %d bytes instead of expected %d\n" "row %, plane %d\n", nb, nx[i], row, plane); return 1; } } else { errprintf("saveZimage: buffer promotion failed\n"); return 2; } pbuff += nx[i] * realpixsize; } } } return 0; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/saveZimage.hxx���������������������������������������������������������������������0000644�0000765�0000765�00000005164�07653237125�017246� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: saveZimage.hxx,v 4.0 2003/04/28 14:44:37 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Header information for Zimage output code * * * *-----------------------------------------------------------------------*/ #ifndef SAVEZIMAGE_H #define SAVEZIMAGE_H int save_zimage(const char *fname, /* input file name */ int numcomp, /* number of components */ int *nx, /* ptr to array of nx values (cols), one per component */ int *ny, /* ptr to array of ny values (rows), one per component */ int *nz, /* ptr to array of nz values (planes), one per component */ int *x0, /* ptr to array of x0 offsets, one per component */ int *y0, /* ptr to array of y0 offsets, one per component */ int *z0, /* ptr to array of z0 offsets, one per component */ int *ptype, /* ptr to array of pixel types, one per component */ void **pixbuff); /* ptr to array of pixel buffer pointers, one per component */ #endif ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/writeMagick.cxx��������������������������������������������������������������������0000644�0000765�0000765�00000013541�10754360060�017401� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: writeMagick.cxx,v 4.1 2008/02/12 18:06:40 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Write Interface to the Image Magick Library * * We are only using the convenience functions at this point. * * Hugues Talbot 31 Jul 2000 * *-----------------------------------------------------------------------*/ #include "imview.hxx" #ifdef HAVE_MAGICK #include <stdio.h> #include <setjmp.h> #include <time.h> #include <errno.h> #include <assert.h> #include <sys/types.h> #include <cstring> #include "../imageIO.hxx" extern imageIO *IOBlackBox; // typical simple C solution #include <magick/api.h> static ImageInfo *image_info = 0; static Image *magickImage = 0; extern jmp_buf magick_jmp; // defined in readMagic.C // handlers have been set in readMagick.C int save_magick(const char *fname, /* input file name */ const char *format, /* output format */ int numcomp, /* 1 or 3 at this point */ int nx, /* dimensions */ int ny, /* dimensions */ uchar *pR, /* buffers */ uchar *pG, uchar *pB) { char nf[1024]; uchar *newbuf = 0, *p; int i; ExceptionInfo exception; volatile int retval = 0; // volatile so that it doesn't get clobbered by longjmp. dbgprintf("save_magick called\n"); if (setjmp(magick_jmp)) { // if we get here, ImageMagick found an error, bailing out if (magickImage) { DestroyImage(magickImage); magickImage = 0; } if (image_info) { DestroyImageInfo(image_info); image_info = 0; } return 100; } assert(pR != 0); // Can't work otherwise assert((numcomp == 1) || (numcomp == 3)); // allocate RGB buffer if ((newbuf = (uchar *)malloc(nx * ny * 3 * sizeof(uchar))) == 0) { errprintf("save_magick: Out of memory condition\n"); return 50; } p = newbuf; if (numcomp == 3) { assert(pG != 0); assert(pB != 0); // interlace the data (RGBRGBRGB etc) for (i = 0 ; i < nx * ny ; i++) { *p++ = pR[i]; *p++ = pG[i]; *p++ = pB[i]; } } else { // with ImageMagick, grey-level images are interpreted as RGB, // the output module is `smart' enough to find out that the image // is really only grey. // pseudo `interlace' the data (RRR,RRR,RRR etc) for (i = 0 ; i < nx * ny ; i++) { *p++ = pR[i]; *p++ = pR[i]; *p++ = pR[i]; } } // prefix the image name with format //snprintf(nf, 1024, "%s:%s", format, fname); strcpy(nf, fname); // set up the Magick stuff // initializes the exception information GetExceptionInfo(&exception); if (image_info == 0) image_info = CloneImageInfo((ImageInfo *)0); // constitute the image magickImage = ConstituteImage (nx, ny, "RGB", CharPixel, newbuf, &exception); // actual saving if (magickImage != 0) { // when saving an image, the filename is attached to the IMAGE // structure, not the imageinfo... Makes perfect sense! strcpy(magickImage->filename, nf); if (!WriteImage(image_info, magickImage)) { // failure errprintf("Image %s failed to write %s\n", fname, (errno) ? strerror(errno):"for some reason"); retval = 20; } // in any case here, DestroyImage(magickImage); magickImage = 0; } else { #ifdef MAGICK_USES_REASON // God I hate gratuitous API changes // for ImageMagick 5.2.7-2 (on RH7.1) MagickError(exception.severity,exception.reason,exception.description); #else // for other ImageMagick versions < 5.2.7-2 MagickError(exception.severity,exception.message,exception.qualifier); #endif retval = 10; } DestroyImageInfo(image_info); image_info = 0; free(newbuf); return retval; } #else // HAVE_MAGICK int save_magick(const char *fname, /* input file name */ const char *format, /* output format */ int numcomp, /* 1 or 3 at this point */ int nx, int ny, /* dimensions */ uchar *pR, uchar *pG, uchar *pB) /* buffers */ { errprintf("This version of Imview cannot save this images as the ImageMagick library\n" "is not available\n"); return 1; } #endif // HAVE_MAGICK ���������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/io/writeMagick.hxx��������������������������������������������������������������������0000644�0000765�0000765�00000004322�07653237126�017415� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: writeMagick.hxx,v 4.0 2003/04/28 14:44:38 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Write Interface to the Image Magick Library * * We are only using the convenience functions at this point. * * Hugues Talbot 31 Jul 2000 * *-----------------------------------------------------------------------*/ int save_magick(const char *fname, /* input file name */ const char *format, /* output format */ int numcomp, /* 1 or 3 at this point */ int nx, int ny, /* dimensions */ uchar *pR, uchar *pG, uchar *pB); /* buffers */ ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/keyboard.cxx��������������������������������������������������������������������������0000644�0000765�0000765�00000023737�10632004152�016324� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: keyboard.cxx,v 4.7 2007/06/07 13:30:18 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * This files complements the imageViewer class by handling * the keyboard inputs. * * The idea is to put together useful shortcuts in additions * to the ones provided by the menus. * * Hugues Talbot 18 Mar 1998 * *-----------------------------------------------------------------------*/ #include <FL/Fl.H> #include <assert.h> #include "imview.hxx" #include "imageIO.hxx" #include "pointfile.hxx" #include "imageViewer.hxx" #include "menubar.hxx" #include "server/interpreter.hxx" extern imageViewer *mainViewer; extern linkmanager *imview_linkmanager; extern int appMaxWidth, appMaxHeight; extern bool disableIOKeys; extern displaymode displaymodepref; extern bool fullScreen; bool imageViewer::toggle_fullscreen(void) { static displaymode olddspmode = displaymodepref; // irrelevant default static int oldx = -1, oldy=-1, oldw=-1, oldh=-1; dbgprintf("Toggling fullscreen status\n"); if (fullScreen) { // undo fullscreen dbgprintf(" Undoing fullscreen, reverting to (%d+%d-%dx%d)\n", oldx, oldy, oldw, oldh); assert((oldw > 0) && (oldh > 0)); parentWindow->fullscreen_off(oldx, oldy, oldw, oldh); setdisplaymode(olddspmode); } else { oldx = parentWindow->x(); // incorrect, should be global x() oldy = parentWindow->y(); oldw = parentWindow->w(); oldh = parentWindow->h(); dbgprintf(" Going fullscreen, saved dimensions as (%d+%d-%dx%d)\n", oldx, oldy, oldw, oldh); olddspmode = getdisplaymode(); setdisplaymode(IMV_DISPLAY_DECOUPLE_WIN_IMG); parentWindow->fullscreen(); } fullScreen = !fullScreen; return fullScreen; } // handle more keyboard shortcuts int imageViewer::handleKeyboardEvent() { int retval= 0; const char *txt; // look for special characters first switch (Fl::event_key()) { case FL_Escape: if (!disableIOKeys) quit_cb(0,0); retval = 1; break; /* frame switch */ case FL_Page_Up: dbgprintf("Page up key pressed\n"); nextframe_cb(0,0); retval = 1; break; case FL_Page_Down: dbgprintf("Page down key pressed\n"); previousframe_cb(0,0); retval = 1; break; /* component switch */ case FL_Home: dbgprintf("Home key pressed \n"); nextcomponent_cb(0,0); retval = 1; break; case FL_End: dbgprintf("End key pressed \n"); previouscomponent_cb(0,0); retval = 1; break; /* 3D switch */ case FL_Insert: dbgprintf("Insert key pressed \n"); nextplane_cb(0,0); retval = 1; break; case FL_Delete: dbgprintf("Delete key pressed \n"); previousplane_cb(0,0); retval = 1; break; case FL_BackSpace: dbgprintf("Backspace key pressed \n"); previousimage_cb(0,0); retval = 1; break; } // then look for normal text txt = Fl::event_text(); dbgprintf("Received keyboard event with text: %s\n", txt); switch (txt[0]) { case 'C': case 'G': case 's': retval = 0; break; case 'R': // reset the display (return to default zoom, maximises) if (Fl::event_state() & FL_ALT) { defaultZoomFactor_ = 1.0; } unzoom_cb(0,0); resetDisplay(); retval = 1; break; case 'c': // close the current image if (!disableIOKeys) close_cb(0,0); retval = 1; break; case ' ': // another way to walk the image list if (Fl::event_key(FL_Shift_L) || Fl::event_key(FL_Shift_R)) previousimage_cb(0,0); else nextimage_cb(0,0); retval = 1; break; case 'f': if (!(Fl::event_state() & FL_ALT)) { fullscreen_cb(0,0); retval = 1; } // alt-f invokes the file menu. break; case 'k': // display the next image in list nextimage_cb(0,0); retval = 1; break; case 'l': // display the previous image in list previousimage_cb(0,0); retval = 1; break; case 'm': // maximise the display resetDisplay(false,true); retval = 1; break; case 'n': // return zoom to default value unzoom_cb(0,0); retval = 1; break; case 'o': // open a new image if (!disableIOKeys) open_cb(0,0); retval = 1; break; case 'p': // closes the point file if (!disableIOKeys) closepointfile_cb(0,0); retval = 1; break; case 'q': // quit the application if (!disableIOKeys) quit_cb(0,0); retval = 1; break; case 'r': // redraw the display (do nothing else...) redraw(); retval = 1; break; case '.': // zoom in by 10% and grow the window if (!(Fl::event_state() & FL_ALT) && (getdisplaymode() == IMV_DISPLAY_WINDOW_FIT_IMG)) { // change the DEFAULT zoom factor defaultZoomFactor_ = imageZoomFactor_ * 1.1; zoomFactor(defaultZoomFactor_, false); // no redraw resetDisplay(false,true); } else { zoomFactor(imageZoomFactor_ * 1.1, true); // maybe redraw } retval = 1; break; case '>': // zoom in by 100% and grow the window if (!(Fl::event_state() & FL_ALT) && (getdisplaymode() == IMV_DISPLAY_WINDOW_FIT_IMG)) { // change the DEFAULT zoom factor defaultZoomFactor_ = imageZoomFactor_ * 2.0; zoomFactor(defaultZoomFactor_, false); // no redraw resetDisplay(false,true); } else { zoomFactor(imageZoomFactor_ * 2.0, true); // maybe redraw } retval = 1; break; case ',': // zoom out by 10% if (!(Fl::event_state() & FL_ALT) && (getdisplaymode() == IMV_DISPLAY_WINDOW_FIT_IMG)) { // change the DEFAULT zoom factor defaultZoomFactor_ = imageZoomFactor_ / 1.1; zoomFactor(defaultZoomFactor_, false); // no redraw resetDisplay(false,true); } else { zoomFactor(imageZoomFactor_ / 1.1, true); // maybe redraw } retval = 1; break; case '<': // zoom out by 100% if (!(Fl::event_state() & FL_ALT) && (getdisplaymode() == IMV_DISPLAY_WINDOW_FIT_IMG)) { // change the DEFAULT zoom factor defaultZoomFactor_ = imageZoomFactor_ / 2.0; zoomFactor(defaultZoomFactor_, false); // no redraw resetDisplay(false,true); } else { zoomFactor(imageZoomFactor_ / 2.0, true); // maybe redraw } retval = 1; break; case '=': // zoom back to 100% if (!(Fl::event_state() & FL_ALT) && (getdisplaymode() == IMV_DISPLAY_WINDOW_FIT_IMG)) { // change the DEFAULT zoom factor defaultZoomFactor_ = 1.0; zoomFactor(defaultZoomFactor_, false); // no redraw resetDisplay(false,true); } else { zoomFactor(1.0, true); // maybe redraw } retval = 1; break; case '[': // next image plane (3d) nextplane_cb(0,0); retval = 1; break; case ']': // previous image plane (3d) previousplane_cb(0,0); retval = 1; break; case '*': // secret! if (!disableIOKeys) saveimagelist_cb(0,0); retval = 1; break; } return retval; } // redisplay and resize the image to the max that can be done. void imageViewer::resetDisplay(bool doRedraw, bool forward) { int realMinWidth, realMinHeight; // sometimes the scrollbars are a problem if (doRedraw) destroy_scrollbars(); realMinWidth = trivmin(appMaxWidth,currentImageWidth()); realMinHeight = trivmin(appMaxHeight,currentImageHeight()); dbgprintf("Resetting image to %d x %d\n", realMinWidth, realMinHeight); if (parentWindow) { if (getdisplaymode() != IMV_DISPLAY_IMG_FIT_WINDOW) { sizeConstraints(realMinWidth, realMinHeight); } sizeParent(Ox + realMinWidth, Oy + realMinHeight); if (doRedraw) redraw_image(); } if (forward && imview_linkmanager) { if (imview_linkmanager->resetDisplay() > 0) { dbgprintf("Remote reset display failed\n"); } } return; } ���������������������������������imview-1.1.9c/machine.cxx���������������������������������������������������������������������������0000644�0000765�0000765�00000022330�10720351523�016121� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: machine.cxx,v 4.6 2007/11/19 18:17:55 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * This hosts the bits of imview that are not portable. * * Except for drawing calls, such as in imDrawPoint.C, * NO other file should have any #ifdev STRANGEMACHINE, etc * That's the theory anyway. * * Hugues Talbot 19 Jan 2000 * * *-----------------------------------------------------------------------*/ #include <imcfg.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <time.h> #ifdef HAVE_SYS_TIME_H # include <sys/time.h> #endif #include <sys/types.h> #ifndef WIN32_NOTCYGWIN # include <sys/utsname.h> # include <sys/types.h> # include <sys/stat.h> # include <fcntl.h> #endif #include "imunistd.h" #include <FL/Fl.H> #include <FL/x.H> #include "imview.hxx" // globals #if HAVE_PTHREADS # include <pthread.h> // good for both DEC and P threads # if !HAVE_DECTHREADS pthread_mutexattr_t *pthread_mutexattr_default = 0; pthread_condattr_t *pthread_condattr_default = 0; # endif // !HAVE_DECTHREAD #endif // HAVE_PTHREADS char const *systemName(void) { #ifdef WIN32_NOTCYGWIN static char const *retval = "win32"; #else static char const *retval; static struct utsname thisname; uname(&thisname); retval = thisname.sysname; #endif return retval; } // a temporary file name utility // Someone is welcome to come up with a secure version of this, // It's probably impossible, in the meantime gcc complains... #define TemporaryTemplate "ImView" // return a "unique" file name in filename, that can be opened, etc // This is not secure, but this is portable. // filename must be writeable, therefore must not be a string but an // array of chars. void imtempnam(char *filename) { char *name; assert(filename != NULL); name = (char *) tempnam(NULL, TemporaryTemplate); if (name == NULL) tmpnam(filename); else { strcpy(filename, name); free(name); } return; } // This emulates the `basename' not-very-standard // system call. The basename command line is // much more complicated, but we can't emulate it // here short of allocating a new buffer, which we // don't want to do. // // The win32 call will cope (sort of) with both / and '\\' // but it doesn't do that very well. It will do. const char *myBaseName(const char *astring) { #ifdef WIN32 // look for forward slash const char *retval = strrchr(astring, '/'); if (retval == 0) { // look for backward slash retval = strrchr(astring, '\\'); if (retval == 0) retval = astring; else retval++; } else retval++; #else const char *retval = strrchr(astring, '/'); if (retval == 0) retval = astring; else retval++; // go past the `/' #endif return retval; } // This emulates the `dirname' call // const char *myDirName(const char *astring) { int stringlength = strlen(astring); int i; char *retval = "."; // default return value #ifdef WIN32 for (i = stringlength-1 ; i > 0 ; --i) { // look for last forward or backslash if ((astring[i] == '/') || (astring[i] == '\\')) { retval = new char[i]; strncpy(retval, astring, i); retval[i] = '\0'; // terminating token break; } } #else for (i = stringlength-1 ; i > 0 ; --i) { // look for last forward slash if (astring[i] == '/') { retval = new char[i]; strncpy(retval, astring, i); retval[i] = '\0'; // terminating token break; } } #endif // WIN32 return retval; } // This is the Nightmare Call. int myFork(void) { return 0; } extern int debugIsOn; // Synchronize call for debugging void synchronize_GUI(void) { #if !defined(WIN32) && !defined(MACOSX_CARBON) if (debugIsOn) { // this is only for SERIOUS debugging XSynchronize(fl_display, 1); dbgprintf("Display synchronized for debugging\n"); } #endif return; } // skip over a \0 in a file. Necessary for // reading Z-IMAGE files. // NT doesn't require this for some reason int skipzero(FILE *fp) { int retval; #ifdef WIN32 retval = '\0'; // do nothing #else retval = getc(fp); #endif return retval; } #if HAVE_USLEEP #ifdef OSF1 // DEC Unix's prototype is unreachable extern "C" { extern int usleep (unsigned int); } #endif int myusleep(unsigned int usec) { struct timezone dummy; struct timeval start, end; double time0, time1, dt; gettimeofday(&start, &dummy); usleep(usec); gettimeofday(&end, &dummy); time0 = start.tv_sec + start.tv_usec/1e6; time1 = end.tv_sec + end.tv_usec/1e6; dt = time1-time0; dbgprintf("Asked to wait for %f sec, actually waited %f sec\n", usec/1e6, dt); return 0; } #elif HAVE_NANOSLEEP int myusleep(unsigned int usec) { struct timespec req; struct timezone dummy; struct timeval start, end; double time0, time1, dt; req.tv_sec = (int)(usec/1e6); req.tv_nsec = (long)((usec - req.tv_sec * 1e6) * 1000); gettimeofday(&start, &dummy); nanosleep(&req, NULL); gettimeofday(&end, &dummy); time0 = start.tv_sec + start.tv_usec/1e6; time1 = end.tv_sec + end.tv_usec/1e6; dt = time1-time0; dbgprintf("Asked to wait for %f sec, actually waited %f sec\n", usec/1e6, dt); return 0; } #elif !defined(WIN32) && HAVE_SELECT // Calls select on sterr, waiting to read // obviously this is going to fail, this is what we want: // select will time out and give us a portable time sleep. // the usual usleep is not widely available. // NOTE: This rely on a side effect of select. Time will // in fact tell if this is portable... int myusleep(unsigned int usec) { fd_set rfds; struct timeval tv, start, end; struct timezone dummy; int retval; double time0, time1, dt; static char tmppath[1024]; static int somedesc = -1; if (somedesc < 0) { char *tmp; // open the pipe tmp = tempnam(0, "flim"); strncpy(tmppath, tmp, 1024); retval = mkfifo(tmppath, S_IRUSR|S_IWUSR); if (retval != 0) { dbgprintf("Can't create fifo %s\n", tmppath); return 1; // can't go further } somedesc = open(tmppath, O_RDONLY | O_NDELAY, 0); if (somedesc < 0) { dbgprintf("Can't open fifo %s for reading\n"); return 2; // Can't go further either } } if (usec == 0) { usec = 10; // 0 actually means forever } FD_ZERO(&rfds); FD_SET(somedesc, &rfds); /* Wait up to the given time period */ tv.tv_sec = 0; tv.tv_usec = usec; gettimeofday(&start, &dummy); /* this assumes nothing come from stderr... */ retval = select(FD_SETSIZE, &rfds, NULL, NULL, &tv); gettimeofday(&end, &dummy); time0 = start.tv_sec + start.tv_usec/1e6; time1 = end.tv_sec + end.tv_usec/1e6; dt = time1-time0; dbgprintf("Asked to wait for %f sec, actually waited %f sec\n", usec/1e6, dt); unlink(tmppath); somedesc = -1; return retval; } #else // fake it really bad int myusleep(int usec) { sleep((int)(usec/1e6)); return 0; } #endif // SLEEP functions // semaphore replacement functions, if needs be #ifndef HAVE_PTHREADS void semaphore_down(int *) { } void semaphore_up(int *) { } void semaphore_init(int *) { } void semaphore_destroy(int *) { } #endif // ! HAVE_PTHREADS // Endianness issue endianness checkendian(void) { /* Are we little or big endian? From Harbison&Steele. */ union { long l; char c[sizeof (long)]; } u; u.l = 1; if (u.c[sizeof (long) - 1] == 1) return(ENDIAN_BIG); else return(ENDIAN_LITTLE); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/machine.hxx���������������������������������������������������������������������������0000644�0000765�0000765�00000007545�10720351523�016141� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: machine.hxx,v 4.4 2007/11/19 18:17:55 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * * Include file for non-portable bits of imview * * Hugues Talbot 20 Jan 2000 * *-----------------------------------------------------------------------*/ #ifndef MACHINE_H #define MACHINE_H #include <stdio.h> #include <setjmp.h> #include <signal.h> #include <imcfg.h> #if HAVE_PTHREADS # include <pthread.h> #endif #include "imview.hxx" #ifdef WIN32_NOTCYGWIN typedef jmp_buf im_jmp_buf; # define im_longjmp(X,Y) longjmp((X),(Y)) # define im_setjmp(X,Y) setjmp((X)) # define im_signal(X,Y) {/* empty statement */} // for when a signal is not supported typedef unsigned char uchar; typedef unsigned short ushort; typedef unsigned int uint; typedef unsigned long ulong; # ifdef _MSC_VER # define im_va_start(X,Y) va_start((char *)(X),(Y)) #else // only vc++ has a problem? # define im_va_start va_start #endif # define random rand // not as good but will do. #else // WIN32_NOTCYGWIN typedef sigjmp_buf im_jmp_buf; # define im_longjmp(X,Y) siglongjmp((X),(Y)) # define im_setjmp(X,Y) sigsetjmp((X),(Y)) # define im_signal(X,Y) signal((X),(Y)) # ifndef O_BINARY # define O_BINARY 0 # endif # define im_va_start va_start #endif // WIN32_NOTCYGWIN // DEC threads #if HAVE_PTHREADS # if HAVE_DECTHREADS # define pthread_attr_init pthread_attr_create # else // HAVE_DECTHREAD extern pthread_mutexattr_t *pthread_mutexattr_default; extern pthread_condattr_t *pthread_condattr_default; # endif extern pthread_t noThread; // a global #else // HAVE_PTHREADS // fake 'em if we don't have 'em typedef int Semaphore; void semaphore_down(int *); void semaphore_up(int *); void semaphore_init(int *); void semaphore_destroy(int *); #endif // HAVE_PTHREADS // prototypes void imtempnam(char *name); char const *systemName(void); const char *myBaseName(const char *astring); const char *myDirName(const char *astring); int myFork(void); void synchronize_GUI(void); int skipzero(FILE *fp); int myusleep(unsigned int usec); endianness checkendian(void); // bizarre stuff needed by MSVC++ #ifdef _MSC_VER #define popen _popen // How does Microsoft get away with things like that? #define pclose _pclose #endif // _MSC_VER #endif // MACHINE_H �����������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/make_purify���������������������������������������������������������������������������0000755�0000765�0000765�00000001055�07653236467�016257� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������purify g++ -DSolaris -I/usr/openwin/include -I/home/ee02/include -Wall -g -O2 -DSVR4 -D_SOLARIS -I/usr/openwin/include -o imview imview.o menubar.o imageViewer.o imageIO.o my_Image.o imdebug.o readgif.o readtiff.o readZimage.o imtranslate.o readjpeg.o pointfile.o keyboard.o menucb.o readics.o imlines.o imDrawPoint.o printPrefs.o savePrefs.o imageInfo.o transferFunction.o transferBox.o fluid/imview_ui.a io/imview_io.a -L/datamine/local/lib -L/home/ee02/lib -L/usr/openwin/lib /home/ee02/lib/libFl_db_g++272.a -lX11 -lgen -lm -ljpeg -ltiff -lsocket -lnsl �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/Makefile.in���������������������������������������������������������������������������0000644�0000765�0000765�00000045005�10745372604�016054� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- Makefile -*- # hand-generated Makefile.in for the imview project # This file gets used by the configure script to generate the # real makefile. # # This is somewhat hard to do but very worthwile... # Hugues Talbot 6 Aug 2000 # SHELL = /bin/sh LN = /bin/ln # hopefully this works everywhere... MV = @MV@ CP = @CP@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ subdirs = @subdirs@ top_srcdir = @top_srcdir@ srcdir = @srcdir@ bindir = $(exec_prefix)/bin infodir = $(prefix)/info libdir = $(prefix)/lib/gnudl mandir = $(prefix)/man/man1 datadir = @datadir@ datadestdir = $(datadir)/Imview # compilers and flags CC = @CC@ CXX = @CXX@ FLUID = @FLUID@ CPPFLAGS = @CPPFLAGS@ CFLAGS = $(CPPFLAGS) @CFLAGS@ CXXFLAGS = $(CPPFLAGS) @CXXFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ INSTALL = @INSTALL@ FLTK_CONFIG = @FLTK_CONFIG@ # program to make the archive: LIBNAME = @LIBNAME@ LIBCOMMAND = @LIBCOMMAND@ RANLIB = @RANLIB@ DSONAME = @DSONAME@ DSOCOMMAND = @DSOCOMMAND@ # executable's name IMVIEW = imview # if nothing else PLATFORM = @target@ # Executable extension EEXT = @EEXT@ # version VERS = @MAJOR_VERSION@.@MINOR_VERSION@.@MICRO_VERSION@ CVSTAG = IMVIEW_@MAJOR_VERSION@_@MINOR_VERSION@_@MICRO_VERSION@ BRANCHTAG = @BRANCH_TAG@ # libraries to link with: LDLIBS =@LDFLAGS@ @FLTKLIB@ @FLTKEXTRA@ @IMLIBS@ @XLIBS@ @X_EXTRA_LIBS@ @THREADLIB@ @POSIX_IPC_LIB@ @MATHLIB@ #GLDLIBS =@LDFLAGS@ @LIBS@ @GLLIB@ -lX11 -lXext @X_EXTRA_LIBS@ -lm TOP = ${top_srcdir} TARGET = ${IMVIEW}${EEXT} # so as to include the class declarations and config.h CXXFLAGS += -I${TOP} -I. # installer mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs UILIB = fluid/imview_ui.a IOLIB = io/imview_io.a SRVLIB = server/imview_server.a CPPFILES = \ imview.cxx \ imviewWindow.cxx \ menubar.cxx \ imageViewer.cxx \ imageIO.cxx \ my_Image.cxx \ imdebug.cxx \ imtranslate.cxx \ imtransform.cxx \ pointfile.cxx \ keyboard.cxx \ menucb.cxx \ imlines.cxx \ imDrawPoint.cxx \ printPrefs.cxx \ savePrefs.cxx \ imageInfo.cxx \ transferFunction.cxx \ transferBox.cxx \ transferHistoBox.cxx \ transferFunctionBox.cxx \ spectraBox.cxx \ axisBox.cxx \ saveSpect.cxx \ printSpect.cxx \ profileBox.cxx \ userPrefs.cxx \ bivHist.cxx \ machine.cxx \ progressInfo.cxx \ rawImage.cxx \ StatusBox.cxx \ annotatePoints.cxx \ toolbar.cxx \ transferRGBFunction.cxx \ transferRGBFunctionBox.cxx \ transferRGBHistoBox.cxx \ transferRGBBox.cxx \ sliceSlider.cxx \ view3d.cxx \ simpleViewer.cxx OBJECTS = $(CPPFILES:.cxx=.o) .SUFFIXES : .cxx .c .o .do .cc .PHONY : targzip epm rpm help check doc fence checker insure test .cc: @echo "Do nothing with $<" .cxx.o : $(CXX) $(CXXTRA) $(CXXFLAGS) -I../include -c $< .cxx : $(SENTINEL) $(CXX) $(CXXTRA) $(CXXFLAGS) -I../include -o $@ $< $(UILIB) $(IOLIB) $(SRVLIB) $(LDFLAGS) $(LDLIBS) $(LDXTRA) $(FENCE) ## All is the first target all:: (cd fluid ; $(MAKE) ) (cd io ; $(MAKE) ) (cd server ; $(MAKE) ) $(MAKE) $(TARGET) redoc:: - (if [ ! -e ${top_srcdir}/../imview-doc ] ; then \ echo "*** Documentation ${top_srcdir}/../imview-doc missing ***" ;\ echo "*** get it from CVS sourceforge and install it there ***" ;\ else \ (cd ${top_srcdir} ; if [ ! -L fulldoc ] ; then ln -s ../imview-doc fulldoc ; fi) ;\ (cd ${top_srcdir}/fulldoc ; ${MAKE} ) ;\ $(CP) ${top_srcdir}/fulldoc/quickhelp*.html ${top_srcdir}/fulldoc/gpl.html ${top_srcdir}/fulldoc/warranty.html ${top_srcdir}/doc ;\ $(CP) ${top_srcdir}/fulldoc/imview.man ${top_srcdir}/doc/imview.1 ;\ fi) etags:: etags ${CPPFILES} doc:: @echo "This command <make doc> does nothing, use <make redoc> for rebuilding the documentation" fence:: ${MAKE} FENCE=-lefence all checker: $(MAKE) CXX=checkerg++ all insure: $(MAKE) CXX=insure CXXFLAGS='-g -Wall -DINSURE_PICKY -Zoi "compiler g++"' all $(TARGET) : $(UILIB) $(IOLIB) $(SRVLIB) $(OBJECTS) $(SENTINEL) $(CXX) $(STATIC) $(CXXTRA) $(CXXFLAGS) -o $(TARGET) $(OBJECTS) $(UILIB) $(IOLIB) $(SRVLIB) $(LDFLAGS) $(LDLIBS) $(LDXTRA) $(FENCE) $(FLTK_CONFIG) --post $(TARGET) @(cd ${TOP} ; ./buildnb) $(UILIB): (cd fluid ; $(MAKE) ) $(IOLIB): (cd io ; $(MAKE) ) $(SRVLIB): (cd server ; $(MAKE) ) install: all doc install-bin install-lut install-help # install with one level of undo if possible # NOTE: if (diff filea fileb) is true if both files are the same # NOTE: use $(CP) here instead of $(INSTALL) because of MacOS which requires a # copy capable of dealing with resource forks install-bin: @$(mkinstalldirs) $(DESTDIR)$(bindir) @if [ -L $(DESTDIR)$(bindir)/${IMVIEW}.bin ] ; then \ echo "Installing as ${IMVIEW}.bin" ; \ ${CP} ${TARGET} $(DESTDIR)$(bindir)/${IMVIEW}-${VERS}${EEXT} ; \ (cd $(DESTDIR)$(bindir) ; \ if ( diff ${IMVIEW}.bin ${IMVIEW}-${VERS}${EEXT} ) ; then \ ${MV} ${IMVIEW}.bin ${IMVIEW}.old ; \ fi ;\ ${LN} -fs ${IMVIEW}-${VERS}${EEXT} ${IMVIEW}.bin ) ; \ elif [ -L $(DESTDIR)$(bindir)/${IMVIEW}${EEXT} ] ; then \ echo "Installing as ${IMVIEW}-${VERS}${EEXT}" ; \ ${CP} ${TARGET} $(DESTDIR)$(bindir)/${IMVIEW}-${VERS}${EEXT} ; \ (cd $(DESTDIR)$(bindir) ; \ if ( diff ${IMVIEW}${EEXT} -${IMVIEW}-${VERS}${EEXT} ) ; then \ ${MV} ${IMVIEW}${EEXT} ${IMVIEW}.old ; \ fi ;\ ${LN} -fs ${IMVIEW}-${VERS}${EEXT} ${IMVIEW}${EEXT} ) ; \ else \ echo "Installing as ${IMVIEW}${EEXT}" ; \ ${CP} ${TARGET} $(DESTDIR)$(bindir)/${IMVIEW}${EEXT} ; \ fi install-lut: @$(mkinstalldirs) $(DESTDIR)$(datadestdir) @for i in ${top_srcdir}/support/*.lut ${top_srcdir}/support/*.jpg ; do \ ${INSTALL} $$i $(DESTDIR)$(datadestdir)/ ;\ done install-help: @$(mkinstalldirs) $(DESTDIR)$(datadestdir)/doc @for i in ${top_srcdir}/doc/quickhelp*.html ; do \ ${INSTALL} $$i $(DESTDIR)$(datadestdir)/doc/ ;\ done @-${INSTALL} -d $(DESTDIR)$(datadestdir) @-${INSTALL} ${top_srcdir}/doc/gpl.html $(DESTDIR)$(datadestdir)/doc/ @-${INSTALL} ${top_srcdir}/doc/warranty.html $(DESTDIR)$(datadestdir)/doc/ @-${INSTALL} -d $(DESTDIR)$(mandir) @-${INSTALL} ${top_srcdir}/doc/imview.1 $(DESTDIR)$(mandir)/ @gzip $(DESTDIR)$(mandir)/imview.1 # strip executables before installing. install-strip: install-lut install-help $(MAKE) INSTALL='$(INSTALL) -s' install-bin uninstall: uninstall-bin uninstall-lut uninstall-doc # should be safe... (famous last words) uninstall-bin: @if [ -L $(DESTDIR)$(bindir)/${IMVIEW}.bin ] ; then \ (cd $(DESTDIR)$(bindir) ; \ if [ -e ${IMVIEW}.old ] ; then \ ${MV} ${IMVIEW}.old ${IMVIEW}.bin ; \ else \ ${RM} ${IMVIEW}.bin ; \ fi ; \ ${RM} ${IMVIEW}-${VERS}${EEXT}) ; \ elif [ -L $(DESTDIR)$(bindir)/${IMVIEW}${EEXT} ] ; then \ (cd $(DESTDIR)$(bindir) ; \ if [ -e ${IMVIEW}.old ] ; then \ ${MV} ${IMVIEW}.old ${IMVIEW}${EEXT} ; \ else \ ${RM} ${IMVIEW}${EEXT} ; \ fi ; \ ${RM} ${IMVIEW}-${VERS}${EEXT}) ; \ else \ ${RM} $(DESTDIR)$(bindir)/${IMVIEW}${EEXT} ; \ fi uninstall-lut: @if [ ! -L $(DESTDIR)$(bindir)/${IMVIEW}.bin -o -e $(DESTDIR)$(bindir)/${IMVIEW}${EEXT} ] ; then \ ${RM} -rf $(DESTDIR)$(datadestdir) ;\ else \ echo "Not removing lut, as an older version of imview is still available" ;\ fi uninstall-doc: @if [ ! -L $(DESTDIR)$(bindir)/${IMVIEW}.bin -o -e $(DESTDIR)$(bindir)/${IMVIEW}${EEXT} ] ; then \ ${RM} -rf $(DESTDIR)$(datadestdir)/doc ;\ ${RM} -f $(DESTDIR)$(mandir)/imview.1.gz ;\ else \ echo "Not removing documentation, as an older version of imview is still available" ;\ fi test: @echo "TOP=" ${TOP} @echo "TARGET=" ${TARGET} @echo "whichOS=" ${whichOS} @echo "FLDIR=" ${FLDIR} @echo "CXXTRA=" ${CXXTRA} @echo "CXX=" ${CXX} @echo "FLUID=" ${FLUID} @echo "datadestdir=" ${datadestdir} @echo "VERS= " ${VERS} @echo "PLATFORM= " ${PLATFORM} coverage: ${MAKE} CXX="$(CXX) -fprofile-arcs -ftest-coverage" all profile: ${MAKE} CXX="$(CXX) -pg" all sentinel:: ${MAKE} "SENTINEL=sentinel" CXX="$(CXX) -static" all ;\ # the host stuff. SOLARISHOST = tweed OSF1HOST = fire IRIXHOST = ourimbah SUNOSHOST = crackers LINUXHOST = boolaroo NTHOST = boolaroo # cross-compilation FTPHOST = extra.cmis.csiro.au FTPDIR = IA/talbot/clients/free/ solaris: rsh $(SOLARISHOST) '(cd ${PWD} ; \ ${MAKE} FLDIR=${FLDIR} CXX=c++ CXXFLAGS="-O2 $(CXXFLAGS)" clean depend install)' osf1: rsh $(OSF1HOST) '(cd ${PWD} ; \ ${MAKE} clean depend optimize)' irix: rsh $(IRIXHOST) '(cd ${PWD} ; \ ${MAKE} clean depend optimize)' sunos: rsh $(SUNOSHOST) '(cd ${PWD} ;\ ${MAKE} clean depend optimize)' linux: ssh $(LINUXHOST) '(cd ${PWD} ;\ ${MAKE} clean depend optimize)' debug: $(MAKE) CXX=gcc++ CXXFLAGS='-g -Wall' clean depend all optimize: $(MAKE) CXX='${CXX} -O2' all fast: $(MAKE) 'MAKE=${MAKE} -j 2' -j 2 all vfast: $(MAKE) 'MAKE=${MAKE} -j 4' -j 4 all allplatforms: solaris osf1 irix sunos linux clobber: realclean -rm -rf Solaris OSF1 Linux IRIX SunOS realclean: (cd fluid; $(MAKE) realclean) (cd io; $(MAKE) realclean) (cd server ; $(MAKE) realclean) -@ rm -f *.o $(TARGET) $(CLEAN) core *~ makedepend gmon.out *.da *.bb *.bbg *.log .ix[0-9]* .inslog* @touch makedepend clean : (cd fluid ; $(MAKE) FLDIR=${FLDIR} clean) (cd io; $(MAKE) FLDIR=${FLDIR} clean) (cd server ; $(MAKE) FLDIR=${FLDIR} clean) -@ rm -f *.o $(TARGET) $(CLEAN) # in the last line, replace patchlevel.h with a known file imview.cxx already depends upon. # that's the most elegant way I've found not to leave garbage in the makedepend file. # Think about it. It's hard as the path to patchlevel.h is unknown, can contain whitespaces, etc... depend: $(CPPFILES) $(CFILES) (cd fluid ; ${MAKE} depend) (cd io ; $(MAKE) depend) (cd server ; $(MAKE) depend) $(CXX) $(CXXTRA) $(CXXFLAGS) -M $^ > makedepend @echo "removing dependency on patchlevel.h" @(sed 's/patchlevel.h/imview.hxx/' < makedepend > /tmp/makedepend.tmp ; $(RM) makedepend; $(CP) /tmp/makedepend.tmp makedepend) makedepend: touch makedepend ${MAKE} depend include makedepend snapshot: @echo "Try <make tag_snapshot> or <make branch_snapshot>" # a rule to make snapshots tag_snapshot: @echo @(grep totalbnb ${top_srcdir}/patchlevel.h | awk '{print $$4}' > /tmp/imview_bnb) @echo "-> Note: The current version is" @echo "->" $(VERS) "build number" `cat /tmp/imview_bnb` @echo "-> The current imview tag is" @echo "->" $(CVSTAG)_`cat /tmp/imview_bnb` @echo @echo "-> Tagging the repository" @(BN=`cat /tmp/imview_bnb` ; cd ${top_srcdir} ; cvs tag ${CVSTAG}_$${BN} imview) @echo @echo "-> CVS export of all the files" (BN=`cat /tmp/imview_bnb` ; \ cd ${top_srcdir}/export ; \ if [ -d imview-${VERS} ] ; then rm -rf imview-${VERS} ; fi ; \ cvs export -r ${CVSTAG}_$${BN} imview ; $(MV) imview imview-${VERS}) @echo "-> Tarring the snapshot" (cd ${top_srcdir}/export ; tar czf imview-src-${VERS}.tar.gz imview-${VERS}) @echo @(rm -f /tmp/imview_bnb) @echo "-> Done." # branch tag snapshot branch_snapshot: @echo @(grep totalbnb ${top_srcdir}/patchlevel.h | awk '{print $$4}' > /tmp/imview_bnb) @echo "-> Note: The current version is" @echo "->" $(VERS) "build number" `cat /tmp/imview_bnb` @echo "-> The current imview tag is" @echo "->" $(CVSTAG)_`cat /tmp/imview_bnb` @echo @echo "-> CVS export of all the files" (BN=`cat /tmp/imview_bnb` ; \ cd ${top_srcdir}/export ; \ if [ -d imview-${VERS} ] ; then rm -rf imview-${VERS} ; fi ; \ cvs export -r ${BRANCHTAG} imview ; $(MV) imview imview-${VERS}) @echo "-> Tarring the snapshot" (cd ${top_srcdir}/export ; tar czf imview-src-${VERS}.tar.gz imview-${VERS}) @echo @(rm -f /tmp/imview_bnb) @echo "-> Done." ftpsnap: @echo "-> placing the snapshot for anonymous ftp in " $(FTPDIR) @echo @ncftpput -u ${USER} $(FTPHOST) $(FTPDIR) ${top_srcdir}/export/imview-src-$(VERS).tar.gz manifest: @echo "Manifest:" - @(cd ${top_srcdir} ;\ find . -type f -print | sed -e 's%\./%%' -e '/CVS/d' -e '/~$$/d' -e '/^obj/d' -e '/^distrib/d' -e '/^autom4te/d' -e '/^export/d' | sort 2>&1 > /tmp/MANIFEST.new1 ;\ if [ "`diff /tmp/MANIFEST.new1 MANIFEST`" != "" ] ; then \ echo "*** Difference in MANIFEST, see /tmp/MANIFEST.new1 " ;\ diff /tmp/MANIFEST.new1 MANIFEST ;\ else \ echo "No diff -- tarring distribution" ;\ tar czf export/imview-src-${VERS}.tar.gz `cat MANIFEST` ;\ (cd export ; mkdir imview-${VERS} ; cd imview-${VERS} ; tar zxf ../imview-src-${VERS}.tar.gz) ;\ rm export/imview-src-${VERS}.tar.gz ;\ echo "Tarring again" ;\ (cd export ;tar czvf imview-src-${VERS}.tar.gz imview-${VERS}) ;\ rm -rf export/imview-${VERS} ;\ fi) rpm: @echo @if [ -e /etc/redhat-release ] ; then \ echo "-> Making RPM for `cat /etc/redhat-release`" ; \ else \ echo "-> Making RPM for `uname`" ;\ fi @(if [ ! -f ${top_srcdir}/export/imview-src-${VERS}.tar.gz ] ; then echo "" ; \ echo "*** You must make a snapshot or a manifest first (make snapshot/make manifest)" ; exit 1 ; fi) @echo "-> Linking source package" (cd ${top_srcdir}/distrib/redhat/SOURCES ; ln -sf ../../../export/imview-src-${VERS}.tar.gz . ) @echo "-> Creating spec file" (cd ${top_srcdir}/distrib/redhat ; sed -e "s/@VERSION@/${VERS}/g" imview-generic.spec > SPECS/imview-${VERS}-1.spec) @echo "-> Making RPM" (unset LD_LIBRARY_PATH ; cd ${top_srcdir}/distrib/redhat ; \ export MYTOPDIR=`pwd` ; \ cd SPECS ;\ rpmbuild --define "_topdir $${MYTOPDIR}" --buildroot $${MYTOPDIR}/root -ba imview-${VERS}-1.spec) @echo "-> Done." ftprpm: @echo "-> placing RPM for anonymous ftp in " $(FTPDIR) @echo @ncftpput -u ${USER} $(FTPHOST) $(FTPDIR) ${top_srcdir}/distrib/redhat/RPMS/imview-${VERS}.rpm semistat: -if [ -f ./imview -a -x `which ldd` ] ; then \ statlibcxx=`ldd ./imview | grep libstdc++ | sed -e 's%.*=>\(.*libstdc.*\)\.so.*%\1.a%'` ;\ if [ "$${statlibcxx}" != "" ] ; then \ echo $${statlibcxx} ;\ extrastatlib="-append $${statlibcxx} -- " ;\ rm imview ;\ ${MAKE} CXX='gcc' SENTINEL="${top_srcdir}/statisize.py $${extrastatlib}" all ;\ else \ rm imview ;\ ${MAKE} SENTINEL="${top_srcdir}/statisize.py" all ;\ fi \ else \ rm imview ;\ ${MAKE} SENTINEL="${top_srcdir}/statisize.py" all ;\ fi # problem here: we are starting to heavily depend on GCC. mind you the idea # is to provide a semi-static executable that will work everywhere, not necessarily # the best performances epm: @echo "1-> Re-linking a NORMAL executable" -rm imview ; ${MAKE} all @echo "2-> Re-linking a static imview" ${MAKE} semistat @echo "3-> Running Easy Package Manager" ${MAKE} epmproper @echo "-> Done." epmproper: (TGZDIR=`epm -e` ; export TGZDIR ; \ epm --setup-image ${top_srcdir}/fulldoc/images/setup.xpm -v imview ;\ $(CP) $${TGZDIR}/imview-${VERS}-$${TGZDIR}.tar.gz ${top_srcdir}/distrib/binaries) ftpepm: @echo "-> placing EPM for anonymous ftp in " $(FTPDIR) @echo @(TGZDIR=`epm -e` ; export TGZDIR ; \ ncftpput -u ${USER} $(FTPHOST) $(FTPDIR) $${TGZDIR}/imview-${VERS}-$${TGZDIR}.tar.gz) @ncftpls -u $(USER) -l -x -rt ftp://$(FTPHOST)/$(FTPDIR) targzip: @echo @echo " -> Binary for ${PLATFORM}" - mkdir ${top_srcdir}/tmp - rm -rf ${top_srcdir}/tmp/* - mkdir ${top_srcdir}/tmp/imview-${VERS}-${PLATFORM} mkdir ${top_srcdir}/tmp/imview-${VERS}-${PLATFORM}/lut mkdir ${top_srcdir}/tmp/imview-${VERS}-${PLATFORM}/doc @echo " -> Re-linking a static version (for redistribution)" rm ./imview ${MAKE} STATIC='-static' all # re-link a static version - strip ./imview $(CP) ./imview ${top_srcdir}/tmp/imview-${VERS}-${PLATFORM}/ $(CP) ${top_srcdir}/support/*.lut ${top_srcdir}/tmp/imview-${VERS}-${PLATFORM}/lut $(CP) ${top_srcdir}/doc/*.html ${top_srcdir}/tmp/imview-${VERS}-${PLATFORM}/doc (cd ${top_srcdir}/tmp/ ; tar zcf imview-${VERS}-${PLATFORM}.tar.gz imview-${VERS}-${PLATFORM}) $(CP) ${top_srcdir}/tmp/imview-${VERS}-${PLATFORM}.tar.gz ${top_srcdir}/distrib/binaries/ @echo " -> done Binary for ${PLATFORM}" check: ${top_srcdir}/check/minimal.exp ${USER} ./imview ${top_srcdir} help: @echo "Standard targets:" @echo " depend : Computes dependencies" @echo " all : Makes everything" @echo " check : Runs test" @echo " doc : builds the HTML online doc" @echo " install : Installs everything" @echo " clean : Cleans" @echo " uninstall : Uninstalls present version" @echo "" @echo "Developers targets" @echo " snapshot : Makes a release (needs CVS'ed version)" @echo " manifest : Makes a release (from current distribution, not CVS)" @echo " rpm : Makes a RedHat RPM (needs a snapshot or a manifest)" @echo " epm : Makes a portable binary package (no snapshot needed)" @echo " fast : fast (== all) build on 2-proc SMP machines" @echo " vfast : very fast (== all) build on 4-proc SMP machines" @echo " fence : Makes an electric-fence executable (memory debugging)" @echo " realclean : Deletes all cruft" @echo "" @echo "Publishing targets" @echo " ftpsnap : publishes the source snapshot" @echo " ftprpm : publishes the latest RPM" @echo " ftpepm : publishes the latest EPM" @echo "" @echo "Non-portable/deprecated targets" @echo " coverage : Force a build for gcov (Use configure for this)" @echo " profile : Makes an exec for gprof (Use configure for this)" @echo " checker : Makes a checker-gcc exec (doesn't work anymore)" @echo " insure : Makes an insure exec (may still work...)" @echo " sentinel : Makes a sentinel exec (doesn't work anymore)" @echo " debug : Force a debug build, (use configure now)" @echo " solaris : Build a solaris exec (don't use)" @echo " osf1 : Build for DEC/Compaq osf-1/DEC Unix/Tru64" @echo " irix : Build an Irix exec (don't use)" @echo " sunos : Build for SunOS (4.x) (don't use)" @echo " linux : Build for Linux (don't use)" @echo " allplatform : Build for all the above, (don't use)" @echo " clobber : realclean for all platforms (don't use)" @echo " optimize : Force an optimized build (don't use)" # automatic re-running of configure if the ocnfigure.in file has changed ${srcdir}/configure: configure.in aclocal.m4 imview.list.in cd ${srcdir} && autoconf # autoheader might not change config.h.in, so touch a stamp file ${srcdir}/config.h.in: stamp-h.in ${srcdir}/stamp-h.in: configure.in aclocal.m4 # cd ${srcdir} && autoheader echo timestamp > ${srcdir}/stamp-h.in config.h: stamp-h stamp-h: config.h.in config.status ./config.status Makefile: Makefile.in config.status fluid/Makefile.in io/Makefile.in server/Makefile.in ./config.status config.status: configure ./config.status --recheck ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/MANIFEST������������������������������������������������������������������������������0000644�0000765�0000765�00000010563�10201166373�015130� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������aclocal.m4 annotatePoints.cxx annotatePoints.hxx axisBox.cxx axisBox.hxx bivHist.cxx bivHist.hxx buildnb changehdr.sh ChangeLog check/minimal.exp client/democlient.c client/imclient.c client/imclient.h client/liarp.h client/liarwrap.c client/liarwrap.h client/Makefile client/startim.c config.guess config.sub configure configure.in CONTRIBUTORS COPYING COPYRIGHT CREDITS .cvsignore DESCRIPTION doc/gpl.html doc/imview.1 doc/quickhelp-1.html doc/quickhelp-2.html doc/quickhelp-3.html doc/quickhelp-4.html doc/quickhelp.html doc/warranty.html FAQ fluid/addpoint.xpm fluid/annotatedlg.fl fluid/arbitrary.fl fluid/bivdlg.fl fluid/config.h.in fluid/configure.in fluid/.cvsignore fluid/editpoint.xpm fluid/fliph.xpm fluid/flipv.xpm fluid/hidetoolbar.xpm fluid/imginfodlg.fl fluid/Makefile.in fluid/measure.xpm fluid/pencil.xpm fluid/printdlg.fl fluid/prntspectdlg.fl fluid/profile.fl fluid/progress.fl fluid/rmpoint.xpm fluid/rotate-90.xpm fluid/rotate+90.xpm fluid/savedlg.fl fluid/savespectdlg.fl fluid/selectpoint.xpm fluid/sliderdlg.fl fluid/spectra.fl fluid/tmpmsgdlg.fl fluid/toolbardlg.fl fluid/transfer2.fl fluid/transfer.fl fluid/userprefdlg.fl fluid/zoom_s.xpm header.txt imageInfo.cxx imageInfo.hxx imageIO.cxx imageIO.hxx imageViewer.cxx imageViewer.hxx imcfg.h.in imdebug.cxx imDrawPoint.cxx imDrawPoint.hxx imlines.cxx imlines.hxx imnmspc.hxx imtransform.cxx imtranslate.cxx imtranslate.hxx imunistd.h imview.cxx imview.hxx imview.list.in imviewWindow.cxx imviewWindow.hxx INSTALL install-sh io/byte-swap.h io/config.h.in io/configure.in io/cpostscript.cxx io/cpostscript.hxx io/.cvsignore io/gplot2.cxx io/gplot2.hxx io/ics.hxx io/imSystem.cxx io/imSystem.hxx io/loadtiff-code.h io/loadtiff.h io/Makefile.in io/newprefio.cxx io/newprefio.hxx io/readgif.cxx io/readgif.hxx io/readics.cxx io/readics.hxx io/readjpeg.cxx io/readjpeg.hxx io/readMagick.cxx io/readMagick.hxx io/readmat5.cxx io/readmat5.hxx io/readpnm.cxx io/readpnm.hxx io/readps.cxx io/readps.hxx io/readraw.cxx io/readraw.hxx io/readsocket.cxx io/readsocket.hxx io/readtiff.cxx io/readtiff.hxx io/readZimage.cxx io/readZimage.hxx io/savetiff.cxx io/savetiff.hxx io/saveZimage.cxx io/saveZimage.hxx io/writeMagick.cxx io/writeMagick.hxx keyboard.cxx machine.cxx machine.hxx Makefile.in make_purify MANIFEST menubar.cxx menubar.hxx menucb.cxx mkinstalldirs my_Image.cxx my_Image.hxx nocase.hxx old/fluid/HelpDialog.fl old/HelpView.cxx old/HelpView.hxx old/imageViewer_draw.cxx old/prefio.cxx old/prefio.hxx old/README patches/carbon_fork.txt patches/synchro.c patchlevel.h pointfile.cxx pointfile.hxx printPrefs.cxx printPrefs.hxx printSpect.cxx printSpect.hxx profileBox.cxx profileBox.hxx progressInfo.cxx progressInfo.hxx rawImage.cxx rawImage.hxx README README.html savePrefs.cxx savePrefs.hxx saveSpect.cxx saveSpect.hxx server/asynchat.cxx server/asynchat.hxx server/asyncore.cxx server/asyncore.hxx server/config.h.in server/configure.in server/.cvsignore server/imserver.cxx server/imserver.hxx server/imshared.cxx server/imshared.hxx server/interpreter.cxx server/interpreter.hxx server/Makefile.in server/noimserver.cxx server/semaphore.cxx server/semaphore.hxx server/socketstream.cxx server/socketstream.hxx sliceSlider.cxx sliceSlider.hxx spectraBox.cxx spectraBox.hxx stamp-h.in statisize.py StatusBox.cxx StatusBox.hxx stl/secure.c stl/sstream/iotraits.h stl/sstream/sstream stl/sstream/sstream.cc stl/sstream/sstream.h support/binary.lut support/blue.lut support/green.lut support/heat.lut support/hue.lut support/imview_banner.jpg support/imview.sh support/inv_binary.lut support/inv_grey.lut support/inv_heat.lut support/inv_rainbow.lut support/inv_spec.lut support/inv_spiral.lut support/NeWSfb.lut support/overlay_blue.lut support/overlay_cyan.lut support/overlay_green.lut support/overlay_magenta.lut support/overlay_red.lut support/overlay_yellow.lut support/rainbow.lut support/ramps.lut support/README support/red.lut support/regions1.lut support/regions.lut support/rgb.lut support/rg.lut support/spectrum.lut support/spiral.lut support/std_grey.lut tmpMsg.hxx TODO toolbar.cxx toolbar.hxx transferBox.cxx transferBox.hxx transferFunctionBox.cxx transferFunctionBox.hxx transferFunction.cxx transferFunction.hxx transferHistoBox.cxx transferHistoBox.hxx transferRGBBox.cxx transferRGBBox.hxx transferRGBFunctionBox.cxx transferRGBFunctionBox.hxx transferRGBFunction.cxx transferRGBFunction.hxx transferRGBHistoBox.cxx transferRGBHistoBox.hxx userPrefs.cxx userPrefs.hxx ���������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/menubar.cxx���������������������������������������������������������������������������0000644�0000765�0000765�00000072172�10720351523�016157� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: menubar.cxx,v 4.11 2007/11/19 18:17:55 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The menu portion of imView, an image viewer program for X11 * by Hugues Talbot 26 Oct 1997 * * This program is available free of charge for anyone to use under no * guarantee of any kind, expressed or implied. * *-----------------------------------------------------------------------*/ #include <FL/Fl.H> #include <FL/Fl_Box.H> #include <FL/Fl_Window.H> #include <FL/Fl_Menu_Bar.H> #include <FL/Fl_Sys_Menu_Bar.H> // system menubar (for macs) #include <FL/Fl_Box.H> #include <FL/Fl_File_Chooser.H> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "imview.hxx" #include "imageIO.hxx" #include "pointfile.hxx" #include "imageViewer.hxx" #include "menubar.hxx" // components of the application extern imageViewer *mainViewer; extern char appName[]; extern imViewMenuBar *mainMenuBar; extern imageIO *IOBlackBox; extern pointfile *PtFileMngr; // other global flags extern int debugIsOn; extern int stopDebug; extern bool lutWraparound; extern volatile bool syncDisplay; extern bool disableMainMenu; extern int makeImageCharIfFits; extern int RGBdisplaysRGB; extern int fitCharOverAllSamples; extern int fitCharOverAllSlices; extern bool hideMainMenu; extern bool fullScreen; extern displaymode displaymodepref; // went the easy way on that one: extern double persistentGamma; imViewMenuBar::imViewMenuBar(int x, int y, int w, int h, const char *label) : Fl_Menu_Bar(x,y,w,h,label) { int i, menusize; Fl_Menu_Item startmenu[] = { // this menu is only temporary {"&File", 0, 0, 0, FL_SUBMENU}, {"Open", FL_COMMAND+'o', open_cb}, {CLOSE_ITEM, FL_COMMAND+'c', close_cb, 0, FL_PUP_GREY}, {SAVE_ITEM, FL_COMMAND+'s', save_cb, 0, FL_PUP_GREY}, {OVERLAY_SUBMENU, 0, 0, 0, FL_PUP_GREY | FL_SUBMENU | FL_MENU_DIVIDER}, {OPEN_OVERLAY_ITEM, FL_ALT+'v', openoverlay_cb, 0, 0}, {CLOSE_OVERLAY_ITEM, FL_ALT+'c', closeoverlay_cb, 0, 0}, {0}, {PRINTPREFS_ITEM, FL_COMMAND+FL_SHIFT+'p', printprefs_cb, 0, FL_PUP_GREY | FL_MENU_DIVIDER}, {"Quit", FL_COMMAND+'q', quit_cb}, {0}, {"&Edit", 0, 0, 0, FL_SUBMENU}, {"Undo", 0, test_cb, 0, FL_PUP_GREY}, {"Quick &options", 0, 0, 0, FL_SUBMENU}, {"Display mode", 0, 0, 0, FL_SUBMENU}, {WIN_FIT_IMG_ITEM, 0, displaymode_cb, (void*)IMV_DISPLAY_WINDOW_FIT_IMG, FL_MENU_RADIO | (displaymodepref == IMV_DISPLAY_WINDOW_FIT_IMG) ? FL_MENU_VALUE:0}, {IMG_FIT_WIN_ITEM, 0, displaymode_cb, (void*)IMV_DISPLAY_IMG_FIT_WINDOW, FL_MENU_RADIO | (displaymodepref == IMV_DISPLAY_IMG_FIT_WINDOW) ? FL_MENU_VALUE:0}, {DECOUPLE_IMG_WIN_ITEM, 0, displaymode_cb, (void*)IMV_DISPLAY_DECOUPLE_WIN_IMG, FL_MENU_RADIO | FL_MENU_DIVIDER | (displaymodepref == IMV_DISPLAY_DECOUPLE_WIN_IMG) ? FL_MENU_VALUE:0}, {"Fullscreen", 0, preference_cb, (void *)PREF_FULLSCREEN, FL_PUP_BOX | (fullScreen ? FL_MENU_VALUE:0)}, {0}, {"Hide main menu bar", FL_COMMAND+'m', preference_cb, (void *)PREF_HIDEMENU, FL_PUP_BOX | (hideMainMenu ? FL_MENU_VALUE:0)}, {WRAPLUT_ITEM, 0, preference_cb, (void *)PREF_WRAPAROUND, FL_PUP_BOX | (lutWraparound ? FL_MENU_VALUE:0)}, {SYNCDISP_ITEM, 0, preference_cb, (void *)PREF_SYNCDISP, FL_PUP_BOX | (syncDisplay ? FL_MENU_VALUE:0)}, {"Cast to CHAR if possible", 0, preference_cb, (void *)PREF_MAKECHAR, FL_PUP_BOX | (makeImageCharIfFits ? FL_MENU_VALUE:0)}, {"RGB images display as RGB", 0, preference_cb, (void *)PREF_RGBRGB, FL_PUP_BOX | (RGBdisplaysRGB ? FL_MENU_VALUE:0) }, {"Fit to CHAR over all samples", 0, preference_cb, (void *)PREF_FITALL, FL_PUP_BOX | (fitCharOverAllSamples ? FL_MENU_VALUE:0) }, {"Fit to CHAR over all slices (3D)", 0, preference_cb, (void *)PREF_FIT3D, FL_PUP_BOX | (fitCharOverAllSlices ? FL_MENU_VALUE:0) | FL_MENU_DIVIDER }, // {"Smooth when zooming out", 0, preference_cb, (void *)PREF_SMOOTHUNZOOM, FL_PUP_BOX}, {"Show warnings", FL_COMMAND+FL_SHIFT+'w', preference_cb, (void *)PREF_WARNING, 0}, {"Enable debug messages", FL_ALT+FL_SHIFT+'g', preference_cb, (void *)PREF_DEBUG, FL_PUP_BOX | (debugIsOn? FL_MENU_VALUE:0)}, {"Stop after debug messages", FL_ALT+FL_SHIFT+'s', preference_cb, (void *)PREF_STOPDEBUG, FL_PUP_BOX | (stopDebug ? FL_MENU_VALUE:0)}, // {"Keep points when switching images", FL_ALT+'K', preference_cb, (void *)PREF_KEEPPOINTS, FL_PUP_BOX | FL_MENU_DIVIDER}, // {"Change XOR value for lines...", 0, setxorvalue_cb, 0, 0}, {0}, {"&User preferences...", 0, userprefspanel_cb}, {0}, {"&Transform", 0, 0, 0, FL_SUBMENU}, {"Toolbar...", FL_COMMAND+FL_SHIFT+'t', toolbar_cb, 0, FL_MENU_DIVIDER}, {COLOURMAP_ITEM, 0, 0, 0, FL_PUP_GREY | FL_SUBMENU}, {CLUT_LIST_BEGIN, FL_COMMAND+FL_SHIFT+'c', noclut_cb, 0, 0}, /* rest of CLUT list comes here */ {0}, {"Zoom", 0, 0, 0, FL_SUBMENU}, {"Zoom in 100%", FL_COMMAND+'>', zoomin_cb}, {"Zoom in 10%", FL_COMMAND+'.', smallzoomin_cb}, {"Zoom out 100%", FL_COMMAND+'<', zoomout_cb}, {"Zoom out 10%", FL_COMMAND+',', smallzoomout_cb}, {"Set this zoom factor as default", FL_COMMAND+'\'', thiszoom_cb}, {"Select zoom factor...", FL_COMMAND+'z', selectzoom_cb}, {"Select default zoom factor...", FL_COMMAND+FL_SHIFT+'z', selectdefaultzoom_cb}, {"Apply default zoom factor", FL_COMMAND+'n', unzoom_cb}, {0}, {"Rotate", 0, 0, 0, FL_SUBMENU}, {"Right 90 degree", FL_COMMAND+'(', rotate90right_cb}, {"Left 90 degree", FL_COMMAND+')', rotate90left_cb}, {"180 degree", FL_COMMAND+'+', rotate180_cb}, {ROTATE3DMENU_ITEM, 0, 0, 0, FL_SUBMENU|FL_PUP_INVISIBLE}, {"Up 90 degree", 0, rotate3dup_cb}, {"Down 90 degree", 0, rotate3ddown_cb}, {0}, {0}, {"Flip", 0, 0, 0, FL_SUBMENU}, {"Vertically", FL_COMMAND+'|', flipv_cb}, {"Horizontally", FL_COMMAND+'_', fliph_cb}, {0}, {"Pointfile", 0, 0, 0, FL_SUBMENU}, {"Add point mode", FL_ALT+'g', mode_cb, (void *)MODE_POINTFILE, FL_PUP_BOX | FL_MENU_DIVIDER}, {"Open existing pointfile...", FL_ALT+'p', openpointfile_cb}, {"New pointfile", FL_COMMAND+'p', newpointfile_cb}, {"Save current pointfile", FL_COMMAND+FL_SHIFT+'p', closepointfile_cb}, {"Delete all points", FL_COMMAND+FL_SHIFT+'d', deleteallpoints_cb}, {"Delete last point", FL_COMMAND+'d', deletelastpoint_cb}, {0}, {"Histogram", 0, 0, 0, FL_SUBMENU}, {"Contrast-Brightness", FL_COMMAND+'b', transfer_cb}, {RGBTRANSFER_ITEM, FL_COMMAND+FL_SHIFT+'b', transferRGB_cb, 0, FL_PUP_INVISIBLE}, {BIVHIST_ITEM, FL_COMMAND+'L', showbivhist_cb, 0, FL_PUP_INVISIBLE}, {"Interactive thresholding", FL_COMMAND+'h', threshold_cb, 0, FL_PUP_GREY}, {0}, {0}, {"&Image", 0, 0, 0, FL_SUBMENU}, {"Information...",FL_COMMAND+FL_SHIFT+'i', imageinfo_cb}, {"1-D profile...", FL_COMMAND+'1', showprofile_cb, 0, FL_MENU_DIVIDER}, {"Server", 0, 0, 0, FL_SUBMENU|FL_MENU_DIVIDER}, {"Progress", 0, showprogress_cb, 0, 0}, {"Start", 0, startserver_cb, 0, FL_PUP_INVISIBLE}, {"Stop", 0, stopserver_cb, 0, FL_PUP_INVISIBLE}, {0}, #ifdef MACOSX_CARBON // layout is sufficiently different {VIEW3D_ITEM, FL_ALT+'3', showview3d_cb, 0, FL_PUP_INVISIBLE|FL_MENU_DIVIDER}, {HYPERSPECTRAL_ITEM, FL_COMMAND+FL_SHIFT+'s', showspectrum_cb, 0, FL_PUP_INVISIBLE}, {NEXTCOMPONENT_ITEM, FL_COMMAND+'2', nextcomponent_cb, 0, FL_PUP_INVISIBLE}, {PREVIOUSCOMPONENT_ITEM, FL_COMMAND+'3', previouscomponent_cb, 0, FL_PUP_INVISIBLE}, {SELECTCOMPONENT_ITEM, FL_COMMAND+'4', selectcomponent_cb, 0, FL_PUP_INVISIBLE | FL_MENU_DIVIDER}, {DEPTHPROFILE_ITEM, FL_COMMAND+FL_SHIFT+'d', showdepthprofile_cb, 0, FL_PUP_INVISIBLE}, {NEXTPLANE_ITEM, FL_COMMAND+'5', nextplane_cb, 0, FL_PUP_INVISIBLE}, {PREVIOUSPLANE_ITEM, FL_COMMAND+'6', previousplane_cb, 0, FL_PUP_INVISIBLE}, {SELECTPLANE_ITEM, FL_COMMAND+'7', selectplane_cb, 0, FL_PUP_INVISIBLE | FL_MENU_DIVIDER}, {NEXTFRAME_ITEM, FL_COMMAND+'8', nextframe_cb, 0, FL_PUP_INVISIBLE}, {PREVIOUSFRAME_ITEM, FL_COMMAND+'9', previousframe_cb, 0, FL_PUP_INVISIBLE}, {SELECTFRAME_ITEM, FL_COMMAND+'0', selectframe_cb, 0, FL_PUP_INVISIBLE | FL_MENU_DIVIDER}, {NEXTIMAGE_ITEM, ' ', nextimage_cb, 0, FL_PUP_GREY}, {PREVIOUSIMAGE_ITEM, FL_SHIFT+' ', previousimage_cb, 0, FL_PUP_GREY | FL_MENU_DIVIDER}, {IMAGE_LIST_BEGIN, 0, 0, 0, FL_PUP_GREY | FL_SUBMENU}, #else {VIEW3D_ITEM, FL_COMMAND+'3', showview3d_cb, 0, FL_PUP_INVISIBLE|FL_MENU_DIVIDER}, {HYPERSPECTRAL_ITEM, FL_COMMAND+FL_SHIFT+'s', showspectrum_cb, 0, FL_PUP_INVISIBLE}, {NEXTCOMPONENT_ITEM, FL_Home, nextcomponent_cb, 0, FL_PUP_INVISIBLE}, {PREVIOUSCOMPONENT_ITEM, FL_End, previouscomponent_cb, 0, FL_PUP_INVISIBLE}, {SELECTCOMPONENT_ITEM, FL_Scroll_Lock, selectcomponent_cb, 0, FL_PUP_INVISIBLE | FL_MENU_DIVIDER}, {DEPTHPROFILE_ITEM, FL_COMMAND+FL_SHIFT+'d', showdepthprofile_cb, 0, FL_PUP_INVISIBLE}, {NEXTPLANE_ITEM, FL_Insert, nextplane_cb, 0, FL_PUP_INVISIBLE}, {PREVIOUSPLANE_ITEM, FL_Delete, previousplane_cb, 0, FL_PUP_INVISIBLE}, {SELECTPLANE_ITEM, FL_Print, selectplane_cb, 0, FL_PUP_INVISIBLE | FL_MENU_DIVIDER}, {NEXTFRAME_ITEM, FL_Page_Up, nextframe_cb, 0, FL_PUP_INVISIBLE}, {PREVIOUSFRAME_ITEM, FL_Page_Down, previousframe_cb, 0, FL_PUP_INVISIBLE}, {SELECTFRAME_ITEM, FL_Pause, selectframe_cb, 0, FL_PUP_INVISIBLE | FL_MENU_DIVIDER}, {NEXTIMAGE_ITEM, ' ', nextimage_cb, 0, FL_PUP_GREY}, {PREVIOUSIMAGE_ITEM, FL_SHIFT+' ', previousimage_cb, 0, FL_PUP_GREY | FL_MENU_DIVIDER}, {IMAGE_LIST_BEGIN, 0, 0, 0, FL_PUP_GREY | FL_SUBMENU}, #endif /* originally empty image list goes here */ {0}, {0}, {"&Help", 0, 0, 0, FL_SUBMENU}, {"About imview...", 0, whodunit_cb, 0, FL_MENU_DIVIDER}, {"Quick online help", '?', onlinehelp_cb, 0, 0}, {"Full HTML documentation", FL_COMMAND+'?', fulldocument_cb, 0, FL_MENU_DIVIDER}, {"Licence...", 0, licence_cb, 0, 0}, {"No warranty...", 0, warranty_cb, 0, 0}, {0}, {0} }; dbgprintf("imViewMenuBar constructed\n"); // set things up for the image list listName[IMAGE_LIST_ID] = IMAGE_LIST_BEGIN; listCallback[IMAGE_LIST_ID] = (void *)image_cb; // set things up for the colour LUT list listName[CLUT_LIST_ID] = CLUT_LIST_BEGIN; listCallback[CLUT_LIST_ID] = (void *)clut_cb; // Create the start menu menu(startmenu); // allocated the dynamic menu menusize = size(); dbgprintf("Menu size = %d\n", menusize); dynamicMenu = new Fl_Menu_Item[menusize]; for (i = 0 ; i < menusize ; i++) { dynamicMenu[i] = startmenu[i]; if (disableMainMenu) { dynamicMenu[i].flags |= FL_MENU_INACTIVE; } } menu(dynamicMenu); // from now on we can forget about the old menu nbImagesInList = 0; return; } imViewMenuBar::~imViewMenuBar() { delete[] dynamicMenu; dbgprintf("Menu bar destructor called\n"); } // The System menu can currently be set only once // Call this to set it, once the main menu has been // put together relatively completely. void imViewMenuBar::setSysMenu(void) { int menusize = size(); staticMenu_ = new Fl_Menu_Item[menusize]; for (int i = 0 ; i < menusize ; ++i) { // copy and activate staticMenu_[i] = dynamicMenu[i]; staticMenu_[i].flags &= ~(FL_PUP_GREY | FL_MENU_INACTIVE); } sysmenu_ = new Fl_Sys_Menu_Bar(x(),y(),w(),h()); sysmenu_->menu(staticMenu_); return; } void imViewMenuBar::draw() { // if (hideMainMenu) // resize(x(),y(),w(),0); // ?? //else // resize(x(),y(),w(),MENUHEIGHT); Fl_Menu_Bar::draw(); } // returns 1 if the item is effectively added to the list // 0 otherwise (item already in item list or invalid) int imViewMenuBar::addToItemList(const char *newImagePath, int listID) { int i, j, res = 0; int newSize; const char *shortname; Fl_Menu_Item *oldMenu; IMAGEPARM *itx; if ((newImagePath[0] != '\0') && (!isAlreadyInItemList(newImagePath,listID))) { oldMenu = dynamicMenu; dbgprintf("adding %s to the %s list\n", newImagePath, listName[listID]); newSize = size() + 1; dbgprintf("Menu will have %d items\n", newSize); dynamicMenu = new Fl_Menu_Item[newSize]; for (i = 0, j = 0 ; i < newSize-1 ; i++, j++) { dynamicMenu[j] = oldMenu[i]; if ((oldMenu[i].label() != 0) && (strcmp(oldMenu[i].label(), listName[listID]) == 0)) { // activate the current item dynamicMenu[j].flags &= ~FL_MENU_INACTIVE; i++; j++; // go to the next field // look for the `0' finishing the menu for ( ; i < newSize-1 ; i++, j++) { dynamicMenu[j] = oldMenu[i]; // keep filling the menu if ((dynamicMenu[j].label() != 0) && (dynamicMenu[j].callback() == (Fl_Callback *)listCallback[listID])) { // uncheck the check box for those items dynamicMenu[j].flags &= ~FL_PUP_CHECK; } else break; } // fill the new struct by hand itx = new IMAGEPARM; itx->itempath = strdup(newImagePath); itx->clutpath = 0; itx->ovlpath = 0; itx->pfpath = 0; itx->gamma = persistentGamma; // may not be 1.0! itx->contrast = 0.5; itx->brightness = 0.5; itx->Rgamma = itx->Ggamma = itx->Bgamma = itx->gamma; itx->Rcontrast = itx->Gcontrast = itx->Bcontrast = itx->contrast; itx->Rbrightness = itx->Gbrightness = itx->Bbrightness = itx->brightness; itx->zslice = 0; itx->comp = 0; itx->frame = 0; itx->nbframes = 0; itx->angle = 0; itx->mirror = 0; itx->next = 0; shortname = strrchr(itx->itempath, '/'); // look for the last `/' if (shortname == NULL) shortname = itx->itempath; // revert to full name if name is local else shortname++; // go beyond the last `/' dynamicMenu[j+1] = oldMenu[i]; dynamicMenu[j] = dynamicMenu[0]; // to reset all the fields dynamicMenu[j].label(shortname); dynamicMenu[j].shortcut(0); dynamicMenu[j].callback((Fl_Callback *)(listCallback[listID])); dynamicMenu[j].user_data((void *)itx); dynamicMenu[j].flags = (FL_PUP_BOX | FL_PUP_CHECK); // advance to the next one j++; } } // specific issue for separate lists if (listID == IMAGE_LIST_ID) { // we have positively added an item to the image menu, therefore // the `close' item can be enabled setFlagsByName(CLOSE_ITEM, 0, dynamicMenu, newSize); setFlagsByName(SAVE_ITEM, 0, dynamicMenu, newSize); setFlagsByName(OVERLAY_SUBMENU, FL_SUBMENU | FL_MENU_DIVIDER, dynamicMenu, newSize); setFlagsByName(PRINTPREFS_ITEM, FL_MENU_DIVIDER, dynamicMenu, newSize); // as well as the colour map button setFlagsByName(COLOURMAP_ITEM, FL_SUBMENU, dynamicMenu, newSize); // increase the counter of images in the list nbImagesInList++; } delete[] oldMenu; menu(dynamicMenu); int sz = size(); dbgprintf("Menu size is now: %d\n", sz); redraw(); res = 1; // yes, we have added an item } else { // isAlreadyInItemList(newImagePath,listID) is true // either the image is already in the image list: we only have to check the right item // or the newImagePath argument is the empty string. In this case // we want to unselect all the items. int sz = size(); for (i = 0 ; i < sz ; i++) { if ((dynamicMenu[i].label() != 0) && (dynamicMenu[i].callback() == (Fl_Callback *)listCallback[listID])) { dynamicMenu[i].flags &= ~FL_PUP_CHECK; if (((unsigned long) dynamicMenu[i].user_data() > LAST_INT_ARG) && (strcmp((char*)((IMAGEPARM *)dynamicMenu[i].user_data())->itempath, newImagePath) == 0)) dynamicMenu[i].flags |= FL_PUP_CHECK; } } } return res; } void imViewMenuBar::removeFromItemList(const char *oldImagePath, int listID) { int i, j; int newSize; Fl_Menu_Item *oldMenu; char *to_be_freed_later = 0; if (isAlreadyInItemList(oldImagePath,listID)) { // this is fine, we can remove it from the list! oldMenu = dynamicMenu; dbgprintf("removing %s from the image list\n", oldImagePath); newSize = size() - 1 ; dbgprintf("Menu will have %d items\n", newSize); dynamicMenu = new Fl_Menu_Item[newSize]; for (i = 0, j = 0 ; i <= newSize ; i++, j++) { if (((unsigned long)oldMenu[i].user_data() > LAST_INT_ARG) && (strcmp(((IMAGEPARM *)oldMenu[i].user_data())->itempath, oldImagePath) == 0)) { // now selects the closest image in the image list if (oldMenu[i+1].label() != 0) { // the next image down the list gets selected oldMenu[i+1].flags |= (FL_PUP_BOX | FL_PUP_CHECK); // copy to dynamicMenu will occur later } else if ((oldMenu[i-1].label() != 0) && (strcmp(oldMenu[i-1].label(), listName[listID]) != 0)) { // the previous image up the list gets selected dynamicMenu[i-1].flags |= (FL_PUP_BOX | FL_PUP_CHECK); } else { // the image we remove was the last on the list, disable `Image' menu dynamicMenu[i-1].flags |= (FL_PUP_GREY); if (listID == IMAGE_LIST_ID) { // disable the `close' item setFlagsByName(CLOSE_ITEM, FL_PUP_GREY, dynamicMenu, newSize); setFlagsByName(SAVE_ITEM, FL_PUP_GREY, dynamicMenu, newSize); setFlagsByName(OVERLAY_SUBMENU, FL_PUP_GREY | FL_SUBMENU | FL_MENU_DIVIDER, dynamicMenu, newSize); setFlagsByName(PRINTPREFS_ITEM, FL_PUP_GREY | FL_MENU_DIVIDER, dynamicMenu, newSize); // and the Colourmap item setFlagsByName(COLOURMAP_ITEM, FL_PUP_GREY | FL_SUBMENU, dynamicMenu, newSize); } } // this had been strdup'ed IMAGEPARM *pp = (IMAGEPARM *)oldMenu[i].user_data(); if (pp->itempath != oldImagePath) { // we need the old path a bit longer. free(pp->itempath); pp->itempath = 0; } else { to_be_freed_later = pp->itempath; // man, isn't that dangerous? } if (pp->ovlpath) { free(pp->ovlpath); pp->ovlpath = 0; } if (pp->pfpath) { free(pp->pfpath); pp->pfpath = 0; } // this had been new'ed delete (IMAGEPARM *)oldMenu[i].user_data(); //oldMenu[i].argument = 0; // otherwise FL will think it is still there... //oldMenu[i].text = 0; // this was a substring allocated in the argument // skip the name i++; } // business as usual dynamicMenu[j] = oldMenu[i]; } delete[] oldMenu; menu(dynamicMenu); int sz = size(); dbgprintf("Menu size after deletion is now: %d\n", sz); // one more dangerous thing to do if (to_be_freed_later != 0) { free(to_be_freed_later); to_be_freed_later = 0; } redraw(); } // we've got nothing to do, the name in question is not in the list return; } int imViewMenuBar::isAlreadyInItemList(const char *newImagePath, int listID) { int res = 0; int i; dbgprintf("Checking if new name already in %s\n", listName[listID]); if (newImagePath) { // check that a name was actually given... for (i = 0 ; i < size() ; i++) if ((dynamicMenu[i].label() != 0) && (strcmp(dynamicMenu[i].label(), listName[listID]) == 0)) { i++; break; } if (i != size()) { for ( ; (unsigned long)dynamicMenu[i].user_data() > LAST_INT_ARG ; i++) { if (strcmp(((IMAGEPARM *)dynamicMenu[i].user_data())->itempath, newImagePath) == 0) { dbgprintf("Name %s is already in list at position %d\n", newImagePath, i); res = 1; // the new name is already in the list break; } } } } return res; } // return the first item matching the given label void *imViewMenuBar::getItemByLabel(const char *givenLbl, int listID) { void *res = 0; int i; dbgprintf("Looking for %s in list %s\n", givenLbl, listName[listID]); if (givenLbl) { // check that a name was actually given... for (i = 0 ; i < size() ; i++) if ((dynamicMenu[i].label() != 0) && (strcmp(dynamicMenu[i].label(), listName[listID]) == 0)) { i++; break; } if (i != size()) { for ( ; (unsigned long)dynamicMenu[i].user_data() > LAST_INT_ARG ; i++) { if (strcmp(dynamicMenu[i].label(), givenLbl) == 0) { dbgprintf("Found %s in list at position %d\n", givenLbl, i); res = (void*)dynamicMenu[i].user_data(); // the label was found, first item returned. break; } } } } return res; } char *imViewMenuBar::getItemListContent(int listID, int &nbitems) { int i, j, outlength, sz; char *res = 0; nbitems = 0; dbgprintf("Saving the content of list #%d to a string\n", listID); sz = size(); for (i = 0 ; i < sz ; i++) if ((dynamicMenu[i].label() != 0) && (strcmp(dynamicMenu[i].label(), listName[listID]) == 0)) { i++; break; } if (i != size()) { for (j = i, outlength = 0 ; (unsigned long)dynamicMenu[j].user_data() > LAST_INT_ARG ; j++) outlength += strlen(((IMAGEPARM *)dynamicMenu[j].user_data())->itempath); if (outlength > 0) { res = new char[outlength+j+1]; res[0] = '\0'; for (j = i ; (unsigned long)dynamicMenu[j].user_data() > LAST_INT_ARG ; j++) { strcat(res, ((IMAGEPARM *)dynamicMenu[j].user_data())->itempath); strcat(res, "\n"); nbitems++; } } } return res; } void *imViewMenuBar::getSelectedItemArgument(int listID) { void *res = 0; int i, sz; dbgprintf("Looking for path of image being currently selected\n"); sz = size(); // look for where the image list begins for (i = 0 ; i < sz; i++) { if ((dynamicMenu[i].label() != 0) && (strcmp(dynamicMenu[i].label(), listName[listID]) == 0)) { i++; break; } } if (i != sz) { for ( ; dynamicMenu[i].label() != 0 ; i++) { if (dynamicMenu[i].flags == (FL_PUP_BOX | FL_PUP_CHECK)) { res = (void *)dynamicMenu[i].user_data(); // the new name is already in the list break; } } } return res; } Fl_Menu_Item *imViewMenuBar::getSelectedMenuItem(int listID) { int i; Fl_Menu_Item *res = 0; dbgprintf("Looking for menu item currently selected in list %s\n", listName[listID]); // look for where the image list begins for (i = 0 ; i < size(); i++) if ((dynamicMenu[i].label() != 0) && (strcmp(dynamicMenu[i].label(), listName[listID]) == 0)) { i++; break; } if (i != size()) { for ( ; dynamicMenu[i].label() != 0 ; i++) { if (dynamicMenu[i].flags == (FL_PUP_BOX | FL_PUP_CHECK)) { res = dynamicMenu+i; // the new name is already in the list break; } } } return res; } // returns the argument to the next image in the image list if possible // else returns the argument to the first image, and otherwise returns NULL void *imViewMenuBar::getNextItemInList(int listID) { void *res = 0; int i, startimage; // look for where the image list begins for (i = 0 ; i < size(); i++) if ((dynamicMenu[i].label() != 0) && (strcmp(dynamicMenu[i].label(), listName[listID]) == 0)) { i++; break; } startimage = i; if (i != size()) { for ( ; dynamicMenu[i].label() != 0 ; i++) { // look for the image name that is currently checked if (dynamicMenu[i].flags == (FL_PUP_BOX | FL_PUP_CHECK)) { if (dynamicMenu[i+1].label() != 0) res = (void *)dynamicMenu[i+1].user_data(); // open next one on the list else if (dynamicMenu[startimage].label() != 0) res = (void *)dynamicMenu[startimage].user_data(); // open first image on the list break; } } } return res; } // returns the path to the next image in the image list if possible // else returns the path to the first image, and otherwise returns NULL void *imViewMenuBar::getPreviousItemInList(int listID) { void *res = 0; int i, lastimage, checkedimage; // look for where the image list begins for (i = 0 ; i < size(); i++) if ((dynamicMenu[i].label() != 0) && (strcmp(dynamicMenu[i].label(), listName[listID]) == 0)) { i++; break; } checkedimage = 0; // look for the last image for ( ; dynamicMenu[i].label() != 0 ; i++) { if (dynamicMenu[i].flags == (FL_PUP_BOX | FL_PUP_CHECK)) { checkedimage = i; } } lastimage = i-1; if (checkedimage != 0) { if ((dynamicMenu[checkedimage-1].label() != 0) && (strcmp(dynamicMenu[checkedimage-1].label(), listName[listID]) != 0)) res = (void *)dynamicMenu[checkedimage-1].user_data(); // open previous one on the list else if (dynamicMenu[lastimage].label() != 0) res = (void *)dynamicMenu[lastimage].user_data(); // open last image on the list else res = 0; } return res; } // this functions hunts for a named menu element and returns its flags int imViewMenuBar::getFlagsByName(const char *theName, Fl_Menu_Item *currentMenu, int menuSize) { int i, theFlags = -1; if (currentMenu == 0) currentMenu = dynamicMenu; if (menuSize == 0) menuSize = size(); for (i = 0 ; i < menuSize ; i++) if ((currentMenu[i].label() != 0) && (strcmp(currentMenu[i].label(), (char *)theName) == 0)) { theFlags = currentMenu[i].flags; break; // only change the first occurence... Normally no two menu items have the same name } return theFlags; } // this functions hunts for a named menu element and changes its flags void imViewMenuBar::setFlagsByName(const char *theName, int theFlags, Fl_Menu_Item *currentMenu, int menuSize) { int i; if (currentMenu == 0) currentMenu = dynamicMenu; if (menuSize == 0) menuSize = size(); for (i = 0 ; i < menuSize ; i++) if ((currentMenu[i].label() != 0) && (strcmp(currentMenu[i].label(), (char *)theName) == 0)) { currentMenu[i].flags = theFlags; break; // only change the first occurence... Normally no two menu items have the same name } return; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/menubar.hxx���������������������������������������������������������������������������0000644�0000765�0000765�00000022522�10637222145�016162� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: menubar.hxx,v 4.10 2007/06/23 13:47:17 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The application main menu * * Hugues Talbot 16 Nov 1997 * *-----------------------------------------------------------------------*/ #ifndef MENUBAR_H #define MENUBAR_H #ifndef Fl_Object_H #include <FL/Fl_Object.H> #endif #include <FL/Fl.H> #include <FL/Fl_Menu_Bar.H> #include <FL/Fl_Sys_Menu_Bar.H> #define IMAGE_LIST_ID 0 #define CLUT_LIST_ID 1 #define LAST_LIST_ID 2 #define ONLINEHELP "quickhelp.html" #define LICENSE "gpl.html" #define WARRANTY "warranty.html" #define HELPURL "http://extra.cmis.csiro.au/IA/talbot/ee02only/imview/" #define IMAGE_LIST_BEGIN "Image list" #define CLUT_LIST_BEGIN "Default Colourmap" // menu items that have variable flags, for which // their name is important #define NEXTIMAGE_ITEM "Next image" #define PREVIOUSIMAGE_ITEM "Previous image" #define OVERLAY_SUBMENU "Overlay" #define OPEN_OVERLAY_ITEM "Open overlay" #define CLOSE_OVERLAY_ITEM "Close overlay" #define CLOSE_ITEM "Close" #define SAVE_ITEM "Save" #define PRINTPREFS_ITEM "Print" #define WRAPLUT_ITEM "Wraparound LUT" #define SYNCDISP_ITEM "Synchronize display" #define COLOURMAP_ITEM "Colourmap" #define VIEW3D_ITEM "View 3D" #define ROTATE3DMENU_ITEM "3D rotate" #define NEXTCOMPONENT_ITEM "Next sample" #define PREVIOUSCOMPONENT_ITEM "Previous sample" #define SELECTCOMPONENT_ITEM "Select sample" #define HYPERSPECTRAL_ITEM "Show spectrum" #define DEPTHPROFILE_ITEM "Show depth profile" #define RGBTRANSFER_ITEM "RGB contrast/brightness" #define BIVHIST_ITEM "Bivariate histogram" #define NEXTPLANE_ITEM "Next plane" #define PREVIOUSPLANE_ITEM "Previous plane" #define SELECTPLANE_ITEM "Select plane" #define NEXTFRAME_ITEM "Next frame" #define PREVIOUSFRAME_ITEM "Previous frame" #define SELECTFRAME_ITEM "Select frame" #define WIN_FIT_IMG_ITEM "Fit &window to image" #define IMG_FIT_WIN_ITEM "Fit &image to window" #define DECOUPLE_IMG_WIN_ITEM "&De-coupled image and window" // preference definition enum imview_quickpref { PREF_SMOOTHUNZOOM = 0, // smooth when unzooming PREF_DEBUG, // debug on/off PREF_KEEPPOINTS, // keep point when switching images (or not) PREF_STOPDEBUG, // stop after each debug message (not recommended!) PREF_WARNING, // show warnings PREF_WRAPAROUND, // make the LUT wrap around after 255 rather than fit to min/max PREF_MAKECHAR, // make images CHAR if no data is lost that way (the non-char data fits into chars) PREF_RGBRGB, // RGB images are displayed as RGB, not as multi-spectral images PREF_FITALL, // fit grey-levels/colours over all samples, not just the one displayed PREF_FIT3D, // fit grey-level/colours over all slices PREF_SYNCDISP, // synchronize display with the imview server PREF_HIDEMENU, // totally hide the main menu PREF_FULLSCREEN, // fullscreen mode LAST_INT_ARG, // END marker. }; #define MODE_POINTFILE 0 // apparently all the callbacks have to be global functions void openfile_cb(const char *s); void test_cb(Fl_Object *,void *i); void open_cb(Fl_Object *, void *); void openoverlay_cb(Fl_Object *, void *); void closeoverlay_cb(Fl_Object *, void *); void save_cb(Fl_Object *, void *); void printprefs_cb(Fl_Object *, void *); void close_cb(Fl_Object *, void *); // help void whodunit_cb(Fl_Object *, void *); void onlinehelp_cb(Fl_Object *, void *); void fulldocument_cb(Fl_Object *, void *); void licence_cb(Fl_Object *, void *); void warranty_cb(Fl_Object *, void *); // histogram void transfer_cb(Fl_Object *, void *); void transferRGB_cb(Fl_Object *, void *); void threshold_cb(Fl_Object *, void *); // zoom void zoomin_cb(Fl_Object *,void *); void zoomout_cb(Fl_Object *,void *); void smallzoomin_cb(Fl_Object *,void *); void smallzoomout_cb(Fl_Object *,void *); void unzoom_cb(Fl_Object *,void *); void selectzoom_cb(Fl_Object *, void *); void thiszoom_cb(Fl_Object *, void *); void selectdefaultzoom_cb(Fl_Object *, void *); // 3D viewer void showview3d_cb(Fl_Object *, void *); // rotations & flips void rotate90right_cb(Fl_Object *, void *); void rotate90left_cb(Fl_Object *, void *); void rotate180_cb(Fl_Object *, void *); void rotate3dup_cb(Fl_Object *, void *); void rotate3ddown_cb(Fl_Object *, void *); void flipv_cb(Fl_Object *, void *); void fliph_cb(Fl_Object *, void *); // image list manipulation void image_cb(Fl_Object *, void *); void nextimage_cb(Fl_Object *, void *arg); void previousimage_cb(Fl_Object *, void *arg); void saveimagelist_cb(Fl_Object *, void *); // various manipulation on images void nextcomponent_cb(Fl_Object *, void *); void previouscomponent_cb(Fl_Object *, void *); void showprofile_cb(Fl_Object *, void *); void showspectrum_cb(Fl_Object *, void *); void showbivhist_cb(Fl_Object *, void *); void setcomponentvalue(int v); void selectcomponent_cb(Fl_Object *, void *); void showdepthprofile_cb(Fl_Object *, void *); void nextplane_cb(Fl_Object *, void *); void previousplane_cb(Fl_Object *, void *); void setplanevalue(int v); void selectplane_cb(Fl_Object *, void *); void setframevalue(int v); void nextframe_cb(Fl_Object *, void *); void previousframe_cb(Fl_Object *, void *); void selectframe_cb(Fl_Object *, void *); void imageinfo_cb(Fl_Object *, void *); void toolbar_cb(Fl_Object *, void *); int setClut(const char *label); // Hmmm void clut_cb(Fl_Object *,void *); void noclut_cb(Fl_Object *,void *); void mode_cb(Fl_Object *,void *); // user preferences void userprefspanel_cb(Fl_Object *, void *); void preference_cb(Fl_Object *,void *); void displaymode_cb(Fl_Object *,void *); void fullscreen_cb(Fl_Object *,void *); void hidemainmenu_cb(Fl_Object *, void *arg); void showmainmenu_cb(Fl_Object *, void *arg); // pointfiles void openpointfile_cb(Fl_Object *,void *); void newpointfile_cb(Fl_Object *, void *); void closepointfile_cb(Fl_Object *,void *); void deleteallpoints_cb(Fl_Object *,void *); void deletelastpoint_cb(Fl_Object *,void *); void setxorvalue_cb(Fl_Object *,void *); // server void startserver_cb(Fl_Object *, void *); void stopserver_cb(Fl_Object *, void *); void showprogress_cb(Fl_Object *, void *); // graceful exit void quit_cb(Fl_Object *,void *); void noquit_cb(Fl_Object *,void *); // a global wrapper int openimage(const char *imname, int frame=-1); class imViewMenuBar: public Fl_Menu_Bar { public: imViewMenuBar(int x, int y, int w, int h, const char *label = 0); ~imViewMenuBar(); int addToItemList(const char *newImage, int listID); void removeFromItemList(const char *oldImage, int listID); void *getSelectedItemArgument(int listID); Fl_Menu_Item *getSelectedMenuItem(int listID); void *getItemByLabel(const char *givenLbl, int listID); char *getItemListContent(int listID, int &nbitems); void *getNextItemInList(int listID); void *getPreviousItemInList(int listID); int isAlreadyInItemList(const char *newImageName, int listID); void setFlagsByName(const char *itemName, int newFlags, Fl_Menu_Item *aMenu = 0, int menuSize = 0); int getFlagsByName(const char *itemName, Fl_Menu_Item *aMenu = 0, int menuSize = 0); int getNbImagesInList(void) { return nbImagesInList; } void setSysMenu(void); void draw(); private: Fl_Menu_Item *dynamicMenu, *staticMenu_; Fl_Sys_Menu_Bar *sysmenu_; // global variables for the menu application const char *listName[LAST_LIST_ID]; void *listCallback[LAST_LIST_ID]; // this will be a list of functions int nbImagesInList; }; #endif // MENUBAR_H ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/menucb.cxx����������������������������������������������������������������������������0000644�0000765�0000765�00000163050�10733752216�016003� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: menucb.cxx,v 4.20 2007/12/24 15:47:26 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * This file contains all the global functions called by the menu * callbacks and keyboard accelerators. * * *-----------------------------------------------------------------------*/ #include <imcfg.h> #include "imnmspc.hxx" // contains namespace definition, if needed #include <FL/Fl.H> #include <FL/Fl_Box.H> #include <FL/Fl_Window.H> #include <FL/Fl_Menu_Bar.H> #include <FL/Fl_Box.H> #include <FL/Fl_File_Chooser.H> #ifdef HAVE_NATIVE_CHOOSER #include <FL/Fl_Native_File_Chooser.H> #endif #include <FL/Fl_Help_Dialog.H> #include <FL/fl_ask.H> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "imunistd.h" #include <errno.h> #include <sys/types.h> #include <map> // C++ stl container. #include <string> // C++ strings #include "imview.hxx" #include "nocase.hxx" #include "imageIO.hxx" #include "pointfile.hxx" #include "imageViewer.hxx" #include "menubar.hxx" #include "printPrefs.hxx" #include "savePrefs.hxx" #include "imageInfo.hxx" #include "spectraBox.hxx" #include "transferFunction.hxx" #include "transferRGBFunction.hxx" #include "profileBox.hxx" #include "userPrefs.hxx" #include "progressInfo.hxx" #include "bivHist.hxx" #include "machine.hxx" #include "StatusBox.hxx" #include "toolbar.hxx" #include "io/newprefio.hxx" #include "sliceSlider.hxx" #include "view3d.hxx" using std::map; typedef map<string,image_psfile>::iterator mi; // Map iterator (can't be const) // components of the application extern imviewWindow *mainWindow; extern imageViewer *mainViewer; extern imViewMenuBar *mainMenuBar; extern imageIO *IOBlackBox; extern pointfile *PtFileMngr; extern Fl_File_Chooser *ImviewFC; #ifdef HAVE_NATIVE_CHOOSER extern Fl_Native_File_Chooser *ImviewNFC; // native file chooser #endif extern int debugIsOn; extern int stopDebug; extern bool lutWraparound; extern volatile bool syncDisplay; extern int makeImageCharIfFits; extern int RGBdisplaysRGB; extern int fitCharOverAllSamples; extern int fitCharOverAllSlices; extern const char *patchlevel; extern int totalbnb; extern char *builder; extern int deleteAfter; extern const char *psonlyfile; extern map<string,image_psfile> psfilemap; extern int appMaxHeight; // fluid-generated extern printprefs *printPrefsPanel; extern saveprefs *savePrefsPanel; extern imageinfo *imageInfoPanel; extern transfer *transferEditorPanel; extern transferRGB *transferRGBEditorPanel; extern spectra *spectraPanel; extern spectra *depthProfile; extern profile *profilePanel; extern userprefs *userprefsPanel; extern bivhist *bivHistPanel; extern progress *progressPanel; extern Fl_Help_Dialog *help; extern toolbar *toolbarPanel; extern slideinput *slice3D, *sliceComponent, *sliceSeries; extern view3D *view3dPanel; // others extern imprefs *fileprefs; extern int applyTransferToAll; extern bool main_terminate; extern bool hideMainMenu; extern bool fullScreen; extern char installpath[], runningpath[]; int keepPoints = 0; // a local preference // openimage is a wrapper for all the read() calls int openimage(const char *imname, int frame) { int ret; static char clutname[DFLTSTRLEN+1]; const char *pf; int nbframes=0; IMAGEPARM *p; if (IOBlackBox->isOverlay(imname)) { // are we opening an overlay? dbgprintf("Image %s is an overlay\n", imname); p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p) { p->ovlpath = strdup(imname); // apply overlay to current image int retval = IOBlackBox->readOverlay(imname); if (retval == 0) { // redisplay image with overlay present IOBlackBox->applyImageParameters(p, 0, 0, true); mainViewer->displayCurrentImage(); } return retval; // don't go any further in reading this image! } else { // close the overlay, it can never be displayed IOBlackBox->closeHeader(imname); return 20; } } else if (mainMenuBar->isAlreadyInItemList(imname, IMAGE_LIST_ID)) { // are we opening a new image? // image may have already been opened once, but we are not sure yet // selects that item mainMenuBar->addToItemList(imname, IMAGE_LIST_ID); p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p->nbframes > 0) { // now we are quite sure that the image has been opened before if (frame == -1) // default is wrong here frame = p->frame; nbframes = p->nbframes; } else { // image has never been opened before nbframes = IOBlackBox->getNbFrames(imname); } } else { // image has never been opened before nbframes = IOBlackBox->getNbFrames(imname); } if (nbframes <= -10) { return (nbframes); // don't go any further, waste of time... } else if (nbframes > 1) { // enable the menu items mainMenuBar->setFlagsByName(NEXTFRAME_ITEM, 0); mainMenuBar->setFlagsByName(PREVIOUSFRAME_ITEM, 0); mainMenuBar->setFlagsByName(SELECTFRAME_ITEM, FL_MENU_DIVIDER); } else { mainMenuBar->setFlagsByName(NEXTFRAME_ITEM, FL_PUP_INVISIBLE); mainMenuBar->setFlagsByName(PREVIOUSFRAME_ITEM, FL_PUP_INVISIBLE); mainMenuBar->setFlagsByName(SELECTFRAME_ITEM, FL_PUP_INVISIBLE | FL_MENU_DIVIDER); } // correct the default if by that time it hasn't been done yet if (frame == -1) frame = 0; // before image switch, backup the points PtFileMngr->savelist(false); if ((ret = IOBlackBox->read(imname, frame)) == 0) { // we have successfully read the image // remove the titleBox if it is still present removeSimpleBanner(); // selects this file in the image list mainMenuBar->addToItemList(imname, IMAGE_LIST_ID); if (mainMenuBar->getNbImagesInList() > 1) { mainMenuBar->setFlagsByName(NEXTIMAGE_ITEM, 0); mainMenuBar->setFlagsByName(PREVIOUSIMAGE_ITEM, FL_MENU_DIVIDER); } else { mainMenuBar->setFlagsByName(NEXTIMAGE_ITEM, FL_PUP_GREY); mainMenuBar->setFlagsByName(PREVIOUSIMAGE_ITEM, FL_PUP_GREY | FL_MENU_DIVIDER); } // check for LUT being attached to this image. p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); // records the number of frames (computed earlier) p->nbframes = nbframes; // re-set this, because the number of frame is only // computed the first time the image is read. IOBlackBox->setCurrImgNbFrames(nbframes); // apply the gamma, contrast, etc, that have been saved for this image // except if the `apply gamma to all images' has been checked, in which // case the stored values for the image don't apply. if (transferEditorPanel && !applyTransferToAll) { char cval[100]; dbgprintf("Setting editor panel values\n"); transferEditorPanel->setGammaSliderValue(log(p->gamma)); sprintf(cval, "%1.4g", p->gamma); transferEditorPanel->setGammaInputValue((const char *)cval); transferEditorPanel->setContrastSliderValue(p->contrast); transferEditorPanel->setBrightnessSliderValue(p->brightness); transferEditorPanel->setDrawingParms(); transferEditorPanel->redrawWindowIfNeeded(); dbgprintf("Values found for %s:\ngamma=%g, contrast=%g, brightness=%g\n", p->itempath, p->gamma, p->contrast, p->brightness ); } // same thing for RGB panel if (transferRGBEditorPanel && !applyTransferToAll) { char cval[100]; dbgprintf("Setting RGB editor panel values\n"); // Gamma sliders transferRGBEditorPanel->setRGammaSliderValue(log(p->Rgamma)); transferRGBEditorPanel->setGGammaSliderValue(log(p->Ggamma)); transferRGBEditorPanel->setBGammaSliderValue(log(p->Bgamma)); // Gamma inputs sprintf(cval, "%1.4g", p->Rgamma); transferRGBEditorPanel->setRGammaInputValue((const char *)cval); sprintf(cval, "%1.4g", p->Ggamma); transferRGBEditorPanel->setGGammaInputValue((const char *)cval); sprintf(cval, "%1.4g", p->Bgamma); transferRGBEditorPanel->setBGammaInputValue((const char *)cval); // Contrast sliders transferRGBEditorPanel->setRContrastSliderValue(p->Rcontrast); transferRGBEditorPanel->setGContrastSliderValue(p->Gcontrast); transferRGBEditorPanel->setBContrastSliderValue(p->Bcontrast); // Brightness sliders transferRGBEditorPanel->setRBrightnessSliderValue(p->Rbrightness); transferRGBEditorPanel->setGBrightnessSliderValue(p->Gbrightness); transferRGBEditorPanel->setBBrightnessSliderValue(p->Bbrightness); // transferRGBEditorPanel->setDrawingParms(); transferRGBEditorPanel->redrawWindowIfNeeded(); dbgprintf("Values found for %s:\ngamma=%g, contrast=%g, brightness=%g\n", p->itempath, p->gamma, p->contrast, p->brightness ); } // check if pointfile name has been set if (p->pfpath==0) { // check if an image specific pointfile exists if ((pf=PtFileMngr->getPtFileNameIfPresent(imname)) != 0) PtFileMngr->setPtFileName(pf); // set the pointfile name accordingly, default = pointfile p->pfpath = strdup(PtFileMngr->getPtFileName()); } // clears the pointfile if (!fileprefs->keepPoints()) PtFileMngr->rmAllPoints(); PtFileMngr->imageName(imname); // read the overlay, if any if (p->ovlpath) IOBlackBox->readOverlay(p->ovlpath); else // else remove it IOBlackBox->setOverlay(0); // apply the display parameters that have been saved for this image // IOBlackBox->applyImageParameters(p, imname, clutname, false); if ((p->gamma != 1.0) || (p->contrast != 0.5) || (p->brightness != 0.5)) IOBlackBox->applyImageParameters(p, imname, clutname, true); else IOBlackBox->applyImageParameters(p, imname, clutname, false); // selects the CLUT or unselects it (if no CLUT) mainMenuBar->addToItemList((const char *)clutname, CLUT_LIST_ID); // now let's use some information on the image // first of all, is the image 3-d? if (IOBlackBox->getCurrImgThickness() > 1) { // image is 3-d, we'll want to wade through the Z plane mainMenuBar->setFlagsByName(NEXTPLANE_ITEM, 0); mainMenuBar->setFlagsByName(PREVIOUSPLANE_ITEM, 0); mainMenuBar->setFlagsByName(SELECTPLANE_ITEM, FL_MENU_DIVIDER); // allow 3D rotations mainMenuBar->setFlagsByName(ROTATE3DMENU_ITEM, FL_SUBMENU); // allow 3D viewer mainMenuBar->setFlagsByName(VIEW3D_ITEM, FL_MENU_DIVIDER); // allow 3D images to behave as hyperspectral images for some // applications if (IOBlackBox->getCurrImgThickness() > 1) { mainMenuBar->setFlagsByName(DEPTHPROFILE_ITEM, 0); } else { mainMenuBar->setFlagsByName(DEPTHPROFILE_ITEM, FL_PUP_INVISIBLE); } } else { // image is not 3-d, no point in confusing the user mainMenuBar->setFlagsByName(NEXTPLANE_ITEM, FL_PUP_INVISIBLE); mainMenuBar->setFlagsByName(PREVIOUSPLANE_ITEM, FL_PUP_INVISIBLE); mainMenuBar->setFlagsByName(SELECTPLANE_ITEM, FL_PUP_INVISIBLE | FL_MENU_DIVIDER); mainMenuBar->setFlagsByName(VIEW3D_ITEM, FL_PUP_INVISIBLE|FL_MENU_DIVIDER); // disallow 3D rotations mainMenuBar->setFlagsByName(ROTATE3DMENU_ITEM, FL_SUBMENU|FL_PUP_INVISIBLE); } // next: is the image multispectral? if (IOBlackBox->getCurrImgNbSamples() > 1) { // image is multispectral we'll want to wade through the components mainMenuBar->setFlagsByName(NEXTCOMPONENT_ITEM, 0); mainMenuBar->setFlagsByName(PREVIOUSCOMPONENT_ITEM, 0); mainMenuBar->setFlagsByName(SELECTCOMPONENT_ITEM, FL_MENU_DIVIDER); mainMenuBar->setFlagsByName(BIVHIST_ITEM, 0); // Re-enable when it works mainMenuBar->setFlagsByName(RGBTRANSFER_ITEM, 0); if (IOBlackBox->getCurrImgNbSamples() >= 3) { mainMenuBar->setFlagsByName(HYPERSPECTRAL_ITEM, 0); } else { mainMenuBar->setFlagsByName(HYPERSPECTRAL_ITEM, FL_PUP_INVISIBLE); } } else { // image is not multispectral, no point in confusing the user mainMenuBar->setFlagsByName(NEXTCOMPONENT_ITEM, FL_PUP_INVISIBLE); mainMenuBar->setFlagsByName(PREVIOUSCOMPONENT_ITEM, FL_PUP_INVISIBLE); mainMenuBar->setFlagsByName(BIVHIST_ITEM, FL_PUP_INVISIBLE); mainMenuBar->setFlagsByName(RGBTRANSFER_ITEM, FL_PUP_INVISIBLE); // same as above, we want to allow 3D images to behave as hyperspectral images // sometimes if (IOBlackBox->getCurrImgThickness() <= 3) { mainMenuBar->setFlagsByName(HYPERSPECTRAL_ITEM, FL_PUP_INVISIBLE); mainMenuBar->setFlagsByName(SELECTCOMPONENT_ITEM, FL_PUP_INVISIBLE | FL_MENU_DIVIDER); } } // actually display the image mainViewer->displayCurrentImage(); } else { errprintf("Read of %s failed, error=%d\n", imname, ret); } return ret; } // all the callback functions: they have to be globals void openfile_cb(const char *s) { dbgprintf("Got file callback with argument [%s]\n", s); openimage(s); return; } // menu callback functions void test_cb(Fl_Object *,void *i) { dbgprintf("Not implemented yet, sorry! userdata = %ld\n",(long)i); } // Zoom in void zoomin_cb(Fl_Object *, void *) { double zf; zf = mainViewer->zoomFactor(); dbgprintf("Zoom factor = %f\n", (double)(mainViewer->zoomFactor(zf * 2.0))); } void smallzoomin_cb(Fl_Object *, void *) { double zf; zf = mainViewer->zoomFactor(); dbgprintf("Zoom factor = %f\n", (double)(mainViewer->zoomFactor(zf * 1.1))); } // Zoom out void zoomout_cb(Fl_Object *, void *) { double zf; zf = mainViewer->zoomFactor(); dbgprintf("Zoom factor = %f\n", (double)(mainViewer->zoomFactor(zf / 2.0))); } void smallzoomout_cb(Fl_Object *, void *) { double zf; zf = mainViewer->zoomFactor(); dbgprintf("Zoom factor = %f\n", (double)(mainViewer->zoomFactor(zf / 1.1))); } void unzoom_cb(Fl_Object *, void *) { dbgprintf("Zoom factor = %f\n", (double)(mainViewer->applyDefaultZoomFactor())); } void selectzoom_cb(Fl_Object *, void *) { static char currzoomtxt[100]; sprintf(currzoomtxt, "%f", (double)(mainViewer->zoomFactor())); const char *zoomtxt = fl_input("Enter zoom factor", currzoomtxt); double newzoom = (zoomtxt != 0) ? atof(zoomtxt):mainViewer->zoomFactor(); // minimal check if (newzoom > 0) mainViewer->zoomFactor(newzoom); else errprintf("Zoom factor must be strictly positive\n"); return; } void thiszoom_cb(Fl_Object *, void *) { dbgprintf("Current zoom factor %f is new the default\n", mainViewer->setDefaultZoomFactor(mainViewer->zoomFactor())); return; } void selectdefaultzoom_cb(Fl_Object *, void *) { static char currzoomtxt[100]; sprintf(currzoomtxt, "%f", (double)(mainViewer->zoomFactor())); const char *zoomtxt = fl_input("Enter default zoom factor", currzoomtxt); double newzoom = (zoomtxt != 0) ? atof(zoomtxt):mainViewer->zoomFactor(); // minimal check if (newzoom > 0) mainViewer->setDefaultZoomFactor(newzoom); else errprintf("Zoom factor must be strictly positive\n"); return; } // 3D view void showview3d_cb(Fl_Object *, void *) { dbgprintf("View 3D panel callback\n"); if (view3dPanel == 0) { view3dPanel = new view3D; // initializes the fluid-generated panel view3d_panel(*view3dPanel); // do our own private initialisation view3dPanel->setDefaults(); } // show the panel view3dPanel->show(); } // rotations static float mymodulo(float &f) { // modulo is not portable enough in this case while (f >= 360) f -= 360; while (f < 0) f += 360; dbgprintf("Picture angle is %d\n", f); return f; } void rotate90right_cb(Fl_Object *, void *) { IMAGEPARM *p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p) { IOBlackBox->rotateRight(); IOBlackBox->applyImageParameters(p, 0, 0, true); p->angle += 90; mymodulo(p->angle); mainViewer->displayCurrentImage(); } return; } void rotate90left_cb(Fl_Object *, /*g */ void *) /* */ { IMAGEPARM *p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p) { IOBlackBox->rotateLeft(); IOBlackBox->applyImageParameters(p, 0, 0, true); p->angle -= 90; mymodulo(p->angle); mainViewer->displayCurrentImage(); } return; } void rotate180_cb(Fl_Object *, void *) { IMAGEPARM *p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p) { IOBlackBox->rotate180(); IOBlackBox->applyImageParameters(p, 0, 0, true); p->angle += 180; mymodulo(p->angle); mainViewer->displayCurrentImage(); } return; } void rotate3dup_cb(Fl_Object *, void *) { IMAGEPARM *p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p) { IOBlackBox->rotate3Dup(); IOBlackBox->applyImageParameters(p, 0, 0, true); // This will complicate matters... //p->angle += 180; //mymodulo(p->angle); mainViewer->displayCurrentImage(); } return; } void rotate3ddown_cb(Fl_Object *, void *) { IMAGEPARM *p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p) { IOBlackBox->rotate3Ddown(); IOBlackBox->applyImageParameters(p, 0, 0, true); // This will complicate matters... //p->angle += 180; //mymodulo(p->angle); mainViewer->displayCurrentImage(); } return; } // flips void flipv_cb(Fl_Object *, void *) { IMAGEPARM *p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p) { IOBlackBox->flipv(); IOBlackBox->applyImageParameters(p, 0, 0, true); if ((p->angle == 90) || (p->angle == 270)) { p->angle += 180; mymodulo(p->angle); } p->mirror = 1 - p->mirror; // swap the `mirror' status mainViewer->displayCurrentImage(); } return; } void fliph_cb(Fl_Object *, void *) { IMAGEPARM *p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p) { IOBlackBox->fliph(); IOBlackBox->applyImageParameters(p, 0, 0, true); if ((p->angle == 0) || (p->angle == 180)) { p->angle += 180; mymodulo(p->angle); } p->mirror = 1 - p->mirror; // swap the `mirror' status mainViewer->displayCurrentImage(); } return; } void filechoosernew_cb(Fl_File_Chooser *fc, void *data) { dbgprintf("new file_chooser callback (fc=%p, data=%p)\n", fc, data); dbgprintf(" filename = \"%s\"\n", fc->value()); } // Create both choosers void create_fc(void) { #ifdef HAVE_NATIVE_CHOOSER const static char *native_file_filter = \ "Image files\t*.{bmp,gif,jpg,JPG,png,pbm,pgm,pnm,PNG,raw,RAW,tif,tiff}\n" "Pointfiles\t*.pf\n"; if (ImviewNFC == 0) { ImviewNFC = new Fl_Native_File_Chooser(); assert(ImviewNFC !=0); ImviewNFC->type(Fl_Native_File_Chooser::BROWSE_MULTI_FILE); // let user browse several files ImviewNFC->title("Open one or more file(s)"); // optional title ImviewNFC->filter(native_file_filter); // optional filter } #endif const static char *file_filter = \ "Image Files (*.{bmp,gif,jpg,JPG,png,PNG,tif,tiff})\t" "Pointfiles (*.pf)"; if (ImviewFC == 0) { ImviewFC = new Fl_File_Chooser(".", "*", Fl_File_Chooser::MULTI|Fl_File_Chooser::CREATE, "Imview File Chooser"); assert(ImviewFC != 0); // eh. ImviewFC->callback(filechoosernew_cb); ImviewFC->filter(file_filter); } //#endif // HAVE_NATIVE_CHOOSER } // Lauches the openfile dialog void open_cb(Fl_Object *, void *i) { int count, n; char locfilename[DFLTSTRLEN]; dbgprintf("Open dialog callback with option %ld\n", (long) i); create_fc(); #ifdef HAVE_NATIVE_CHOOSER ImviewNFC->type(Fl_Native_File_Chooser::BROWSE_MULTI_FILE); ImviewNFC->title("Open one or more file(s)"); switch ( ImviewNFC->show() ) { case -1: // ERROR warnprintf("** native chooser show() failed:%s\n", ImviewNFC->errmsg()); break; case 1: // CANCEL dbgprintf("native chooser cancel\n"); break; default: // USER PICKED A FILE count = ImviewNFC->count(); for (n = 0; n < count; n++ ) { dbgprintf("%d) '%s'\n", n, ImviewNFC->filename(n)); fl_filename_expand(locfilename, sizeof(locfilename), ImviewNFC->filename(n)); mainMenuBar->addToItemList(locfilename, IMAGE_LIST_ID); } // open the last one openimage(locfilename); break; } #else ImviewFC->show(); // modal while (ImviewFC->visible()) Fl::wait(); count = ImviewFC->count(); // add all the files to the item list and open the last one if (count > 0) { for (int i = 1 ; i <= count ; ++i) { if (!ImviewFC->value(i)) break; fl_filename_expand(locfilename, sizeof(locfilename), ImviewFC->value(i)); mainMenuBar->addToItemList(locfilename, IMAGE_LIST_ID); } // truly open the last one openimage(locfilename); } #endif // HAVE_NATIVE_CHOOSER #if 0 p = fl_file_chooser("Open Image","*",currentfile); if (p) currentfile = p; if (p == 0) { dbgprintf("User cancelled choice\n"); } else { dbgprintf("User chose %s\n", currentfile); // open an image openimage(currentfile); } #endif return; } // Opens an overlay void openoverlay_cb(Fl_Object *, void *i) { IMAGEPARM *pp = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); static const char *currentfile = 0, *p = 0; #ifdef HAVE_NATIVE_CHOOSER char locfilename[DFLTSTRLEN]; ImviewNFC->type(Fl_Native_File_Chooser::BROWSE_FILE); ImviewNFC->title("Open overlay"); switch ( ImviewNFC->show() ) { case -1: // ERROR warnprintf("** native chooser show() failed:%s\n", ImviewNFC->errmsg()); break; case 1: // CANCEL dbgprintf("native chooser cancel\n"); break; default: // USER PICKED A FILE dbgprintf("Overlay: '%s'\n", ImviewNFC->filename()); fl_filename_expand(locfilename, sizeof(locfilename), ImviewNFC->filename()); pp->ovlpath = strdup(locfilename); // apply overlay to current image int retval = IOBlackBox->readOverlay(currentfile); if (retval == 0) { // redisplay image with overlay present // don't call this //IOBlackBox->applyOverlayToCurrentImage(); // call that instead IOBlackBox->applyImageParameters(pp, 0, 0, true); mainViewer->displayCurrentImage(); } openimage(locfilename); break; } #else dbgprintf("Open overlay dialog callback with option %ld\n", (long) i); p = fl_file_chooser("Open Overlay Image","*",currentfile); if (p) currentfile = p; if (p == 0) { dbgprintf("User cancelled choice\n"); } else { dbgprintf("User chose %s\n", currentfile); pp->ovlpath = strdup(p); // apply overlay to current image int retval = IOBlackBox->readOverlay(currentfile); if (retval == 0) { // redisplay image with overlay present // don't call this //IOBlackBox->applyOverlayToCurrentImage(); // call that instead IOBlackBox->applyImageParameters(pp, 0, 0, true); mainViewer->displayCurrentImage(); } } #endif return; } // close overlay by hand void closeoverlay_cb(Fl_Object *, void *i) { IMAGEPARM *p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); // this call free extra buffers associated with socket I/O // this is the logical place for this to happen, as the image can't be // recalled if its name drops from the list. IOBlackBox->closeHeader(p->ovlpath); if (p->ovlpath) { free(p->ovlpath); p->ovlpath = 0; } IOBlackBox->setOverlay(0); IOBlackBox->applyImageParameters(p, 0, 0, true); mainViewer->displayCurrentImage(); } // launches the save preferences dialog, and then the savefile dialog void save_cb(Fl_Object *, void *) { dbgprintf("Save preferences callback\n"); if (savePrefsPanel == 0) { savePrefsPanel = new saveprefs; saveprefs &saveref = *savePrefsPanel; // initializes the fluid-generated panel saveprefs_panel(saveref); // do our own private initialisation savePrefsPanel->setDefaults(); } // show the panel savePrefsPanel->show(); return; } void printprefs_cb(Fl_Object *, void *) { // get the name of the image currently being displayed IMAGEPARM *p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); char *shortname = strrchr(p->itempath, '/'); if (shortname == NULL) shortname = p->itempath; // revert to full name if name is local else shortname++; // go beyond the last `/' dbgprintf("Print preferences callback\n"); if (printPrefsPanel == 0) { // initializes the fluid-generated panel printPrefsPanel = new printprefs; printprefs &printref = *printPrefsPanel; printprefs_panel(printref); // do our own initialisation printPrefsPanel->setDefaults(); } // shows the panel printPrefsPanel->setTitle((const char*)shortname); printPrefsPanel->show(); return; } void imageinfo_cb(Fl_Object *, void *) { dbgprintf("Image info callback\n"); if (imageInfoPanel == 0) { // initializes the fluid-generated panel imageInfoPanel = new imageinfo; imageinfo &imageref = *imageInfoPanel; imageinfo_panel(imageref); // do our own initialisation imageInfoPanel->setDefaults(); } // shows the panel imageInfoPanel->show(); return; } void toolbar_cb(Fl_Object *, void *) { dbgprintf("Toolbar callback\n"); if (toolbarPanel == 0) { // initializes the fluid-generated panel toolbarPanel = new toolbar; toolbar_panel(*toolbarPanel); // init toolbarPanel->setDefaults(); } // Show the panel toolbarPanel->show(); return; } void transfer_cb(Fl_Object *, void *) { dbgprintf("Transfer function editor callback\n"); if (transferEditorPanel == 0) { transferEditorPanel = new transfer; transfer &transferref = *transferEditorPanel; // initializes the fluid-generated panel transfer_panel(transferref); // do our own initialisation transferEditorPanel->setDefaults(); } // shows the panel transferEditorPanel->show(); return; } void transferRGB_cb(Fl_Object *, void *) { dbgprintf("RGB Transfer function editor callback\n"); if (transferRGBEditorPanel == 0) { transferRGBEditorPanel = new transferRGB; // initializes the fluid-generated panel RGB_transfer_panel(*transferRGBEditorPanel); // do our own initialisation transferRGBEditorPanel->setDefaults(); } // shows the panel transferRGBEditorPanel->show(); return; } void threshold_cb(Fl_Object *, void *) { return; } // who is responsible for this heap of crap? void whodunit_cb(Fl_Object *, void *) { static char buff[300], currentpath[DFLTSTRLEN]; getcwd(currentpath, DFLTSTRLEN); printf("Current path: %s\n", currentpath); sprintf(buff, "Imview version %s build #%d for %s\n" "Made on %s by %s\n" "Copyright Hugues Talbot, CMIS Image Analysis 1997-2005\n" "Currentpath=%s\n" "Runningpath=%s", patchlevel, totalbnb, systemName(), __DATE__, builder, currentpath, runningpath ); fl_message((const char *)buff); return; } // online help: just loading a pre-defined image // void onlinehelp_cb(Fl_Object *, void *) // { // // for now, online help is only an image... // openimage(ONLINEHELP); // // this is a bit brutal, but we want to be able to view // // the damn thing... // mainViewer->zoomFactor(1.0); // mainViewer->resetDisplay(false); // return; // } int starthelp(char *returnPath, char *fileToShow) { const char *p; static char pathToHelp[DFLTSTRLEN], tmppath[DFLTSTRLEN], basePath[DFLTSTRLEN]; int result = 0; if (help == 0) { int i, j; // make up the directories where we might look for // the documentation strcpy(pathToHelp, "."); // first look in present directory if ((p = getenv("IMVIEWHOME")) != 0) { // then in ~/.imview, etc snprintf(tmppath, DFLTSTRLEN, "%c%s", PATHSEP, p); strncat(pathToHelp, tmppath, DFLTSTRLEN); } snprintf(tmppath, DFLTSTRLEN-4, "%c%s", PATHSEP, installpath); strncat(pathToHelp, tmppath, DFLTSTRLEN); // then in install directory // hunt for documentation now for ( i = 0, j = 0; ; ) { // ever if ((pathToHelp[i] != PATHSEP) && (pathToHelp[i] != '\0')) { tmppath[j++] = pathToHelp[i++]; } else { tmppath[j] = '\0'; strcat(tmppath,"/"); strcat(tmppath, fileToShow); dbgprintf("looking in %s\n", tmppath); if (access(tmppath, R_OK) == 0) { help = new Fl_Help_Dialog; strncpy(returnPath, tmppath, DFLTSTRLEN); tmppath[j] = '\0'; strcat(tmppath,"/"); strncpy(basePath, tmppath, DFLTSTRLEN); // to keep (static) result = 1; break; // found preferences, finished } // try with doc/blablab.html tmppath[j] = '\0'; strcat(tmppath,"/doc/"); strcat(tmppath, fileToShow); dbgprintf("looking in %s\n", tmppath); if (access(tmppath, R_OK) == 0) { help = new Fl_Help_Dialog; strncpy(returnPath, tmppath, DFLTSTRLEN); result = 1; // success! tmppath[j] = '\0'; strcat(tmppath,"/doc/"); strncpy(basePath, tmppath, DFLTSTRLEN); // to keep (static) break; // found preferences, finished } // no joy there, try next string if possible if (pathToHelp[i] != '\0') { j = 0; i++; } else { strncpy(returnPath, pathToHelp, DFLTSTRLEN); basePath[0] = '\0'; result = 0; // failure break; } } } } else { // help has been started already, but check that the file we want it still there strncpy(tmppath, basePath, DFLTSTRLEN); // ends with a `/' strncat(tmppath, fileToShow, DFLTSTRLEN); dbgprintf("Looking in %s\n", tmppath); if (access(tmppath, R_OK) == 0) { strncpy(returnPath, tmppath, DFLTSTRLEN); result = 1; // success! } else { result = 0; } } return result; } void onlinehelp_cb(Fl_Object *, void *) { const char *p; static char pathToHelp[DFLTSTRLEN]; int helpStarted; helpStarted = starthelp(pathToHelp, ONLINEHELP); if (help && helpStarted) { help->load(pathToHelp); help->show(); } else { if ((p = getenv("IMVIEWHOME")) == 0) { errprintf("On-line help not found anywhere,\n" "try setting IMVIEWHOME. Sorry\n"); } else { errprintf("On-line help not found anywhere in\n%s", pathToHelp); } } } // lauches netscape to read the full documentation void fulldocument_cb(Fl_Object *, void *) { static char command[1024]; sprintf(command, "netscape -remote openURL\\(%s,new-window\\)", HELPURL); int ret = system((const char *)command); if (ret != 0) { // try calling netscape directly! sprintf(command, "netscape %s &", HELPURL); ret = system((const char *)command); if (ret != 0) errprintf("Sorry, can't start netscape\n" "Help URL is:\n" "%s", HELPURL); } } // GNU Public Licence void licence_cb(Fl_Object *, void *) { const char *p; static char pathToLicense[DFLTSTRLEN]; int helpStarted; helpStarted = starthelp(pathToLicense, LICENSE); if (help && helpStarted) { help->load(pathToLicense); help->show(); } else { if ((p = getenv("IMVIEWHOME")) == 0) { errprintf("License file not found anywhere,\n" "try setting IMVIEWHOME Sorry\n"); } else { errprintf("License file not found anywhere in\n%s", pathToLicense); } } } // NO WARRANTY void warranty_cb(Fl_Object *, void *) { const char *p; static char pathToWarranty[DFLTSTRLEN]; int helpStarted; helpStarted = starthelp(pathToWarranty, WARRANTY); if (help && helpStarted) { help->load(pathToWarranty); help->show(); } else { if ((p = getenv("IMVIEWHOME")) == 0) { errprintf("Warranty file not found anywhere,\n" "try setting IMVIEWHOME Sorry\n"); } else { errprintf("Warranty file not found anywhere in\n%s", pathToWarranty); } } } void close_cb(Fl_Object *, void *) { IMAGEPARM *p; mi q; const char *imTempPSFileName; dbgprintf("Close dialog callback\n"); // replace the image being displayed do { p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); // this is the image being displayed at present if (p == 0) return; // this is possible if called from the interpreter // case when the file is a Postscript file, rendered into // a different file... if ((q = psfilemap.find(p->itempath)) != psfilemap.end()) { // if (psonlyfile && (strcmp(p->itempath, psonlyfile) == 0)) { // erase the temp file imTempPSFileName = (q->second).getfilename().c_str(); dbgprintf("Erasing the rendered PS file %s\n", imTempPSFileName); unlink(imTempPSFileName); psfilemap.erase(q); // get rid of it } else if (deleteAfter) { // be a bit conservative: remove the image only if it is in one of the tmp directories if (strstr(p->itempath, "/tmp/") != 0) { dbgprintf("Physically deleting the image %s\n", p->itempath); unlink(p->itempath); } else { dbgprintf("Not deleting %s after all\n", p->itempath); } } // this call free extra buffers associated with socket I/O // this is the logical place for this to happen, as the image can't be // recalled if its name drops from the list. IOBlackBox->closeHeader(p->itempath); // normal menu handling mainMenuBar->removeFromItemList(p->itempath, IMAGE_LIST_ID); // this will change the selection... p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); // therefore it is NO LONGER the same image as above } while ((p != 0) && (openimage(p->itempath) != 0)); if (p == 0) { // there isn't any image left in the list: show the simple banner instead mainViewer->close(); showSimpleBanner(); } return; } void filechooser_cb(const char *name) { dbgprintf("File chooser callback '%s'\n",name); } // called when a image name is selected from the image menu void image_cb(Fl_Object *, void *arg) { IMAGEPARM *p; p = (IMAGEPARM *)arg; dbgprintf("Image callback with argument %s\n", p->itempath); if (openimage(p->itempath) != 0) { // this image couldn't be opened: remove it from the list! do { mainMenuBar->removeFromItemList(p->itempath, IMAGE_LIST_ID); // this will get the new selection... p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); } while ((p != 0) && (openimage(p->itempath) != 0)); if (p == 0) { // there isn't any image left in the list: show the simple banner instead mainViewer->close(); showSimpleBanner(); } } } // get the next image on the list if any void nextimage_cb(Fl_Object *, void *) { IMAGEPARM *p; dbgprintf("Next image callback\n"); if ((p = (IMAGEPARM *)mainMenuBar->getNextItemInList(IMAGE_LIST_ID)) != 0) { if (openimage(p->itempath) != 0) { // this image couldn't be opened: remove it from the list! do { mainMenuBar->removeFromItemList(p->itempath, IMAGE_LIST_ID); // this will get the new selection... p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); } while ((p != 0) && (openimage(p->itempath) != 0)); if (p == 0) { // there isn't any image left in the list: show the simple banner instead mainViewer->close(); showSimpleBanner(); } } } else { warnprintf("Null pointer in image list: this is a bug\n"); } return; } void previousimage_cb(Fl_Object *, void *) { IMAGEPARM *p; dbgprintf("Previous image callback\n"); if ((p = (IMAGEPARM *)mainMenuBar->getPreviousItemInList(IMAGE_LIST_ID)) != 0) { if (openimage(p->itempath) != 0) { // this image couldn't be opened: remove it from the list! do { mainMenuBar->removeFromItemList(p->itempath, IMAGE_LIST_ID); // this will get the new selection... p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); } while ((p != 0) && (openimage(p->itempath) != 0)); if (p == 0) { // there isn't any image left in the list: show the simple banner instead mainViewer->close(); showSimpleBanner(); } } } else { warnprintf("Null pointer in image list: this is a bug\n"); } return; } // Walk down the list of images and save them to file... void saveimagelist_cb(Fl_Object *, void *) { static char currSavePath[100], errmsg[300]; int nbitems; char *res = mainMenuBar->getItemListContent(IMAGE_LIST_ID, nbitems); strcpy(currSavePath, "/usr/tmp/imagelist"); const char *savePathTxt = fl_input("Enter list save path", currSavePath); FILE *saveListFile = fopen(savePathTxt, "w"); if (saveListFile != NULL) { fprintf(saveListFile, res); fclose(saveListFile); dbgprintf("Saving %d image names to %s\n", nbitems, savePathTxt); } else { sprintf(errmsg, "Error saving list to %s\n%s", savePathTxt, strerror(errno)); fl_alert(errmsg); } delete[] res; return; } // 1-D profiles handling void showprofile_cb(Fl_Object *, void *) { dbgprintf("Profile panel callback\n"); if (profilePanel == 0) { profilePanel = new profile; profile &profileref = *profilePanel; profile_panel(profileref); // do our own init profilePanel->setDefaults(); } // shows the panel profilePanel->show(); return; } void startserver_cb(Fl_Object *, void *) { } void stopserver_cb(Fl_Object *, void *) { } // server download progress panel void showprogress_cb(Fl_Object *, void *) { dbgprintf("Progress panel callback\n"); if (progressPanel == 0) { progressPanel = new progress; progress_panel(*progressPanel); // standard init progressPanel->setDefaults(); } // show the panel progressPanel->show(); return; } // multispectral image handling void nextcomponent_cb(Fl_Object *, void *) { IMAGEPARM *p; dbgprintf("Next sample\n"); p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p->comp < (IOBlackBox->getCurrImgNbSamples()-1)) { p->comp++; if (sliceComponent) { sliceComponent->setSlice(p->comp); } else { IOBlackBox->applyImageParameters(p, 0, 0, true); // we keep the current gamma // actually display the image mainViewer->displayCurrentImage(); } } return; } void previouscomponent_cb(Fl_Object *, void *) { IMAGEPARM *p; dbgprintf("Previous sample\n"); p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p->comp > 0) { p->comp--; if (sliceComponent) { sliceComponent->setSlice(p->comp); } else { IOBlackBox->applyImageParameters(p, 0, 0, true); // we keep the current gamma if defined // actually display the image mainViewer->displayCurrentImage(); } } return; } void showspectrum_cb(Fl_Object *, void *) { dbgprintf("Spectra panel callback\n"); if (spectraPanel == 0) { spectraPanel = new spectra; spectra &spectraref = *spectraPanel; spectra_panel(spectraref); // do our own init spectraPanel->setDefaults(); } // shows the panel spectraPanel->show(); return; } void showbivhist_cb(Fl_Object *, void *) { dbgprintf("Bivariate histogram panel callback\n"); if (bivHistPanel == 0) { bivHistPanel = new bivhist; bivhist &bivhistref = *bivHistPanel; bivhist_panel(bivhistref); // do our own init bivHistPanel->setDefaults(); } // shows the panel bivHistPanel->show(); return; } void setcomponentvalue(int v) { IMAGEPARM *p; dbgprintf("Set sample to %d\n", v); p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); // minimal check if ((v >= 0) && (v < IOBlackBox->getCurrImgNbSamples())) { p->comp = v; IOBlackBox->applyImageParameters(p, 0, 0, true); // we keep the gamma if defined mainViewer->displayCurrentImage(); } else { errprintf("Sample number is out of bounds\n"); } return; } void selectcomponent_cb(Fl_Object *, void *) { IMAGEPARM *p; int cmin, cmax; dbgprintf("Select sample\n"); p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (sliceComponent == 0) { sliceComponent = new slideinput; slider_panel(*sliceComponent); sliceComponent->setDefaults(); // own init sliceComponent->setWindowTitle("Select sample"); sliceComponent->setValueTitle("sample:"); sliceComponent->setSliceCB(setcomponentvalue); } cmin = 0; cmax = IOBlackBox->getCurrImgNbSamples()-1; sliceComponent->setLimits(cmin, cmax); sliceComponent->setSlice(p->comp); sliceComponent->show(); return; } // 3-D bare bone functions void showdepthprofile_cb(Fl_Object *, void *) { dbgprintf("Depth profile panel callback\n"); if (depthProfile == 0) { depthProfile = new spectra; spectra_panel(*depthProfile); // do our own init depthProfile->setDefaults(); depthProfile->setWindowTitle("Depth profile panel"); depthProfile->setXValueLabel("Plane:"); } // shows the panel depthProfile->show(); return; } void nextplane_cb(Fl_Object *, void *) { IMAGEPARM *p; dbgprintf("Next plane\n"); p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p->zslice < (IOBlackBox->getCurrImgThickness()-1)) { p->zslice++; if (slice3D) { slice3D->setSlice(p->zslice); } else { IOBlackBox->applyImageParameters(p, 0, 0, true); // we keep the current gamma if defined // actually display the image mainViewer->displayCurrentImage(); } } return; } void previousplane_cb(Fl_Object *, void *) { IMAGEPARM *p; dbgprintf("Previous plane\n"); p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p->zslice > 0) { p->zslice--; if (slice3D) { slice3D->setSlice(p->zslice); } else { IOBlackBox->applyImageParameters(p, 0, 0, true); // we keep the current gamma if defined // actually display the image mainViewer->displayCurrentImage(); } } return; } // Z offset is not dealt with as it should here void setplanevalue(int v) { IMAGEPARM *p; int zt = IOBlackBox->getCurrImgThickness(); dbgprintf("Set plane to %d\n", v); p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); // minimal check if ((v >= 0) && (v < zt)) { p->zslice = v; IOBlackBox->applyImageParameters(p, 0, 0, true); // we keep the current gamma if defined mainViewer->displayCurrentImage(); } else { errprintf("Plane number is out of bounds\n"); } return; } void selectplane_cb(Fl_Object *, void *) { IMAGEPARM *p; int cmin, cmax, zt = IOBlackBox->getCurrImgThickness(); dbgprintf("Select plane\n"); p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (slice3D == 0) { slice3D = new slideinput; slider_panel(*slice3D); slice3D->setDefaults(); slice3D->setWindowTitle("Select plane"); slice3D->setValueTitle("plane:"); slice3D->setSliceCB(setplanevalue); } cmin = 0; cmax = zt-1; slice3D->setLimits(cmin, cmax); slice3D->setSlice(p->zslice); slice3D->show(); return; } // unlike the other slices, this one allows loops (time loops // are frequent, think of GIF animations. void nextframe_cb(Fl_Object *, void *) { IMAGEPARM *p; p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p != 0) { if (p->frame < p->nbframes-1) p->frame++; else p->frame = 0; dbgprintf("Opening frame #%d for file %s\n", p->frame, p->itempath); if (sliceSeries) { sliceSeries->setSlice(p->frame); } openimage(p->itempath, p->frame); } return; } void previousframe_cb(Fl_Object *, void *) { IMAGEPARM *p; p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p != 0) { if (p->frame > 0) p->frame--; else p->frame = p->nbframes -1; dbgprintf("Opening frame #%d for file %s\n", p->frame, p->itempath); if (sliceSeries) { sliceSeries->setSlice(p->frame); } openimage(p->itempath, p->frame); } return; } void setframevalue(int v) { IMAGEPARM *p; int pt; dbgprintf("Set frame to %d\n", v); p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p != 0) { pt = p->nbframes; // minimal check // minimal check if ((v >= 0) && (v < pt)) { p->frame = v; openimage(p->itempath, p->frame); } else { errprintf("Frame number is out of bounds\n"); } } return; } void selectframe_cb(Fl_Object *, void *) { IMAGEPARM *p; int cmin, cmax, pt; dbgprintf("Select frame\n"); p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (p != 0) { pt = p->nbframes; if (sliceSeries == 0) { sliceSeries = new slideinput; slider_panel(*sliceSeries); sliceSeries->setDefaults(); sliceSeries->setWindowTitle("Select frame"); sliceSeries->setSliceCB(setframevalue); } cmin = 0; cmax = pt-1; sliceSeries->setLimits(cmin, cmax); sliceSeries->setSlice(p->frame); sliceSeries->show(); } return; } // Hmmmm. int setClut(const char *label) { int res = 0; IMAGEPARM *xlut; xlut = (IMAGEPARM *)mainMenuBar->getItemByLabel(label, CLUT_LIST_ID); if (xlut != 0) clut_cb(0, xlut); // hmmm else res = 1; return res; } // called when a CLUT is chosen for the current image void clut_cb(Fl_Object *,void *arg) { IMAGEPARM *xlut, *ximg; xlut = (IMAGEPARM *)arg; dbgprintf("CLUT callback called with argument %s\n", xlut->itempath); if (IOBlackBox->applyCLUTtoCurrentImage((const char *)xlut->itempath) == 0) { // we have successfully opened the image // remove the titleBox if it is still present removeSimpleBanner(); // selects the CLUT mainMenuBar->addToItemList(xlut->itempath, CLUT_LIST_ID); // specify that we always want to display the current image with // the chosen LUT in the future. ximg = (IMAGEPARM *) mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if (ximg->clutpath != 0) free(ximg->clutpath); ximg->clutpath = strdup(xlut->itempath); // this should work. dbgprintf("Attaching clut %s to image%s\n", ximg->clutpath, ximg->itempath); // let us not forget to display the image! mainViewer->displayCurrentImage(); } return; } // Remove all colour use with the image void noclut_cb(Fl_Object *,void *) { IMAGEPARM *ximg; Fl_Menu_Item *selectedMenu; const char *currentfile; // get the selected image ID if ((ximg = (IMAGEPARM *) mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID)) != 0) { // delete the association with any colour map... if (ximg->clutpath != 0) { free(ximg->clutpath); ximg->clutpath = 0; } // unselects the current CLUT if ((selectedMenu = mainMenuBar->getSelectedMenuItem(CLUT_LIST_ID)) != 0) { // uncheck the thing selectedMenu->flags &= ~FL_PUP_CHECK; } currentfile = ximg->itempath; dbgprintf("Removing colour map associated with image%s\n", currentfile); // let us not forget to display the image! bool oldkeepPoints = fileprefs->keepPoints(); fileprefs->keepPoints(true); openimage(currentfile); if (!oldkeepPoints) fileprefs->keepPoints(false); // otherwise no change needed } return; } void userprefspanel_cb(Fl_Object *, void *) { dbgprintf("User preferences panel callback\n"); if (userprefsPanel == 0) { userprefsPanel = new userprefs; userprefs &userprefsref = *userprefsPanel; userprefs_panel(userprefsref); // do our own init userprefsPanel->setDefaults(); } // shows the panel userprefsPanel->show(); // set the debug stuff userprefsPanel->setDebug(debugIsOn); userprefsPanel->setStopDebug(stopDebug); return; } // sets or unsets the individual preferences void preference_cb(Fl_Object *obj, void *arg) { long intarg; Fl_Menu_ *m = (Fl_Menu_*)obj; Fl_Menu_Item* i = (Fl_Menu_Item*)(m->mvalue()); // get the menu item bool currentMenuHideStatus = hideMainMenu; intarg = (long)(arg); // non-toggle ones if (intarg == PREF_WARNING) StatusBox::Instance()->show(); // easy... if (i->value()) { switch (intarg) { case PREF_SMOOTHUNZOOM: mainViewer->drawSmooth(1); break; case PREF_DEBUG: debugIsOn = 1; break; case PREF_STOPDEBUG: stopDebug = 1; break; case PREF_KEEPPOINTS: keepPoints = 1; break; case PREF_WRAPAROUND: lutWraparound = true; break; case PREF_MAKECHAR: makeImageCharIfFits = 1; break; case PREF_RGBRGB: RGBdisplaysRGB = 1; break; case PREF_FITALL: fitCharOverAllSamples = 1; IOBlackBox->flush_minmax_cache(); break; case PREF_FIT3D: fitCharOverAllSlices = 1; IOBlackBox->flush_minmax_cache(); break; case PREF_SYNCDISP: syncDisplay = true; break; case PREF_HIDEMENU: hideMainMenu = true; break; case PREF_FULLSCREEN: fullscreen_cb(0,0); break; default: warnprintf("Unknown preference argument %d\n", intarg); break; } } else { switch (intarg) { case PREF_SMOOTHUNZOOM: mainViewer->drawSmooth(0); break; case PREF_DEBUG: debugIsOn = 0; break; case PREF_STOPDEBUG: stopDebug = 0; break; case PREF_KEEPPOINTS: keepPoints = 0; break; case PREF_WRAPAROUND: lutWraparound = false; break; case PREF_MAKECHAR: makeImageCharIfFits = 0; break; case PREF_RGBRGB: RGBdisplaysRGB = 0; break; case PREF_FITALL: fitCharOverAllSamples = 0; IOBlackBox->flush_minmax_cache(); break; case PREF_FIT3D: fitCharOverAllSlices = 0; IOBlackBox->flush_minmax_cache(); break; case PREF_SYNCDISP: syncDisplay = false; break; case PREF_HIDEMENU: hideMainMenu = false; break; case PREF_FULLSCREEN: fullscreen_cb(0,0); break; default: warnprintf("Unknown preference argument %d\n", intarg); break; } } if (hideMainMenu != currentMenuHideStatus) { // avoid infinite loop dbgprintf("Hiding menu requested\n"); if (hideMainMenu) mainWindow->removeMainMenu(); else mainWindow->addMainMenu(); } mainMenuBar->redraw(); mainViewer->redraw(); return; } void displaymode_cb(Fl_Object *obj, void *arg) { long chosenmode = reinterpret_cast<long>(arg); dbgprintf("Display mode = %ld\n", chosenmode); mainViewer->setdisplaymode(static_cast<displaymode>(chosenmode)); return; } // this acts as a toggle. void fullscreen_cb(Fl_Object *, void *arg) { static bool save_hidemenu_status = false; static double save_zoomfactor = 1.0; if (!fullScreen) { // coming into fullscreen, hide the main menu regardless of user preference save_hidemenu_status = hideMainMenu; hidemainmenu_cb(0,0); } else { if (!save_hidemenu_status) // but only restablish it coming out of fs if the user wants the menu. showmainmenu_cb(0,0); } mainViewer->toggle_fullscreen(); if (fullScreen) { save_zoomfactor = mainViewer->zoomFactor(); mainViewer->applyMaxZoomFactor(); // fill the screen! } else mainViewer->setDefaultZoomFactor(save_zoomfactor); // restore previous zoom dbgprintf("Fullscreen-status is now %s\n", (fullScreen) ? "on":"off"); return; } void hidemainmenu_cb(Fl_Object *obj, void *arg) { hideMainMenu = true; mainWindow->removeMainMenu(); appMaxHeight += MENUHEIGHT; if (arg) { mainMenuBar->redraw(); mainViewer->redraw(); } return; } void showmainmenu_cb(Fl_Object *obj, void *arg) { hideMainMenu = false; mainWindow->addMainMenu(); appMaxHeight -= MENUHEIGHT; if (arg) { mainMenuBar->redraw(); mainViewer->redraw(); } return; } void mode_cb(Fl_Object *obj, void *arg) { long intarg; Fl_Menu_ *m = (Fl_Menu_*)obj; Fl_Menu_Item* i = (Fl_Menu_Item*)(m->mvalue()); // get the menu item intarg = (long)(arg); if (i->value()) { switch (intarg) { case MODE_POINTFILE: mainViewer->setPointMode(true); break; } } else { switch (intarg) { case MODE_POINTFILE: mainViewer->setPointMode(false); break; } } mainMenuBar->redraw(); mainViewer->redraw(); return; } // pointfile management // open an existing pointfile void openpointfile_cb(Fl_Object *,void *) { static const char *currentfile = 0, *p = 0; dbgprintf("Opening new point file\n"); p = fl_file_chooser("Open New Point File","*",currentfile); if (p) currentfile = p; if (p == 0) { dbgprintf("User cancelled choice\n"); } else { dbgprintf("User chose %s\n", currentfile); // open a pointfile PtFileMngr->setPtFileName((char *)currentfile); // interpret its content PtFileMngr->readlist(); } return; } void newpointfile_cb(Fl_Object *,void *) { static const char *currentfile = 0, *p = 0; dbgprintf("Opening new point file\n"); p = fl_file_chooser("Open New Point File","*",currentfile); if (p) currentfile = p; if (p == 0) { dbgprintf("User cancelled choice\n"); } else { dbgprintf("User chose %s\n", currentfile); // open a pointfile PtFileMngr->setPtFileName((char *)currentfile); } return; } void closepointfile_cb(Fl_Object *,void *) { static char buff[300]; dbgprintf("Closing point file\n"); if (PtFileMngr->savelist() == 0) { int nbpts = PtFileMngr->nbPointsInList(); int nbbrks = PtFileMngr->nbBreaksInList(); const char *pts = (nbpts > 1) ? "points":"point"; const char *brks = (nbbrks > 1) ? "groups":"group"; sprintf(buff, "%d %s in %d %s saved to\n%s\n", nbpts, pts, nbbrks, brks, PtFileMngr->getPtFileName()); fl_message((const char *)buff); } return; } void deleteallpoints_cb(Fl_Object *,void *) { PtFileMngr->rmAllPoints(); mainViewer->displayCurrentImage(); // stronger than just redraw dbgprintf("Deleting all currently defined points\n"); return; } void deletelastpoint_cb(Fl_Object *,void *) { if (!PtFileMngr->rmSelectedPoints()) PtFileMngr->rmLastPoint(); // delete the last point if none selected mainViewer->displayCurrentImage(); dbgprintf("Deleting point from pointfile\n"); return; } // set the XOR value when drawing a xor line void setxorvalue_cb(Fl_Object *,void *) { static char currxortxt[100]; sprintf(currxortxt, "%#x", PtFileMngr->xorValueForLines()); const char *xortxt = fl_input("Enter xor value", currxortxt); int newxor = (xortxt != 0) ? (int)strtol(xortxt, 0, 0):PtFileMngr->xorValueForLines(); // minimal check if (newxor > 0) PtFileMngr->xorValueForLines(newxor); else errprintf("Xor value must be positive\n"); PtFileMngr->xorValueForLines(newxor); return; } // quits the application void quit_cb(Fl_Object *,void *) { // The End. // imview_exit(0); main_terminate = true; } // never quits the application void noquit_cb(Fl_Object *,void *) { dbgprintf("I will not quit!\n"); // nothing } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/mkinstalldirs�������������������������������������������������������������������������0000644�0000765�0000765�00000001325�07653236471�016614� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman <friedman@prep.ai.mit.edu> # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 4.0 2003/04/28 14:39:53 hut66au Exp $ errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/my_Image.cxx��������������������������������������������������������������������������0000644�0000765�0000765�00000056164�10060025161�016251� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: my_Image.cxx,v 4.4 2004/06/04 07:53:21 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Image drawing complementary functions. * * FL has good capabilities, but they can always be augmented. * Hugues Talbot 4 Nov 1997 * *-----------------------------------------------------------------------*/ #include <FL/Fl_Object.H> #include <FL/Fl_Image.H> #include <FL/x.H> #include <FL/fl_draw.H> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include "imview.hxx" // This variable used for synchronization. volatile bool im_draw_finished = true; void freeOffScreenPixmap(Fl_RGB_Image *b) { if (b && b->id) { fl_delete_offscreen((Fl_Offscreen)b->id); b->id = 0; } return; } void fl_draw_clipped(Fl_RGB_Image *b, /* Input image */ int ox, /* x origin of where the image will be drawn in the window */ int oy, /* y origin of where the image will be drawn in the window */ int x, /* x origin of the bounding box in the image */ int y, /* y origin of the bounding box in the image */ int w, /* width of the bounding box in the image */ int h) /* height of the bounding box in the image */ { /** draws a Fl_RGB_Image object clipped to a given bounding box RETURN VALUE: void DESCRIPTION: The input Fl_RGB_Image is drawn, subject to the given bounding box. The Fl_RGB_Image is *NOT* centered in the bounding box. It is expected that x > 0, y > 0, w > 0, h > 0 and w and h are smaller than the image's dimension. HISTORY: Hugues Talbot 4 Nov 1997 TESTS: REFERENCES: KEYWORDS: **/ if (!b->id) { dbgprintf("Creating an off-screen pixmap (w=%d, h=%d)\n", b->w(), b->h()); #if defined(MACOSX_CARBON) || defined(WIN32) b->id = (void *)fl_create_offscreen(w,h); #else b->id = (unsigned)fl_create_offscreen(w,h); #endif fl_begin_offscreen((Fl_Offscreen)b->id); fl_push_no_clip(); if (b->d() == 1) { dbgprintf("Call to fl_draw_image_mono\n"); // serious change in FLTK-1.1.x fl_draw_image_mono((const uchar *)(b->data()[0]), 0, 0, b->w(), b->h(), b->d()); } else { dbgprintf("Call to fl_draw_image (colour)\n"); // serious change in FLTK-1.1.x fl_draw_image((const uchar *)(b->data()[0]), 0, 0, b->w(), b->h(), b->d()); } fl_pop_clip(); fl_end_offscreen(); dbgprintf("Offscreen buffer pointer: %p\n", b->id); } else { dbgprintf("Now using the off-screen pixmap\n"); } // incorrect entries if (w < 0) w = 0; if (h < 0) h = 0; if (x < 0) x = 0; if (y < 0) y = 0; if (w > b->w()) { w = b->w(); } if (h > b->h()) { h = b->h(); } // somewhat subtle cases if (x+w > b->w()) { // adjust x x = b->w() - w; } if (y+h > b->h()) { // adjust y y = b->h() - h; } dbgprintf("Now displaying image: x=%d, y=%d, w=%d, h=%d, ox=%d, oy=%d, b->id:%p\n", x,y,w,h,ox,oy, b->id); // equivalent to: // XCopyArea(fl_display, b->id, fl_window, fl_gc, x, y, w, h, ox, oy); fl_copy_offscreen(ox, oy, w, h, (Fl_Offscreen)b->id, x, y); im_draw_finished = true; } void fl_draw_clipped_nobuf(Fl_RGB_Image *b, /* Input image */ int ox, /* x origin of where the image will be drawn in the window */ int oy, /* y origin of where the image will be drawn in the window */ int x, /* x origin of the bounding box in the image */ int y, /* y origin of the bounding box in the image */ int w, /* width of the bounding box in the image */ int h) /* height of the bounding box in the image */ { /** draws a Fl_RGB_Image object clipped to a given bounding box RETURN VALUE: void DESCRIPTION: The input Fl_RGB_Image is drawn, subject to the given bounding box. The Fl_RGB_Image is *NOT* centered in the bounding box. It is expected that x > 0, y > 0, w > 0, h > 0 and w and h are smaller than the image's dimension. This functions doesn't use an off-screen pixmap. It is slower to update but uses less memory. HISTORY: Hugues Talbot 4 Nov 1997 TESTS: REFERENCES: KEYWORDS: **/ static uchar *buf = 0; int d, i; d = b->d(); // image depth // incorrect entries if (w < 0) w = 0; if (h < 0) h = 0; if (x < 0) x = 0; if (y < 0) y = 0; if (w > b->w()) { w = b->w(); } if (h > b->h()) { h = b->h(); } // somewhat subtle cases if (x+w > b->w()) { // adjust x x = b->w() - w; } if (y+h > b->h()) { // adjust y y = b->h() - h; } if (buf) { free(buf); buf = 0; } // realloc buffer, don't care about old content. //dbgprintf("Display: b->w=%d, b->d=%d, d=%d, x=%d, y=%d, w=%d, h=%d\n", // b->w, b->d, d, x, y, w, h); buf = (uchar *)malloc(w * h * d * sizeof(uchar)); for (i = 0 ; i < h ; i++) { memcpy(buf + i*w*d, b->data()[0] + d*x + (y+i) * b->w() * d, w * d); } if (d == 1) { dbgprintf("Call to fl_draw_image_mono\n"); fl_draw_image_mono((const uchar *)buf, ox, oy, w, h, d, 0); im_draw_finished = true; } else { dbgprintf("Call to fl_draw_image\n"); fl_draw_image((const uchar *)buf, ox, oy, w, h, d, 0); im_draw_finished = true; } } static void zoominwh(uchar *outbuf, /* output buffer */ const uchar *inbuf, /* input buffer */ int ow, /* output buffer width */ int oh, /* output buffer height */ int iw, /* input buffer width */ int d, /* bytes per pixel in both buffers */ int x, /* x origin of bounding box in input buffer */ int y, /* y origin of BB */ int w, /* width of BB */ int h) /* height of BB */ { /** fast zoom in, both in width and height, on part of a buffer RETURN VALUE: static void no return value DESCRIPTION: This function takes a subset of an input buffer and zooms it in to fit in the dimensions of the output buffer. HISTORY: written by Hugues Talbot 14 Nov 1997 TESTS: REFERENCES: KEYWORDS: **/ int i, j, k, ii; int ex, inc1x, inc2x; int ey, inc1y, inc2y; uchar *op; const uchar *ip; inc1y = 2 * (h - oh); inc2y = 2 * h; ey = inc1y + h; // 2*h - oh; would start in the middle of a pixel for (i = 0, ii = 0 ; i < oh ; i++) { if (i > 0) { // we cannot even think about duplicating lines if none are present if (ey > 0) { // we have to work out a new line ey += inc1y; ii++; } else { // we can simply duplicate the previous line memcpy(outbuf + i*ow*d, outbuf + (i-1)*ow*d, ow*d); ey += inc2y; continue; } } op = outbuf + i*ow*d; ip = inbuf + d*x + (y+ii) * iw * d; // first pixel of the line for (k = 0 ; k < d ; k++) { *op++ = *(ip + k); } // rest of the pixels along that line inc1x = 2 * (w - ow); inc2x = 2 * w; ex = inc1x + w; // 2*w - ow; would start in the middle of a pizel for (j = 1 ; j < ow ; j++) { if (ex > 0) { ip += d; ex += inc1x; } else { ex += inc2x; } // duplicate pixels for (k = 0 ; k < d ; k++) { *op++ = *(ip + k); } } } } static void zoominh_only(uchar *outbuf, /* output buffer */ const uchar *inbuf, /* input buffer */ int ow, /* output buffer width */ int oh, /* output buffer height */ int iw, /* input buffer width */ int d, /* bytes per pixel in both buffers */ int x, /* x origin of bounding box in input buffer */ int y, /* y origin of BB */ int w, /* width of BB */ int h) /* height of BB */ { /** fast zoom in height, on part of a buffer RETURN VALUE: static void no return value DESCRIPTION: This function zooms in part of the images in the vertical direction only. This allows the zoom in function to be implemented in a separable way: zoom h first and then w. This is also useful when the user resizes the main window in such a way that one dimension is zoomed in while the other is zoomed out. HISTORY: written by Hugues Talbot 30 Sep 2002. TESTS: REFERENCES: KEYWORDS: **/ int i, ii; int ey, inc1y, inc2y; assert(oh > h); // we are zooming in assert(h > 0); // the bounding box does not have 0 height inc1y = 2 * (h - oh); inc2y = 2 * h; ey = inc1y + h; // 2*h - oh; would start in the middle of a pixel assert(ow == w); // width should be unchanged // first line special case: ii = 0; memcpy(outbuf, inbuf + d * (x + y * iw), ow*d); if (ey > 0) { ey += inc1y; ++ii; } else { ey += inc2y; } for (i = 1 ; i < oh ; ++i) { if (ey > 0) { // we have to work out a new line ey += inc1y; memcpy(outbuf + d * i*ow, inbuf + d* (x + (y+ii) * iw), ow*d); ++ii; } else { // we can simply duplicate the previous line memcpy(outbuf + i*ow*d, outbuf + (i-1)*ow*d, ow*d); ey += inc2y; continue; } } } static void zoominw_only(uchar *outbuf, /* output buffer */ const uchar *inbuf, /* input buffer */ int ow, /* output buffer width */ int oh, /* output buffer height */ int iw, /* input buffer width */ int d, /* bytes per pixel in both buffers */ int x, /* x origin of bounding box in input buffer */ int y, /* y origin of BB */ int w, /* width of BB */ int h) /* height of BB */ { /** fast zoom in width on part of a buffer RETURN VALUE: static void no return value DESCRIPTION: This function zooms on part of a buffer in the horizontal direction only (does not zoom in height). This allows the zoom-in function to be implemented in a separable way: zoom w first and then h (say). This is also useful when the user resizes the main window in such a way that one dimension is zoomed in while the other is zoomed out. HISTORY: written by Hugues Talbot 30 Sep 2002 TESTS: REFERENCES: KEYWORDS: **/ int i, j, k; int ex, inc1x, inc2x; int ey, inc2y; uchar *op; const uchar *ip; assert( h == oh ); // must have same height inc2y = 2 * h; // = 2*h ey = h; // = h for (i = 0 ; i < oh ; ++i) { op = outbuf + i*ow*d; ip = inbuf + d*x + (y+i) * iw * d; // first pixel of the line for (k = 0 ; k < d ; ++k) { *op++ = *(ip + k); } // rest of the pixels along that line inc1x = 2 * (w - ow); inc2x = 2 * w; ex = inc1x + w; // 2*w - ow; would start in the middle of a pizel for (j = 1 ; j < ow ; ++j) { if (ex > 0) { ip += d; ex += inc1x; } else { ex += inc2x; } // duplicate pixels for (k = 0 ; k < d ; ++k) { *op++ = *(ip + k); } } } } static void zoomoutw_smooth(uchar *outbuf, /* output buffer */ const uchar *inbuf, /* input buffer */ int ow, /* width of the output buffer */ int d, /* number of bytes per pixel in both buffers */ int iw, /* width of the input buffer */ int x, /* x coord. bounding box in input buffer */ int y, /* y coord BB */ int w, /* w width BB */ int h) /* h height BB */ { /** This function zooms out a buffer in the x direction RETURN VALUE: static void DESCRIPTION: This function zooms out a buffer in the x direction. The algorithm does nearest neighbour smoothing. HISTORY: written by Hugues Talbot 14 Nov 1997 TESTS: REFERENCES: KEYWORDS: **/ int i, j, k; int *accum; int nbaccum; int ex, inc1x, inc2x; uchar *op; const uchar *ip; accum = new int[d]; // dynamic array // zoom out in the horizontal direction for (i = 0 ; i < h ; i++) { // set up the integer counters ex = 2*ow - w; inc1x = 2 * (ow - w); inc2x = 2 * ow; // set up the line pointers // output will be the intermediary buffer op = outbuf + i*ow*d; // same as above ip = inbuf + d * (x + (y+i) * iw) ; // line are not zoomed out yet. // work out what to write // -- first pixel for (k = 0 ; k < d ; k++) accum[k] = 0; nbaccum = 0; // rest of the line for (j = 0 ; j < w ; j++) { // fill in the accumulators for (k = 0 ; k < d ; k++) accum[k] += *ip++; // ip is always advancing nbaccum++; if (ex > 0) { // time has come to write out something; for (k = 0 ; k < d ; k++) { *op++ = (int)(((double)(accum[k])/nbaccum) + 0.5); // write out the average accum[k] = 0; // clear the accumulator } nbaccum = 0; ex += inc1x; } else { ex += inc2x; } } } delete[] accum; } static void zoomoutw(uchar *outbuf, /* output buffer */ const uchar *inbuf, /* input buffer */ int ow, /* width of the output buffer */ int d, /* number of bytes per pixel in both buffers */ int iw, /* width of the input buffer */ int x, /* x coord. bounding box in input buffer */ int y, /* y coord BB */ int w, /* w width BB */ int h) /* h height BB */ { /** This function zooms out a buffer in the x direction RETURN VALUE: static void DESCRIPTION: This function zooms out a buffer in the x direction. No smoothing, just sub-sampling. HISTORY: written by Hugues Talbot 14 Nov 1997 TESTS: REFERENCES: KEYWORDS: **/ int i, j, k; int ex, inc1x, inc2x; uchar *op; const uchar *ip; // zoom out in the horizontal direction for (i = 0 ; i < h ; i++) { // set up the integer counters ex = 2*ow - w; inc1x = 2 * (ow - w); inc2x = 2 * ow; // set up the line pointers // output will be the intermediary buffer op = outbuf + i*ow*d; // same as above ip = inbuf + d * (x + (y+i) * iw) ; // line are not zoomed out yet. // work out what to write for (j = 0 ; j < w ; j++) { if (ex > 0) { // time has come to write out something; for (k = 0 ; k < d ; k++) { *op++ = *ip++; } ex += inc1x; } else { ex += inc2x; ip += d; // next pixel } } } } static void zoomouth_smooth(uchar *outbuf, /* Output buffer */ const uchar *inbuf, /* input buffer */ int oh, /* height of the output buffer */ int d, /* number of bytes per pixel */ int iw, /* width of the input buffer */ int x, /* x origin of bounding box in input buffer */ int y, /* y origin for BB */ int w, /* width of BB */ int h) /* height of BB */ { int i, j, k; int *accum; int nbaccum; int ey, inc1y, inc2y; uchar *op; const uchar *ip; accum = new int[d]; // now zoom out the vertical direction for (j = 0 ; j < w ; j++) { // set up the integer counters ey = 2*oh -h; inc1y = 2 * (oh - h); inc2y = 2 * oh; // output will be the final buffer op = outbuf + j * d; // input will be the intermediary buffer allocated above ip = inbuf + d * ((x+j) + y*iw); // work out what to write // first pixel for (k = 0 ; k < d ; k++) accum[k] = 0; nbaccum = 0; // rest of the column for (i = 0 ; i < h ; i++) { // fill in the accumulators for (k = 0 ; k < d ; k++) { accum[k] += *(ip+k); } ip += iw * d; // skip one line nbaccum++; if (ey > 0) { // time has come to write out something for (k = 0 ; k < d ; k++) { *(op+k) = (int)(((double)(accum[k])/nbaccum) + 0.5); // write out the average accum[k] = 0; // clear the accumulator } op += w * d; // skip one line nbaccum = 0; ey += inc1y; } else { ey += inc2y; } } } // free the dynamic array delete[] accum; } static void zoomouth(uchar *outbuf, /* Output buffer */ const uchar *inbuf, /* input buffer */ int oh, /* height of the output buffer */ int d, /* number of bytes per pixel */ int iw, /* width of the input buffer */ int x, /* x origin of bounding box in input buffer */ int y, /* y origin for BB */ int w, /* width of BB */ int h) /* height of BB */ { int i, j, k; int ey, inc1y, inc2y; uchar *op; const uchar *ip; // now zoom out the vertical direction for (j = 0 ; j < w ; j++) { // set up the integer counters ey = 2*oh -h; inc1y = 2 * (oh - h); inc2y = 2 * oh; // output will be the final buffer op = outbuf + j * d; // input will be the intermediary buffer allocated above ip = inbuf + d * ((x+j) + y*iw); // work out what to write // rest of the column for (i = 0 ; i < h ; i++) { if (ey > 0) { // time has come to write out something for (k = 0 ; k < d ; k++) { *(op+k) = *(ip+k); } op += w * d; // skip one line ey += inc1y; } else { ey += inc2y; } ip += iw * d; // skip one line } } } /* zcnb stands for zoomed, clipped, nobuffering */ void fl_draw_zcnb(Fl_RGB_Image *b, /* Input image */ int ox, /* x origin of where the image will be drawn in the window */ int oy, /* y origin of where the image will be drawn in the window */ int ow, /* width of the window the image will be drawn to */ int oh, /* height of the window the image will be drawn to */ int x, /* x origin of the bounding box in the image */ int y, /* y origin of the bounding box in the image */ int w, /* width of the bounding box in the image */ int h, /* height of the bounding box in the image */ int drawsmooth) /* should the output be smooth or not */ { /** draws a Fl_RGB_Image object zoomed and clipped to a given bounding box RETURN VALUE: void DESCRIPTION: The input Fl_RGB_Image is drawn, subject to the given bounding box. The Fl_RGB_Image is *NOT* centered in the bounding box. It is expected that x > 0, y > 0, w > 0, h > 0 and w and h are smaller than the image's dimension. The portion of the image in the input bounding box is scaled to fit in the output window frame. This functions doesn't use an off-screen pixmap. It is slower to update but uses less memory. HISTORY: Hugues Talbot 4 Nov 1997 TESTS: REFERENCES: KEYWORDS: **/ int d; static uchar *buf = 0; static uchar *buf2 = 0; d = b->d(); // image depth // incorrect entries if (ow < 0) ow = 0; if (oh < 0) oh = 0; if (w < 0) w = 0; if (h < 0) h = 0; if (x < 0) x = 0; if (y < 0) y = 0; if (w > b->w()) { w = b->w(); } if (h > b->h()) { h = b->h(); } // somewhat subtle cases if (x+w > b->w()) { // bounding box exceed right hand boundary // adjust x x = b->w() - w; } if (y+h > b->h()) { // bounding box exceeds bottom boundary // adjust y y = b->h() - h; } if (buf) { free(buf); buf = 0; // buf may not have been allocated even if this function has been called before } // realloc buffer, don't care about old content, realloc would be less efficient buf = (uchar *)malloc(ow * oh * d * sizeof(uchar)); //dbgprintf("Display: ox=%d oy=%d ow=%d oh=%d x=%d y=%d w=%d h=%d\n", // ox, oy, ow, oh, x , y , w, h); // bresenham-like processing if (ow >= w && ((ow != w) || (oh >= h))) { if (oh >= h) { zoominwh(buf, (const uchar*)(b->data()[0]), ow, oh, b->w(), d, x, y, w, h); } else { // oh < h dbgprintf("Case (1) where (ow=%d >= w=%d && oh=%d < h=%d) \n", ow, w, oh, h); // Zooming in w and zooming out in h if (buf2 != 0) { free(buf2); buf2 = 0; } buf2 = (uchar *)malloc(ow * h * d * sizeof(uchar)); zoominw_only(buf2, (const uchar*)(b->data()[0]), ow, h, b->w(), d, x, y, w, h); if (drawsmooth) zoomouth_smooth(buf, buf2, oh, d, ow, 0,0,ow,h); else zoomouth(buf, buf2, oh,d,ow,0,0,ow,h); } } else { // ow <= w // whereas for zooming in it is OK to just show larger pixels (in general) // zooming out requires some smoothing or the result just looks awful. // the idea here is to accumulate pixel values in the larger window until // one pixel has to be written in the smaller one. The average of the // accumulated pixels is written. // in this case we need a second buffer for the intermediary image if (buf2 != 0) { free(buf2); buf2 = 0; } buf2 = (uchar *)malloc(ow * h * d * sizeof(uchar)); // zoom out the x dimension if (drawsmooth) zoomoutw_smooth(buf2,(const uchar*)(b->data()[0]),ow,d,b->w(),x,y,w,h); else zoomoutw(buf2,(const uchar *)(b->data()[0]),ow,d,b->w(),x,y,w,h); if (oh < h) { if (drawsmooth) zoomouth_smooth(buf, buf2, oh,d,ow,0,0,ow,h); else zoomouth(buf, buf2, oh,d,ow,0,0,ow,h); } else if (oh == h) { // this should work memcpy(buf, buf2, ow*oh*d); } else { dbgprintf("Case (2) where (ow = %d < w = %d && oh = %d > h = %d)\n", ow, w, oh, h); // zooming out in w and in in h // (zoomin out in w already done) zoominh_only(buf, buf2, ow, oh, ow, d, 0, 0, ow, h); } } if (d == 1) { dbgprintf("Call to fl_draw_image\n"); fl_draw_image_mono((const uchar *)buf, ox, oy, ow, oh, d, 0); im_draw_finished = true; } else { dbgprintf("Call to fl_draw_image\n"); fl_draw_image((const uchar *)buf, ox, oy, ow, oh, d, 0); im_draw_finished = true; } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/my_Image.hxx��������������������������������������������������������������������������0000644�0000765�0000765�00000004223�07653236471�016271� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: my_Image.hxx,v 4.0 2003/04/28 14:39:53 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Image drawing complementary functions. * *-----------------------------------------------------------------------*/ #ifndef MY_IMAGE_H #define MY_IMAGE_H void freeOffScreenPixmap(Fl_RGB_Image *b); void fl_draw_clipped(Fl_RGB_Image *b,int ox,int oy,int x,int y,int w,int h); void fl_draw_clipped_nobuf(Fl_RGB_Image *b,int ox,int oy,int x,int y,int w,int h); void fl_draw_zcnb(Fl_RGB_Image *b,int ox,int oy,int ow, int oh,int x,int y,int w,int h,int isSmooth); #endif �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/nocase.hxx����������������������������������������������������������������������������0000644�0000765�0000765�00000004414�07653236472�016015� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: nocase.hxx,v 4.0 2003/04/28 14:39:54 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Needed by these classes which use string comparisons * Defining this small header is unpalatable, but so are the alternatives. * * Hugues Talbot 1 Mar 2000 * *-----------------------------------------------------------------------*/ #ifndef NOCASE_H #define NOCASE_H using std::string; // the Nocase comparison class // The operator is defined in imview.C class Nocase { public: bool operator () (const string &x, const string &y) const; }; // string comparison, case insensitive, also defined in imview.C int cmp_nocase(const string &a, const string &b); #endif //NOCASE_H ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/patchlevel.h��������������������������������������������������������������������������0000644�0000765�0000765�00000004367�10756343024�016311� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: patchlevel.h,v 4.80 2008/02/12 18:06:39 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Most of imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * This file takes care of the versioning (and of the last builder) * Do not edit it by hand, it gets modified by the program `buildnb' * in the top-level directory. * * Hugues Talbot 8 Aug 2000 * *-----------------------------------------------------------------------*/ #define XSTR(S) STR(S) #define STR(NAME) #NAME /* - Changes below this line will get deleted - LEAVE THINGS AS THEY ARE -*/ const char *patchlevel=XSTR(IMVIEW_MAJOR) "." XSTR(IMVIEW_MINOR) "." XSTR(IMVIEW_MICRO); int buildnb = 237 ; int totalbnb = 3805 ; char *builder = "talbot" ; �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/pointfile.cxx�������������������������������������������������������������������������0000644�0000765�0000765�00000144253�10754360057�016530� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: pointfile.cxx,v 4.7 2008/02/12 18:06:39 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * impointfile.C * * This file contains the code managing pointfiles. * It has gotten really messy lately because of PSL's requirement at some * point (not of much use these days) and because of Nick Lange's wish to * have a drag-to-draw procedure. * * Hugues Talbot 4 Mar 1998 * * Messy stuff: * Hugues Talbot 22 Jun 2004 * *-----------------------------------------------------------------------*/ #include <vector> // STL #include <algorithm> #include <functional> #include <assert.h> #include <cstring> #include "imunistd.h" #include "imview.hxx" #include "pointfile.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "annotatePoints.hxx" extern imageViewer *mainViewer; extern imageIO *IOBlackBox; extern annotatept *annotatePointPanel; extern bool simplePointfile; using std::setw; using std::mem_fun_ref; using std::remove_if; string ptDummyStr; // for default string arguments // implementation for mypoint mypoint::mypoint(void) : Fl_Object(0,0,0,0,0) { x_ = y_ = z_ = 0; Rval_ = Gval_ = Bval_ = 0; nbraw_ = 0; // no raw data coming from display radius_ = 3; hasAnnotation_ = false; annotation_.erase(); // clear the string stringColour_ = FL_RED; // default colour stringFont_ = FL_TIMES; stringSize_ = 10; stringQuadrant_ = STR_SE; // south-east linelength_ = STR_LINE_LN; hidden_ = false; selected_ = false; lsty_ = STYLE_FILLED_BW; // relevant for breaks only lcol_ = FL_BLACK; } // this is the copy constructor mypoint::mypoint(const mypoint &p) : Fl_Object(p.x(),p.y(), 7, 7, 0) { x_ = p.x(); y_ = p.y(); z_ = p.z(); Rval_ = p.Rval(); Gval_ = p.Gval(); Bval_ = p.Bval(); nbraw_ = p.nbraw(); radius_ = p.radius(); hasAnnotation_ = p.hasAnnotation(); annotation_ = p.annotation(); stringColour_ = p.stringColour(); stringFont_ = p.stringFont(); stringSize_ = p.stringSize(); stringQuadrant_ = p.stringQuadrant(); linelength_ = p.linelength(); selected_ = p.selected(); hidden_ = p.isHidden(); lsty_ = p.getLSty(); lcol_ = p.getLCol(); } mypoint::mypoint(int X, int Y, int Z, unsigned char Rval, unsigned char Gval, unsigned char Bval, int nbraw, bool annotated, string &txt, Fl_Color col, int font, int size, int length, str_quadrant qdr, bool h, int pts, linestyle lsty, Fl_Color lcol) : Fl_Object(X, Y, 7, 7, 0) { x_ = X ; y_ = Y; z_ = Z; Rval_ = Rval; Gval_ = Gval; Bval_ = Bval; nbraw_ = nbraw; // data coming from imageViewer if ( annotated ) { hasAnnotation_ = true; // convert back from inlined annotation_inlined(txt); stringColour_ = col; stringFont_ = font; stringSize_ = size; stringQuadrant_ = qdr; linelength_ = length; hidden_ = h; radius_ = pts; lsty_ = lsty; lcol_ = lcol; } else { hasAnnotation_ = false; annotation_.erase(); // clear the string stringColour_ = FL_RED; // default colour stringFont_ = FL_TIMES; stringSize_ = 10; stringQuadrant_ = STR_SE; // south-east linelength_ = STR_LINE_LN; hidden_ = false; radius_ = 3; lsty_ = STYLE_FILLED_BW; lcol_ = FL_BLACK; } // at any rate selected_ = false; } mypoint::~mypoint() { dbgprintf("Point at (%d,%d) destructed\n", x(), y()); } mypoint& mypoint::operator=(mypoint &p) { if (this == &p) return *this ; // but do nothing more x_ = p.x(); y_ = p.y(); z_ = p.z(); Rval_ = p.Rval(); Gval_ = p.Gval(); Bval_ = p.Bval(); nbraw_ = p.nbraw(); // coming from viewer radius_ = p.radius(); hasAnnotation_ = p.hasAnnotation(); annotation_ = p.annotation(); stringColour_ = p.stringColour(); stringFont_ = p.stringFont(); stringSize_ = p.stringSize(); stringQuadrant_ = p.stringQuadrant(); linelength_ = p.linelength(); selected_ = p.selected(); hidden_ = p.isHidden(); return *this; } const string& mypoint::annotation_inlined(void) { string::size_type pos; annotation_inlined_ = annotation_; // the whole commend must fit in a line while ((pos = annotation_inlined_.find("\n")) != string::npos) { annotation_inlined_.replace(pos, 1, "\\n"); // careful, the `\\' here is not a typo } return annotation_inlined_; } void mypoint::annotation_inlined(string &in) { string::size_type pos; annotation_ = in; // re-place the \n while ((pos = annotation_.find("\\n")) != string::npos) { // careful, the `\\' here is not a typo annotation_.replace(pos, 2, "\n"); } return; } // void mypoint::pointdefaults(const pointParams &pp) { defaultParms_ = pp; // POD return; } void mypoint::draw() { double zoomf = mainViewer->zoomFactor(); int maxradius = trivmin(mainViewer->w(), mainViewer->h()); int truex = mainViewer->xOnWindow(x_); int truey = mainViewer->yOnWindow(y_); double enlarge = ((maxradius-radius_)*zoomf)/(maxradius-radius_+zoomf); int trueradius = (int)(enlarge + radius_); double pointZoom = (double)trueradius/radius_; if (IOBlackBox->getCurrZpos() == z_) { //dbgprintf("Circle being drawn at position (%d,%d) " // "on window with radius %d, zoomfactor=%f\n", // truex, truey, trueradius, zoomf); // do not draw outside of the image fl_push_no_clip(); fl_clip(mainViewer->x(), mainViewer->y(), mainViewer->visibleWidth(), mainViewer->visibleHeight()); if (selected()) { fl_begin_line(); fl_color(FL_GREEN); fl_circle(truex,truey,trueradius); fl_color(FL_RED); fl_circle(truex,truey,trueradius+1); fl_end_line(); } else if (!hasAnnotation_) { // non-annotated points fl_begin_line(); fl_color(FL_WHITE); fl_circle(truex,truey,trueradius); fl_color(FL_BLACK); fl_circle(truex,truey,trueradius+1); fl_end_line(); } else { // draw a filled-in point fl_color(stringColour_); fl_pie(truex-trueradius, truey-trueradius, trueradius * 2, trueradius * 2, 0, 360); } // Print the annotation, if any if (annotation_.length() > 0 && !hidden_) { int saveFont = fl_font(); int saveSize = fl_size(); int xdir = 0, ydir = 0; int ws, wss, wmax, hs, hss, xs, ys; int i, j, l, nbl; const char *text = annotation_.c_str(); char multitext[DFLTSTRLEN], c; vector<int> linebreaks; strncpy(multitext, text, DFLTSTRLEN); fl_font(stringFont_, (int)(stringSize_ * pointZoom + 0.5)); fl_color(stringColour_); switch (stringQuadrant_) { default: case STR_SE: xdir = ydir = +1; xs = 0; ys = 1; // add height to position of string break; case STR_NE: xdir = +1; ydir = -1; xs = ys = 0; // default pos is fine break; case STR_SW: xdir = -1; ydir = +1; xs = -1; // move text left by it width ys = +1; // lower text by its height break; case STR_NW: xdir = ydir = -1; xs = -1; // move text left by its width ys = 0; break; } // remove trailing \n's if needed (perl chop) l = strlen(multitext); while ((l > 0) && (multitext[l - 1] == '\n')) { multitext[l - 1] = '\0'; l--; } // draw a line from point to text fl_line(truex + trueradius * xdir, truey + trueradius * ydir, truex + (trueradius + linelength_) * xdir, truey + (trueradius + linelength_) * ydir); // measure dimensions of chopped string ws = (int)(fl_width(text)); // except ws is wrong (bug in FLTK?) hss = fl_height(); // height of a single line // first pass: count number of lines and max width i = j = nbl = wmax = 0 ; linebreaks.clear(); // empty vector linebreaks.push_back(0); // first line starts at 0 while (1) { // look for line breaks c = multitext[j]; if ((c == '\n') || (c == '\0')) { linebreaks.push_back(j+1); // record location of first char after line break multitext[j] = '\0'; // force end of string wss = (int)(fl_width(multitext + linebreaks[nbl])); // measure partial string nbl++; if (wss > wmax) wmax = wss; // measure widest string! if (c == '\0') break; } j++; } // total height hs = hss * nbl; // second pass: draw the strings dbgprintf("printing %d lines\n", nbl); for (i = 0 ; i < nbl ; i++) { dbgprintf("Printing: %s\n", multitext + linebreaks[i]); fl_draw(multitext + linebreaks[i], truex + (trueradius + linelength_) * xdir + wmax * xs, truey + (trueradius + linelength_) * ydir + hss * (ys + i) + (ys-1) * (hss * (nbl-1)) ); // ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^ // Terms: positioning of line offset for multiline } fl_font(saveFont,saveSize); } fl_pop_clip(); // pop the view clip fl_pop_clip(); // pop the no_clip } //else { // dbgprintf("This point not in current plane\n"); // } return; } // this function is called AFTER the image rotation, // hence width and height have been swapped already! void mypoint::rotate90p(void) { int yy; int imw, imh; int s; dbgprintf("Old x= %d, old y= %d\n", x_, y_); imw = IOBlackBox->imageWidth(); imh = IOBlackBox->imageHeight(); yy = imh-x_-1; x_ = y_; y_ = yy; s = (int)stringQuadrant_; // rotate annotation too! if (annotation_.length() > 0) { s -= 1; if (s < 0) s += STR_QUAD_MAX; s %= STR_QUAD_MAX; } stringQuadrant_ = (str_quadrant)s; dbgprintf("New x= %d, new y= %d\n", x_, y_); return; } // this function is called AFTER the image rotation, // hence Y and Z have been swapped already! void mypoint::rotate3dup(void) { int yy; int imw, imh, imt; dbgprintf("Old x= %d, old y= %d, old z=%d \n", x_, y_, z_); imw = IOBlackBox->imageWidth(); imh = IOBlackBox->imageHeight(); imt = IOBlackBox->imageThickness(); // x_ unchanged yy = z_; z_ = imh-y_-1; y_ = yy; // don't bother changing the quadrant... dbgprintf("New x= %d, new y= %d, new z=%d\n", x_, y_, z_); return; } void mypoint::rotate3ddown(void) { int yy; int imw, imh, imt; dbgprintf("Old x= %d, old y= %d, old z=%d \n", x_, y_, z_); imw = IOBlackBox->imageWidth(); imh = IOBlackBox->imageHeight(); imt = IOBlackBox->imageThickness(); // x_ unchanged yy = imt-z_-1; z_ = y_; y_ = yy; // don't bother changing the quadrant... dbgprintf("New x= %d, new y= %d, new z=%d\n", x_, y_, z_); return; } void mypoint::rotate90m(void) { int xx; int imw; int s; dbgprintf("Old x= %d, old y= %d\n", x_, y_); imw = IOBlackBox->imageWidth(); xx = imw - y_ - 1; y_ = x_; x_ = xx; s = (int)stringQuadrant_; // rotate annotation too! if (annotation_.length() > 0) { s += 1; s %= STR_QUAD_MAX; } stringQuadrant_ = (str_quadrant)s; dbgprintf("New x= %d, new y= %d\n", x_, y_); return; } void mypoint::flipv(void) { int imw = IOBlackBox->imageWidth(); int s; x_ = imw - x_ - 1; s = (int)stringQuadrant_; s = abs(s - 3); // try it. stringQuadrant_ = (str_quadrant)s; return; } void mypoint::fliph(void) { int imh = IOBlackBox->imageHeight(); int s; s = (int)stringQuadrant_; switch (stringQuadrant_) { case STR_NE: case STR_SW: s += 1; break; case STR_SE: case STR_NW: s -= 1; break; default: errprintf("Incorrect quadrant\n"); break; } stringQuadrant_ = (str_quadrant)s; y_ = imh - y_ - 1; return; } // implementation for pointfile pointfile::pointfile() { PtFileName = ""; // empty string saveAsOldFormat = 1; // by default we save the points in the old x11() format currentlinestyle_ = STYLE_FILLED_BW; currentlinecolour_ = FL_WHITE; xorvalforlines = DEFAULT_XOR_FG; hasChanged = false; // change detection dbgprintf("pointfile class initialized\n"); } pointfile::~pointfile() { dbgprintf("Pointfile desctructor called, saving to file\n"); showlist(); // this is optional if (hasChanged) savelist(false); // making a backup, recommended rmAllPoints(); // this is necessary to avoid some weird event backtrack side effects from FLTK. dbgprintf("done\n"); } int pointfile::setPtFileName(const char *nm) { PtFileName = nm; return 0; } const char *pointfile::getPtFileName(void) { if (PtFileName != "") return(PtFileName.c_str()); // return the C string. else return 0; } const char *pointfile::getPtFileNameIfPresent(const char *imageName) { static char pfpath[1024]; char *retval = 0; dbgprintf("Checking for the present of a pointfile for the given image.\n"); sprintf(pfpath, "./%s", imageName); strcat(pfpath, ".pf"); // pfpath now ends sensibly in .pf dbgprintf("Checking for %s\n", pfpath); if (access(pfpath, R_OK) == 0) { retval = pfpath; } return retval; } // pb with const-correctness here int pointfile::addPoint(int x, int y, int z, unsigned char Rval, unsigned char Gval, unsigned char Bval, int hasRaw, pointParams &pp) { return(addPoint(x,y,z,Rval,Gval,Bval,hasRaw, pp.annotated, pp.txt, pp.col, pp.font, pp.size, pp.length, pp.qdr, pp.h, pp.pts, pp.lsty, pp.lcol)); } int pointfile::addPoint(int x, int y, int z, unsigned char Rval, unsigned char Gval, unsigned char Bval, int hasRaw, bool annotated, string &annotation, Fl_Color color, int font, int size, int length, str_quadrant qdr, bool hidden, int ptsize, linestyle lstyle, Fl_Color lcolour) { int res = 0; mypoint *aPoint; if (annotated) // a point with annotation aPoint = new mypoint(x,y,z,Rval,Gval,Bval,0, annotated, annotation, color, font, size, length, qdr, hidden, ptsize, lstyle, lcolour); else // normal point aPoint = new mypoint(x,y,z,Rval,Gval,Bval,0); if ((z > 0) // z can be negative to indicate a break point || (Rval != Gval) || (Rval != Bval) || hasRaw || (size > 0)) { // basically, the current image is 3D, colour or has comments saveAsOldFormat = 0; // we must use a new format to save the points } dbgprintf("Adding point (%d,%d,%d)=%d,%d,%d to current pointfile\n", x, y, z, Rval, Gval, Bval); pointlist.push_back(*aPoint); // add the point to the list of things to draw if (!aPoint->isBreak()) mainViewer->add(pointlist.back()); delete aPoint; hasChanged = true; // pointfile was changed return res; } // adds a `break' in the list of points to define a point group // and link all the points together void pointfile::addBreak(bool redraw, linestyle lsty, Fl_Color lcol) { pointIterator pi, pii; // work my way backwards to find the previous break // or the beginning of the list pii = pointlist.end(); --pii; // one position from the end if (!pii->isBreak()) { // no adding of a break immediately after a break // first draw the line if (redraw) { // work my way backwards to find the previous break // or the beginning of the list pii = pointlist.end(); --pii; // one position from the end while ((!pii->isBreak()) && (pii != pointlist.begin())) --pii; // first element from the end if (pii->isBreak()) ++pii; // now we are at the first point from where to draw lines pi = pii++; while (pii != pointlist.end()) { dbgprintf("Adding a line joining A(%d, %d) to B(%d,%d)\n", pi->x(), pi->y(), pii->x(), pii->y() ); linelist.push_back(imline(pi->x(), pi->y(), pii->x(), pii->y(), lsty, xorvalforlines, lcol)); mainViewer->add(linelist.back());// so that it really gets displayed // call the draw routine by hand if possible (linelist.back()).redraw(); pi = pii++; } // do not call redrawLines(); } // style and colour of the line pointParams myparams; myparams.annotated = true; myparams.lsty = lsty; myparams.lcol = lcol; addPoint(-1,-1,WEIRD_CONSTANT, 0, 0, 0, 0, myparams); dbgprintf("Adding break with style=%d, colour=%d\n", (int)lsty, (int)lcol); showlist(); hasChanged = true; // pointfile was changed } return; } // This can be an extraordinarily expensive call if there are a // large number of lines. // redrawns all the lines. // Does not join point groups that do not end // with a `break' void pointfile::redrawLines(void) { pointIterator pi, pii, lastpi; imline aLine; bool hasABreak = false; // remove all the existing lines while (!linelist.empty()) { mainViewer->remove(linelist.front()); // erase the line //(linelist.front()).undraw(); // doesn't always work linelist.pop_front(); } // force the redraw of the entire image. mainViewer->redraw_image(); // now redraw lines between groups separated by breaks. lastpi = pointlist.end(); // special value: means `invalid' for (pi = pointlist.begin() ; pi != pointlist.end() ; ++pi) { if (lastpi != pointlist.end() && (!(*pi).isBreak())) { // now look for a `break' if (!hasABreak) { for (pii = pi ; pii != pointlist.end() ; ++pii) { if ((*pii).isBreak()) { hasABreak = true; break; } } // if there is no break left in the list, no need // to try and draw any line... if (pii == pointlist.end()) break; } if (hasABreak) { dbgprintf("Adding a line joining A(%d, %d) to B(%d,%d)\n", (*lastpi).x(), (*lastpi).y(), (*pi).x(), (*pi).y() ); linelist.push_back(imline((*lastpi).x(), (*lastpi).y(), (*pi).x(), (*pi).y(), pii->getLSty(), xorValueForLines(), pii->getLCol())); mainViewer->add(linelist.back()); // so that it really gets displayed // call the draw routine by hand if possible //(linelist.back()).redraw(); } } if (!(*pi).isBreak()) { lastpi = pi; } else { lastpi = pointlist.end(); hasABreak = false; } } mainViewer->redraw(); return; } void pointfile::resetLinesStatus(void) { // tell all the lines they've just been erased... lineIterator li; for (li = linelist.begin() ; li != linelist.end() ; ++li) { (*li).drawnStatus(0); } return; } pointIterator pointfile::findClosestPoint(int x, int y) { pointIterator i, minI, retval; int currZ; int j, minJ = -1; double dist, mindist = 1e30, zoomf; int maxradius = trivmin(mainViewer->w(), mainViewer->h()); int cutoff; currZ = IOBlackBox->getCurrZpos(); dbgprintf("Removing point on plane %d nearest to (%d,%d)\n", currZ, x, y); for (i = pointlist.begin(), j = 0 ; i != pointlist.end() ; ++i, ++j) { if ((*i).z() == currZ) { dist = sqrt((double)((x-(*i).x())*(x-(*i).x()) + (y-(*i).y())*(y-(*i).y()))); //dbgprintf("Point %d is suitable, distance = %f\n", // j, dist); } else { dist = -1; } if ((dist >= 0) && (dist < mindist)) { mindist = dist; minI = i; minJ = j; // for debugging only } } zoomf= mainViewer->zoomFactor(); cutoff = (int)(((maxradius-PTFILE_CUTOFFD)*zoomf)/(maxradius-PTFILE_CUTOFFD+zoomf) + PTFILE_CUTOFFD); if ((mindist >= 0) && (mindist <= cutoff )) { dbgprintf("Closest point #%d :(x=%4d, y=%4d, z=%4d), distance = %f\n", minJ, (*minI).x(), (*minI).y(), (*minI).z(), mindist); retval = minI; } else { // clutters the debug output //if (mindist < 0) // dbgprintf("No points!\n"); //else // dbgprintf("distance to closest point too great: %f, cutoff = %d\n", // mindist, cutoff); retval = pointlist.end(); } return retval; } void pointfile::rmPoint(int x, int y) { pointIterator minI; minI = findClosestPoint(x,y); if (minI != pointlist.end()) { // prevent it from being redrawn mainViewer->remove(*minI); // delete the appearance of the point mainViewer->deletePoint((*minI).x(), (*minI).y()); // remove it from the list pointlist.erase(minI); // redraw the lines redrawLines(); // pointfile was modified hasChanged = true; } } // remove the whole point group a point belongs to void pointfile::rmPointGroup(int x, int y) { pointIterator minI, firstI, lastI, pI; bool rmsome = false; dbgprintf("Before deletion:\n"); showlist(); minI = findClosestPoint(x,y); if (minI != pointlist.end()) { lastI = firstI = minI; // find the first previous break, if any while ((!firstI->isBreak()) && (firstI != pointlist.begin())) { --firstI; } while ((!lastI->isBreak()) && (lastI != pointlist.end())) { ++lastI; } if (firstI->isBreak()) ++firstI; if (lastI->isBreak()) { // OK, the list of points to consider is // surrounded by breaks; // remove all the points for (pI = firstI ; pI != lastI ; ++pI) { mainViewer->deletePoint(pI->x(), pI->y()); mainViewer->remove(*pI); } // don't forget to remove the break; assert(lastI != pointlist.end()); pI++ = lastI; pointlist.erase(firstI, pI); dbgprintf("After deletion\n"); showlist(); rmsome=true; } } if (rmsome) { redrawLines(); hasChanged = true; } return; } void pointfile::annotatePoint(int x, int y) { pointIterator minI; minI = findClosestPoint(x,y); if (minI != pointlist.end()) { // specify the annotation string text = annotatePointPanel->getAnnotation(); int colour = annotatePointPanel->getFontColour(); int size = annotatePointPanel->getFontSize(); int font = annotatePointPanel->getFont(); str_quadrant q = annotatePointPanel->getFontQuadrant(); int length = annotatePointPanel->getDistance(); bool h = annotatePointPanel->isHidden(); int pts = annotatePointPanel->getPointSize(); (*minI).annotation(text); (*minI).stringColour((Fl_Color) colour); (*minI).stringSize(size); (*minI).stringFont(font); (*minI).stringQuadrant(q); (*minI).linelength(length); (*minI).hide(h); (*minI).radius(pts); saveAsOldFormat = 0; // otherwise the annotation is not saved hasChanged = true; mainViewer->redraw(); } } // returns 1 if a point is close enough int pointfile::getNearestPointParameters(int xx, int yy, string &ann, Fl_Color &col, int &font, int &size, int &length, str_quadrant &q, bool &h, int &ptsize) { pointIterator minI; minI = findClosestPoint(xx,yy); if (minI != pointlist.end()) { ann = (*minI).annotation(); col = (*minI).stringColour(); font = (*minI).stringFont(); size = (*minI).stringSize(); q = (*minI).stringQuadrant(); length = (*minI).linelength(); h = (*minI).isHidden(); ptsize = (*minI).radius(); return 1; } else return 0; } void pointfile::rmLastPoint(void) { if (!pointlist.empty()) { mypoint &aPoint = pointlist.back(); dbgprintf("Removing last point from current pointfile\n"); if (!aPoint.isBreak()) { // remove the last element from the list of things to draw mainViewer->deletePoint(aPoint.x(), aPoint.y()); mainViewer->remove(aPoint); } else { // we need to delete all the lines from that break // to the previous one or to the beginining of the list pointIterator pii; int linesToDelete = 0; pii = ----pointlist.end(); // point before the one being removed while ((!pii->isBreak()) && (pii != pointlist.begin())) { --pii; // first element from the end ++linesToDelete; } // go back up one position if we found a previous break if (pii->isBreak()) { ++pii; --linesToDelete; } // undraw the lines while (linesToDelete-- > 0) { mainViewer->remove(linelist.back()); (linelist.back()).undraw(); linelist.pop_back(); } } // else nothing special to do, just remove the point. // finally remove the point from the list itself pointlist.pop_back(); // do not call redrawLines(); hasChanged = true; } else { dbgprintf("Point list is now empty\n"); } return; } // predicate bool mypoint::isSelectedPred(void) { if (isBreak() && selected()) { dbgprintf("Deleting break point\n"); return true; } else if (selected()) { dbgprintf("Deleting normal point\n"); mainViewer->deletePoint(x(), y()); return true; } else return false; } #if !defined(WIN32_NOTCYGWIN) && (defined(__GNUC__) && (__GNUC__ >= 3)) // According to Scott Meyer it's often better to use STL's algorithms // rather than hand-written loops. // In this case I'm not sure. Here I want to remove from the list // of points those that have been selected by the user. Sounds like a // job for remove_if. The problem is that FLTK relies on the actual // object value to draw it. The algorithm remove_if only cleverly copies objects // inside the list, it does not really remove them as expected. As // a result, a simple application of remove_if wreaks havoc with FLTK's // object list. The solution here is to remove the objects from FLTK's group list // before touching the point list. // The result is typical STL gobbledygook, and anyway MSVC++ 6.0 can't // compile it... bool pointfile::rmSelectedPoints(void) { pointIterator i; bool rmsome = false; dbgprintf("Before deletion:\n"); showlist(); // remove all the points to be displayed for_each(pointlist.begin(), pointlist.end(), bind2nd(mem_fun_ref(&mypoint::removeself),mainViewer)); i = remove_if(pointlist.begin(), pointlist.end(), mem_fun_ref(&mypoint::isSelectedPred)); dbgprintf("After remove_if\n"); showlist(); if (i != pointlist.end()) { pointlist.erase(i, pointlist.end()); dbgprintf("After erase\n"); showlist(); redrawLines(); hasChanged = rmsome = true; } // add back all the points to be displayed for_each(pointlist.begin(), pointlist.end(), bind2nd(mem_fun_ref(&mypoint::addself),mainViewer)); return rmsome; } #else // OK, so in this function we delete the points that were selected, if any // returns true if some points were actually deleted. // NOTE: reverse iterator were not used because they don't help: // http://www.sgi.com/Technology/STL/ReverseIterator.html // fundamental identity of reverse iterators: // reverse_iterator(i).base() == i and &*ri == &*(ri.base() - 1). // see also footnote 3 for why this is (besides making things ugly) // This means that using ri.base() is not obvious at all. bool pointfile::rmSelectedPoints(void) { int n; pointIterator j, jj; // reverse iterator won't work properly. What a bummer. bool rmsome = false; // We need to loop backwards because the end of // the list is affected by the deletion. dbgprintf("Before deletion:\n"); showlist(); j = pointlist.end(); // hopefully legal --j; // should point to the last point before the end n = 0; while (j != pointlist.end()) { // before .begin() is .end() ! if ((*j).isBreak() && (*j).selected()) { // delete that break indicator as it is linked to a point // about to be deleted dbgprintf("Deleting break point\n"); jj = j--; pointlist.erase(jj); dbgprintf("After deletion %d\n", n); showlist(); n++; } else if ((*j).selected()) { dbgprintf("Deleting normal point\n"); mainViewer->deletePoint((*j).x(), (*j).y()); mainViewer->remove(*j); jj = j--; pointlist.erase(jj); // same page dbgprintf("After deletion %d\n", n); showlist(); rmsome = true; n++; } else --j; // simply decrememnt } if (rmsome) { redrawLines(); hasChanged = true; } return rmsome; } #endif void pointfile::rmAllPoints(void) { dbgprintf("Removing all points from current pointfile\n"); // delete the points while (!pointlist.empty()) { mypoint &aPoint = pointlist.back(); // remove the last element from the list of things to draw mainViewer->deletePoint(aPoint.x(), aPoint.y()); mainViewer->remove(aPoint); // then remove it from the list itself pointlist.pop_back(); } // delete the lines while (!linelist.empty()) { imline &aLine = linelist.back(); // same as above mainViewer->remove(aLine); // this will just delete the objects linelist.pop_back(); } saveAsOldFormat = 1; // until we learn better, maybe. hasChanged = true; // reset the point colour if (mainViewer) mainViewer->setPtColourIndex(0); return; } void pointfile::changeSelection(int x, int y, int w, int h, bool selectStatus) { pointIterator i; lineIterator l; int x1, y1, x2, y2; bool allSelected = true; for (i = pointlist.begin(); i != pointlist.end(); ++i) { // select `breaks' if ((*i).isBreak()) { if (allSelected) { (*i).select(selectStatus); // a break is selected if all group points are selected too. if (selectStatus) dbgprintf("Selecting a `break'\n"); else dbgprintf("Un-selecting a `break'\n"); } // in any case allSelected = true; } else { // select normal points if (((*i).x() >= x) && ((*i).x() <= (x + w)) && ((*i).y() >= y) && ((*i).y() <= (y + h))) { (*i).select(selectStatus); } else { allSelected = false; } } } // select lines for (l = linelist.begin() ; l != linelist.end() ; ++l) { (*l).getExtremities(x1,y1,x2,y2); if ((x1 >= x) && (x1 <= (x + w)) && (x2 >= x) && (x2 <= (x + w)) && (y1 >= y) && (y1 <= (y + h)) && (y2 >= y) && (y2 <= (y + h))) { // both extremities are in the selection (*l).select(selectStatus); } } return; } void pointfile::selectPoints(int x, int y, int w, int h, ptselectflag what) { pointIterator i; lineIterator l; int x1, y1, x2, y2; dbgprintf("Selecting points in rectangle (x=%d,y=%d,w=%d,h=%d)\n", x, y, w, h); switch (what) { // add points to current selection case PT_SELECT_ADD: changeSelection(x,y,w,h,true); break; // remove points from selection case PT_SELECT_RM: changeSelection(x,y,w,h,false); break; // invert current selection case PT_SELECT_INVERT: for (i = pointlist.begin() ; i != pointlist.end() ; ++i) { if (((*i).x() >= x) && ((*i).x() <= (x + w)) && ((*i).y() >= y) && ((*i).y() <= (y + h))) { (*i).select(!(*i).selected()); } } for (l = linelist.begin() ; l != linelist.end() ; ++l) { (*l).getExtremities(x1,y1,x2,y2); if ((x1 >= x) && (x1 <= (x + w)) && (x2 >= x) && (x2 <= (x + w)) && (y1 >= y) && (y1 <= (y + h)) && (y2 >= y) && (y2 <= (y + h))) { // both extremities are in the selection (*l).select(!(*l).selected()); } } break; case PT_SELECT_ALL: for (i = pointlist.begin() ; i != pointlist.end() ; ++i) { (*i).select(); } for (l = linelist.begin() ; l != linelist.end() ; ++l) { (*l).select(); } break; case PT_SELECT_NONE: for (i = pointlist.begin() ; i != pointlist.end() ; ++i) { (*i).select(false); } for (l = linelist.begin() ; l != linelist.end() ; ++l) { (*l).select(false); } break; } return; } void pointfile::rotate90p(void) { pointIterator i; for (i = pointlist.begin() ; i != pointlist.end() ; ++i) { if (!(*i).isBreak()) (*i).rotate90p(); } redrawLines(); } void pointfile::rotate90m(void) { pointIterator i; for (i = pointlist.begin() ; i != pointlist.end() ; ++i) { if (!(*i).isBreak()) (*i).rotate90m(); } redrawLines(); } void pointfile::rotate3dup(void) { pointIterator i; for (i = pointlist.begin() ; i != pointlist.end() ; ++i) { if (!(*i).isBreak()) (*i).rotate3dup(); } redrawLines(); } void pointfile::rotate3ddown(void) { pointIterator i; for (i = pointlist.begin() ; i != pointlist.end() ; ++i) { if (!(*i).isBreak()) (*i).rotate3ddown(); } redrawLines(); } void pointfile::fliph(void) { pointIterator i; for (i = pointlist.begin() ; i != pointlist.end() ; ++i) { if (!(*i).isBreak()) (*i).fliph(); } redrawLines(); } void pointfile::flipv(void) { pointIterator i; for (i = pointlist.begin() ; i != pointlist.end() ; ++i) { if (!(*i).isBreak()) (*i).flipv(); } redrawLines(); } void pointfile::showlist(void) { pointIterator i; int j; dbgprintf("Printing content of pointfile\n"); for (i = pointlist.begin(), j = 0 ; i != pointlist.end() ; ++i, ++j) { if (i->isBreak()) dbgprintf("%4d: Break (style=%d, col=%d), selected=%s\n", j, (int)(i->getLSty()), (int)(i->getLCol()), (*i).selected() ? "yes":"no"); else dbgprintf("%4d: (x=%4d, y=%4d, z=%4d) = %4d,%4d,%4d, selected=%s \n", j, (*i).x(), (*i).y(), (*i).z(), (*i).Rval(),(*i).Gval(),(*i).Bval(), (*i).selected() ? "yes":"no"); } return; } // output to string int pointfile::savelist(string &s) { int retval = 0; if (!pointlist.empty()) { ostringstream ssout; dbgprintf("Saving the point list to a string\n"); if (ssout) { retval = outputlist(ssout); // convert stream content to string s = ssout.str(); } else { errprintf("Could not open string stream\n"); retval = 1; } } else { s = "Empty\n"; // for now... } return retval; } // save to file int pointfile::savelist(bool forsure) { int retval = 0; if (!pointlist.empty()) { string trueFileName; if (!forsure) // backup trueFileName = PtFileName + ".bak"; else trueFileName = PtFileName; ofstream PtFile(trueFileName.c_str()); ///,ios_base::out); // declare and open the file dbgprintf("Saving the point list to %s\n", trueFileName.c_str()); if (PtFile) { retval = outputlist(PtFile); if ((retval == 0) && forsure) { // saving was successful, no need to back up until next // actual change hasChanged = false; } } else { errprintf("Could not open file %s\nfor saving point file: %s\n", trueFileName.c_str(), strerror(errno)); retval = 1; } } else { dbgprintf("Point list is empty\n"); if (forsure) { ofstream PtFile(PtFileName.c_str()); if (PtFile) { PtFile << endl; // empty the file // retval stay at 0, not an error here. } else { errprintf("Could not clearfile %s: %s\n", PtFileName.c_str(), strerror(errno)); retval = 1; } } } // stream gets closed automatically here, if opened. return retval; } // output the list to arbitrary stream int pointfile::outputlist(ostream &sout) { if (saveAsOldFormat) { // old format is row, column, grey-level for (pointIterator i = pointlist.begin() ; i != pointlist.end() ; ++i) { if ((*i).x() >= 0) { // a normal point sout << (*i).y() + IOBlackBox->getYOffset() << " " << (*i).x() + IOBlackBox->getXOffset() << " " << (*i).Rval() << "\n"; } else { // a break point sout << "break" << "\n"; } } } else { // new format, hardly a revolution sout << "# pointfile for " << imgName << "\n"; sout << "# annotation parms: col fnt fntsze lnlen qdt [h]/[v] pt_radius text_of_annotation\n" ; sout << "# Y X R Z G B x y z n LBL ...\n" ; for (pointIterator i = pointlist.begin() ; i != pointlist.end() ; ++i) { if ((*i).x() >= 0) { if (!simplePointfile && ((*i).annotation().length() > 0)) { // output the comment first sout << ANNOTEHDR << (int)((*i).stringColour()) << ' ' << (*i).stringFont() << ' ' << (*i).stringSize() << ' ' << (*i).linelength() << ' ' << (int)((*i).stringQuadrant()) << ' ' << (char)(((*i).isHidden()) ? 'h':'v') << ' ' << (*i).radius() << ' ' << (*i).annotation_inlined() << '\n'; } #ifdef INSURE_PICKY // Phreaking Insure from hell doesn't understand setw # define setw(x) ' ' #endif sout << std::setw(4) << (*i).y() + IOBlackBox->getYOffset() << ' ' << std::setw(4) << (*i).x() + IOBlackBox->getXOffset() << ' ' << std::setw(3) << (*i).Rval() << ' ' ; // the first 3 items are the same as the old format. sout << std::setw(4) << (*i).z() + IOBlackBox->getZOffset() << ' ' << std::setw(3) << (*i).Gval() << ' ' << std::setw(3) << (*i).Bval() << ' ' ; #ifdef INSURE_PICKY #undef setw #endif sout << IOBlackBox->getRawDataInfo((*i).x(), (*i).y(), (*i).z()) << endl; } else { // a break point if (simplePointfile) sout << "break " << endl; else sout << "break " << i->getLSty() << " " << i->getLCol() << endl; } } } return 0; } int pointfile::nbPointsInList(void) { int nbp = 0; // returns the real number of points for (pointIterator i = pointlist.begin() ; i != pointlist.end() ; ++i) if (!(*i).isBreak()) nbp++; return nbp; } int pointfile::nbBreaksInList(void) { int nbb = 0; // returns the real number of breaks for (pointIterator i = pointlist.begin() ; i != pointlist.end() ; ++i) if ((*i).isBreak()) nbb++; return nbb; } // reads and displays points belonging to a list. void pointfile::readlist(void) { dbgprintf("Reading point list from %s\n", PtFileName.c_str()); ifstream PtFile(PtFileName.c_str()); if (PtFile) { string currentLine; int oldstyle; getline(PtFile,currentLine); if (!currentLine.empty()) { if (currentLine[0] == '#') { dbgprintf("Parsing new-style pointfile\n"); oldstyle = 0; // get rid of second line as well getline(PtFile, currentLine); // Things begin to be interesting at the third line getline(PtFile, currentLine); } else { dbgprintf("Parsing old-style pointfile\n"); oldstyle = 1; } while (!currentLine.empty()) { // because g++ 2.7.x doesn't have a recent version of the STL, // we shamefully revert to the C library here! const char *pchline = currentLine.c_str(); int ptx, pty, ptz; dbgprintf("Parsing: %s\n", pchline); if (oldstyle) { int val, nbread; nbread = sscanf(pchline, "%i %i %i", &pty, &ptx, &val); if (nbread == 3) { // remove the current offset, hoping it makes sense! ptx -= IOBlackBox->getXOffset(); pty -= IOBlackBox->getYOffset(); ptz = 0; if ((ptx >= 0) && (ptx < IOBlackBox->imageWidth()) && (pty >=0) && (pty < IOBlackBox->imageHeight())) { // deem that a point... addPoint(ptx, pty, ptz, val, val, val, 0); } else { dbgprintf("Invalid point %d %d %d\n", ptx, pty, val); } } else { char breakstring[100]; int lstyle, lcolour; nbread = sscanf(pchline, "%s %d %d\n", breakstring, &lstyle, &lcolour); if (strncmp(breakstring, "break", 5) == 0) { // insert a break if (nbread == 3) { addBreak(false, (linestyle)lstyle, (Fl_Color)lcolour); } else addBreak(false); // will NOT redraw the lines } else { dbgprintf("Invalid line %s\n", breakstring); } } } else { int Rval, Gval, Bval; int nbread; static char text[DFLTSTRLEN]; static int colour, font, size = 0, length, quad, nb, ptsize; static string txtstr; static char c; // check if annotation if (pchline[0] == '#') { nbread = sscanf(pchline, ANNOTEHDR "%d %d %d %d %d %c %d %n", &colour, &font, &size, &length, &quad, &c, &ptsize, &nb); if (nbread >= 7) { // last %n may or may not increment nbread // parse annotation strncpy(text, pchline+nb, DFLTSTRLEN); dbgprintf("Annotation found: %s", text); txtstr = text; } else { size = 0; getline(PtFile, currentLine); continue; // just a comment, skip to next line } } nbread = sscanf(pchline, "%*i %*i %i %*i %i %i %i %i %i", &Rval, &Gval, &Bval, &ptx, &pty, &ptz); if (nbread >= 5) { if ((ptx >= 0) && (ptx < IOBlackBox->imageWidth()) && (pty >= 0) && (pty < IOBlackBox->imageHeight()) && (ptz >= 0) && (ptz < IOBlackBox->imageThickness())) { // deem that a point if (size == 0) addPoint(ptx, pty, ptz, Rval, Gval, Bval, 1); else // annotated point addPoint(ptx, pty, ptz, Rval, Gval, Bval, 1, true, txtstr, (Fl_Color) colour, font, size, length, (str_quadrant)quad, (c == 'h'), ptsize); size = 0; // reset annotation } else { dbgprintf("Invalid point (%d %d %d) = %d, %d, %d\n", ptx, pty, ptz, Rval, Gval, Bval); } } else { char breakstring[100]; int lstyle, lcolour; nbread = sscanf(pchline, "%s %d %d\n", breakstring, &lstyle, &lcolour); if (strncmp(breakstring, "break", 5) == 0) { // insert a break if (nbread == 3) { addBreak(false, (linestyle)lstyle, (Fl_Color)lcolour); } else addBreak(false); // will NOT redraw the lines size = 0; // reset annotation } else { dbgprintf("Invalid line %s\n", breakstring); } } } getline(PtFile, currentLine); } } redrawLines(); } } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/pointfile.hxx�������������������������������������������������������������������������0000644�0000765�0000765�00000024007�10066324231�016515� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: pointfile.hxx,v 4.4 2004/06/23 15:58:17 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * the pointfile class * * This class is responsible for handling pointfiles, and is * a cheap excuse to learn more about C++ streams, strings, and * the STL in general. * * Hugues Talbot 4 Mar 1998 * *-----------------------------------------------------------------------*/ #ifndef POINTFILE_H #define POINTFILE_H #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <math.h> #include <fstream> #include <sstream> // string stream #include <iomanip> #include <string> #include <list> #include <FL/Fl_Object.H> #include <FL/Fl_Group.H> #include <FL/fl_draw.H> #include "imnmspc.hxx" // namespace def. if required #include "imlines.hxx" using std::ostream; using std::ofstream; using std::ifstream; using std::endl; using std::setw; using std::list; using std::string; using std::ostringstream; #define PTFILE_CUTOFFD 5 // distance cut-off in pixels #define STR_LINE_LN 7 // line between point and text, if any #define WEIRD_CONSTANT -1234321 // to indicate a `break' extern string ptDummyStr; // serves no purpose other than enabling default string argument typedef enum { PT_SELECT_ADD = 0, PT_SELECT_RM, PT_SELECT_INVERT, PT_SELECT_ALL, PT_SELECT_NONE, } ptselectflag; // helper class // weird collection of parameters struct pointParams { pointParams(void) { annotated = false; txt=ptDummyStr; col = FL_BLACK; font = 0; size = 0; length = 0; qdr = STR_NE; h = false; pts = 3; lsty = STYLE_FILLED_BW; lcol = FL_WHITE; } bool annotated; string txt; // text that goes with the point Fl_Color col; // color of the point and text int font; // font of the text int size; // size of the font int length; // length of the line str_quadrant qdr; // direction of line from point bool h; // hidden or not int pts; // point size. linestyle lsty; // style of the linework -- only for breaks Fl_Color lcol; // colour of the linework -- only for breaks }; // this class will grow in time... class mypoint: public Fl_Object { public: mypoint(void); mypoint(const mypoint& p); mypoint(int X, int Y, int Z, unsigned char Rval, unsigned char Gval, unsigned char Bval, int nbraw, bool annotated=false, string &txt = ptDummyStr , Fl_Color col = FL_BLACK, int font = 0, int size = 0, int length = 0, str_quadrant qdr = STR_NE, bool h = false, int pts = 3, linestyle lsty = STYLE_FILLED_BW, Fl_Color lcol = FL_WHITE) ; mypoint& operator=(mypoint &p); ~mypoint(); int x() const { return x_;} int y() const { return y_;} int z() const { return z_;} int Rval() const { return Rval_;} int Gval() const { return Gval_;} int Bval() const { return Bval_;} int nbraw() const {return nbraw_;} int radius() const {return radius_;} void radius(int v) {radius_ = v;} const string& annotation() const {return annotation_;} const string& annotation_inlined(void); void annotation(string &in) {annotation_ = in;} void annotation_inlined(string &in); Fl_Color stringColour() const {return stringColour_;} void stringColour(Fl_Color c) {stringColour_ = c;} int stringFont() const {return stringFont_;} void stringFont(int f) {stringFont_ = f;} int stringSize() const {return stringSize_;} void stringSize(int s) {stringSize_ = s;} str_quadrant stringQuadrant() const {return stringQuadrant_;} void stringQuadrant(str_quadrant q) {stringQuadrant_ = q;} void linelength(int l) {linelength_ = l;} int linelength(void) const {return linelength_;} void pointdefaults(const pointParams &pp); void draw(); void select(bool value = true) {selected_=value;} bool selected(void) const {return selected_;} bool isBreak(void) const {return (z_ == WEIRD_CONSTANT);} bool hasAnnotation(void) const {return hasAnnotation_;} bool isHidden(void) const {return hidden_;} void hide(bool v) {hidden_ = v;} linestyle getLSty(void) const {return lsty_;} Fl_Color getLCol(void) const {return lcol_;} // point rotation void rotate90p(void); void rotate90m(void); void rotate3dup(void); void rotate3ddown(void); void flipv(void); void fliph(void); // selection predicate bool isSelectedPred(void); void removeself(Fl_Group* v) {if (!isBreak()) v->remove(*this);} // remove self from list of things to draw void addself(Fl_Group* v) {if (!isBreak()) v->add(*this);} // add self to list of things to draw private: int x_, y_, z_; unsigned char Rval_, Gval_, Bval_; int nbraw_; int radius_; string annotation_, annotation_inlined_; Fl_Color stringColour_, lcol_; int stringFont_, stringSize_, linelength_; str_quadrant stringQuadrant_; bool selected_, hidden_, hasAnnotation_; linestyle lsty_; pointParams defaultParms_; }; // quick, define a list iterator! typedef list<mypoint>::iterator pointIterator; typedef list<mypoint>::reverse_iterator pointRIterator; typedef list<imline>::iterator lineIterator; typedef list<imline>::reverse_iterator lineRIterator; class pointfile { private: int outputlist(ostream &sout); // output the pf to an arbitrary stream pointIterator findClosestPoint(int x, int y); bool isValid(pointIterator i) {return(i != pointlist.end());} void changeSelection(int x, int y, int w, int h, bool selectStatus); public: pointfile(); ~pointfile(); int addPoint(int x, int y, int z, unsigned char Rval, unsigned char Gval, unsigned char Bval, int hasRaw, bool hasAnnotation = false, string &annotation = ptDummyStr, Fl_Color color=FL_RED, int font=0, int size=0, int length=0, str_quadrant qdr=STR_NE, bool hidden = false, int ptsize = 3, linestyle lstyle = STYLE_FILLED_BW, Fl_Color lcolour= FL_WHITE); // same as above, slightly more convenient. int addPoint(int x, int y, int z, unsigned char Rval, unsigned char Gval, unsigned char Bval, int hasRaw, pointParams &pp); void addBreak(bool redraw = true, linestyle lsty=STYLE_FILLED_BW, Fl_Color lcol=FL_WHITE); void redrawLines(void); void resetLinesStatus(void); void imageName(const char *p) {imgName = p;} void rmPoint(int x, int y); void annotatePoint(int x, int y); int getNearestPointParameters(int X, int Y, string &ann, Fl_Color &col, int &font, int &size, int &length, str_quadrant &q, bool &hidden, int &pointsize); bool isValidPoint(int x, int y) {return isValid(findClosestPoint(x,y));} void rmLastPoint(void); void rmAllPoints(void); bool rmSelectedPoints(void); void rmPointGroup(int x, int y); void selectPoints(int x, int y, int w, int h, ptselectflag flag=PT_SELECT_ADD); void showlist(void); int savelist(bool forsure=true); // to the pointfile int savelist(string &s); // to an arbitrary string void readlist(void); void getlist(string &s); int nbPointsInList(void); int nbBreaksInList(void); void xorValueForLines(int x) {xorvalforlines = x;} int xorValueForLines(void) {return xorvalforlines;} void setCurrentLineStyle(linestyle l) {currentlinestyle_ = l;} void setCurrentLineColour(Fl_Color c) {currentlinecolour_ = c;} // provide access to the point file name. int setPtFileName(const char *nm); const char *getPtFileName(void); const char *getPtFileNameIfPresent(const char *imageName); // points transformation void rotate90p(void); void rotate90m(void); void rotate3dup(void); void rotate3ddown(void); void flipv(void); void fliph(void); private: int saveAsOldFormat; int xorvalforlines; bool hasChanged; string PtFileName; string imgName; list <mypoint> pointlist; list <imline> linelist; linestyle currentlinestyle_; Fl_Color currentlinecolour_; }; #endif // POINTFILE �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/printPrefs.cxx������������������������������������������������������������������������0000644�0000765�0000765�00000040070�10054504410�016645� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: printPrefs.cxx,v 4.5 2004/05/24 23:45:12 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A print preference panel using fluid. * * Hugues Talbot 21 Apr 1998 * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" #include <string.h> #include <stdio.h> #include <stdlib.h> #include "imunistd.h" #include <errno.h> #include <string> // needed by nocase.H #include <FL/Fl_File_Chooser.H> #include <FL/fl_ask.H> #include "imview.hxx" #include "nocase.hxx" #include "io/imSystem.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "menubar.hxx" #include "printPrefs.hxx" #include "io/newprefio.hxx" #include "io/cpostscript.hxx" #include "machine.hxx" extern char appName[]; extern imageIO *IOBlackBox; extern imageViewer *mainViewer; extern imViewMenuBar *mainMenuBar; extern imprefs *fileprefs; extern printprefs *printPrefsPanel; // the `broken pipe' signal handler static void brokenPipeHandler(int sig); // the siglongjmp buffer static im_jmp_buf bpenv; // print panel methods printprefs::printprefs() { dbgprintf("Print panel constructed\n"); prefWindow = 0; // fluid depend on that... return; } void printprefs::setDefaults() { static char buff[100]; char *myenv; // we print to a real printer by default printerCheck->set(); // default printing output if ((myenv = getenv("PRINTER")) != 0) sprintf(buff, "lpr -P%s", myenv); else strcpy(buff, "lpr"); commandInput->value((const char *)buff); // default value for file sprintf(buff, "%s.ps", appName); filenameInput->value(buff); // empty title is fine... // orientation should be portrait portraitCheck->set(); // Paper size should be A4 // A4Check->set(); papertype_ = PAGESIZE_A4; papersizeChoice->value(papertype_); // language should be PS psCheck->set(); // by default we only print the image that is showing now oneImageCheck->set(); // number of copies should be just one nbcopiesInput->value("1"); // By default we print the whole image wholeCheck->set(); // that's it return; } // this method switches between the `File' and the `Printer' defaults void printprefs::toggleToFile() { // disable the Print command commandInput->deactivate(); commandInput->color(47); // got that from fluid... commandInput->textcolor(31); commandInput->labelcolor(31); // enable the "file" command filenameInput->activate(); filenameInput->color(43); filenameInput->textcolor(FL_BLACK); filenameInput->labelcolor(FL_BLACK); // enable the browse button browseButton->activate(); browseButton->labelcolor(FL_BLACK); prefWindow->redraw(); return; } void printprefs::toggleToPrinter() { // disable the Print command filenameInput->deactivate(); filenameInput->color(47); // got that from fluid... filenameInput->textcolor(31); filenameInput->labelcolor(31); // enable the "file" command commandInput->activate(); commandInput->color(43); commandInput->textcolor(FL_BLACK); commandInput->labelcolor(FL_BLACK); // disable the browse button browseButton->deactivate(); browseButton->labelcolor(31); prefWindow->redraw(); return; } void printprefs::allowTitle(bool b) { if (b) { // setting the title is allowed titleInput->activate(); titleInput->color(43); // fluid... titleInput->textcolor(FL_BLACK); titleInput->labelcolor(FL_BLACK); } else { titleInput->deactivate(); titleInput->color(47); titleInput->textcolor(31); titleInput->textcolor(31); } prefWindow->redraw(); return; } void printprefs::setTitle(const char *t) { titleInput->value(t); return; } void printprefs::printFileName(const char *fn) { // this copies it to something more permanent. filenameInput->value(fn); return; } void printprefs::setMargins(long whichItem) { switch ((margin_size)whichItem) { case MARGIN_SIZE_STANDARD: case MARGIN_SIZE_SMALL: case MARGIN_SIZE_LARGE: case MARGIN_SIZE_ZERO: postscript_set_margin_index((margin_size)whichItem); // then set valus for margin inputs break; case MARGIN_SIZE_CUSTOM: postscript_set_margin_index((margin_size)whichItem); // need to set custom margins too // then GET value from margin inputs break; default: warnprintf("Incorrect size option %ld\n", whichItem); break; } return; } static void brokenPipeHandler(int sig) { // reset the signal handler signal(sig, brokenPipeHandler); im_longjmp(bpenv, 1); } // the following is a tiny bit hackish. // the vp=&... are seemingly useless statements that // prevent the compiler from optimizing the automatic variable // into registers, thus putting the longjmp in jeopardy. // in fact there is no problem, but that's the easiest way // I found for stopping gcc warning me about the possibility. int printprefs::doThePrinting(bool preview) { HIMAGE *tbp; // don't you love C? volatile void *vp; int retval = 0; vp = &retval; byte win_type; vp = &win_type; byte orientation; vp = &orientation; bool usePipe = false; vp = &usePipe; int nbcopies, nbitems, i; vp = &nbcopies; vp = &nbitems; vp = &i; char *title, *filename, *pipeCommand; vp = &title; vp = &filename; vp = &pipeCommand; char *fileList, *tmpPreview; vp = &fileList; vp = &tmpPreview; uchar *buf0, *buf1, *buf2; vp = &buf0;vp = &buf1; vp = &buf2; FILE *outfile; vp = &outfile; // how many images are we going to save? if (wholeListCheck->value() == 1) { fileList = mainMenuBar->getItemListContent(IMAGE_LIST_ID, nbitems); } else { fileList = 0; nbitems = 1; } tbp = new HIMAGE[nbitems]; dbgprintf("about to print %d items\n", nbitems); for (i = 0 ; i < nbitems ; i++) { // fill up what we can from the outset if (IOBlackBox->getCurrImgPixType() == IM_BINARY) tbp[i].type = PS_BINARY; else tbp[i].type = PS_CHAR; // we don't care, but not binary buf0 = buf1 = buf2 = 0; // first question: are we printing the whole image or only a subset? if (wholeCheck->value() == 1) { // the whole thing tbp[i].nbrows = IOBlackBox->imageHeight(); tbp[i].nbcols = IOBlackBox->imageWidth(); if ((tbp[i].nbcomp = IOBlackBox->wholeImage(&buf0, &buf1, &buf2)) != 0) { tbp[i].buf0 = buf0; tbp[i].buf1 = buf1; tbp[i].buf2 = buf2; } else { errprintf("Can't print images with %d samples per pixel\n", IOBlackBox->imageDepth()); return(10); } } else { // the subset currently displayed int bx, by, bw, bh; // dimensions of the subset... if ((tbp[i].nbcomp = IOBlackBox->subsetImage(&buf0, &buf1, &buf2, bx, by, bw, bh)) != 0) { tbp[i].nbrows = bh; tbp[i].nbcols = bw; tbp[i].buf0 = buf0; tbp[i].buf1 = buf1; tbp[i].buf2 = buf2; } else { errprintf("Can't print images with %d samples per pixel\n", IOBlackBox->imageDepth()); return(11); } } // display the next image if (nbitems > 1) { dbgprintf("Showing the next image\n"); nextimage_cb(0,0); } } // get all the options now // paper type selection with Choice menu now. // if (A3Check->value()) papertype = A3_FMT; // else if (letterCheck->value()) papertype = LE_FMT; // else papertype = A4_FMT; if (epsCheck->value()) win_type = WIN_EPS; else win_type = WIN_ALL; if (landscapeCheck->value()) orientation = ORI_LDS; else orientation = ORI_PRT; nbcopies = MYMAX(atoi(nbcopiesInput->value()), 1); title = (char *)(titleInput->value()); if ((title != 0) && (title[0] == '\0')) title = 0; // empty string // open the pipe! if (printerCheck->value() && !preview) { // we pipe to a command, which hopefully will print // (not our problem if it doesn't... pipeCommand = (char *)commandInput->value(); if ((pipeCommand != 0) && (pipeCommand[0] == '\0') || (pipeCommand == 0)) { errprintf("Please specify a print command\n"); retval = 1; } else { // 2:set the `broken pipe' signal handler outfile = 0; im_signal(SIGPIPE, brokenPipeHandler); if (im_setjmp(bpenv, 1) == 0) { // save the mask buffer // 3: try to open the pipe for writing if ((outfile = popen(pipeCommand, "w")) == 0) { errprintf("Cannot open pipe to command %s\n%s", pipeCommand, strerror(errno)); retval = 2; } } else { // we got there only through the signal handler if (outfile != 0) fclose(outfile); if (pipeCommand != 0) errprintf("Broken pipe: invalid command %s\n", pipeCommand); retval = 3; } usePipe = true; // we'll have to use pclose later on } } else if ((printerCheck->value() == 0) && !preview) { // we send to a file filename = (char *)filenameInput->value(); if ((filename != 0) && (filename[0] == '\0') || (filename == 0)) { errprintf("Please specify a file to print to\n"); retval = 4; } else { if (access(filename, W_OK) == 0) { // the file aready exist, do we really want to do this? static char alrtmsg[1024]; sprintf(alrtmsg, "File %s already exists\n" "Do you want to overwrite?\n", filename); if (fl_ask(alrtmsg) == 0) { retval = 6; goto error; } } if ((outfile = im_fopen(filename, "wb")) == 0) { errprintf("Can't open file %s\n%s", filename, strerror(errno)); retval = 5; } } } else { // preview // 1: get the preview command tmpPreview = tempnam(0, "ImViu"); if ((outfile = im_fopen(tmpPreview, "wb")) == 0) { errprintf("Can't open temporary file %s\n%s", tmpPreview, strerror(errno)); free(tmpPreview); retval = 5; } } if (retval == 0) { // all is fine, we can send the postscript code away. dbgprintf("Composing PS code\n"); compose_PostScript_code(tbp,nbitems,1.0, papertype_, win_type, orientation, nbcopies, 0,0, title, "Times-Roman",0, 1, outfile); if (preview) { int gslen = strlen(fileprefs->gvpath()) + 2*strlen(tmpPreview); char *previewCommand = new char[gslen+20]; sprintf(previewCommand, "(%s %s ; rm -f %s) &", fileprefs->gvpath(), tmpPreview, tmpPreview); fflush(outfile); // send Everything, but do not close. system(previewCommand); delete[] previewCommand; free(tmpPreview); // we can get rid of this now. } if (usePipe) { // if we are previewing, pclose will have to occur later pclose(outfile); outfile = 0; } else { // even if we are previewing fclose(outfile); outfile = 0; } } error: // probably deleting 0 would be acceptable, but hey. for (i = 0 ; i < nbitems ; i++) { if (tbp[i].buf0 != 0) delete[] tbp[i].buf0; if (tbp[i].buf1 != 0) delete[] tbp[i].buf1; if (tbp[i].buf2 != 0) delete[] tbp[i].buf2; } if (fileList != 0) delete[] fileList; delete[] tbp; return retval; } void printprefs::show() { prefWindow->show(); return; } void printprefs::hide() { prefWindow->hide(); return; } // print panel associated callbacks void printercheck_cb(Fl_Check_Button *, printprefs *panel) { dbgprintf("Printer check callback\n"); panel->toggleToPrinter(); return; } void filecheck_cb(Fl_Check_Button *, printprefs *panel) { dbgprintf("File check callback\n"); panel->toggleToFile(); return; } void commandInput_cb(Fl_Input *, printprefs *) { dbgprintf("Command input callback\n"); return; } void filenameInput_cb(Fl_Input *, printprefs *) { dbgprintf("filename input callback\n"); return; } void browsebutton_cb(Fl_Button *, printprefs *panel) { const char *currentfile; static const char *p = 0; dbgprintf("Browse Button pressed on print prefs panel\n"); currentfile = panel->filenameInputValue(); p = fl_file_chooser("Print to file", "*[pP][sS]", currentfile); if (p) panel->printFileName(p); return; } void titleInput_cb(Fl_Input *, printprefs *) { dbgprintf("title input callback\n"); return; } void portraitcheck_cb(Fl_Check_Button *, printprefs *) { dbgprintf("Portrait check callback\n"); return; } void landscapecheck_cb(Fl_Check_Button *, printprefs *) { dbgprintf("Landscape check callback\n"); return; } void papersize_cb(Fl_Choice *c, printprefs *s) { dbgprintf("Paper choice = %d\n", c->value()); s->setpapertype(c->value()); } void a4check_cb(Fl_Check_Button *, printprefs *) { dbgprintf("A4 check callback\n"); return; } void lettercheck_cb(Fl_Check_Button *, printprefs *) { dbgprintf("Letter check callback\n"); return; } void a3check_cb(Fl_Check_Button *, printprefs *) { dbgprintf("A3 check callback\n"); return; } void pscheck_cb(Fl_Check_Button *, printprefs *panel) { dbgprintf("PS check callback\n"); panel->allowTitle(true); return; } void epscheck_cb(Fl_Check_Button *, printprefs *panel) { dbgprintf("EPS check callback\n"); panel->allowTitle(false); return; } void nbcopies_cb(Fl_Input *, printprefs *) { dbgprintf("Nb of copies callback\n"); return; } void oneimagecheck_cb(Fl_Check_Button *, printprefs *) { dbgprintf("One image check callback\n"); return; } void wholelistcheck_cb(Fl_Check_Button *, printprefs *) { dbgprintf("Whole list check callback\n"); return; } void wholecheck_cb(Fl_Check_Button *, printprefs *) { dbgprintf("Whole check callback\n"); return; } void subsetcheck_cb(Fl_Check_Button *, printprefs *) { dbgprintf("Subset check callback\n"); return; } // 2- Margin tab callbacks void marginchoice_cb(Fl_Choice *, printprefs *panel) { dbgprintf("Margin dimensions callback\n"); return; } void chosenmargin_cb(Fl_Menu_ *, void *value) { long v = (long)value; dbgprintf("Margin chosen = %d\n", v); printPrefsPanel->setMargins(v); return; } void cancelbutton_cb(Fl_Button *, printprefs *panel) { dbgprintf("Cancel Button pressed on print prefs panel\n"); // hide the window panel->hide(); return; } void previewbutton_cb(Fl_Button *bt, printprefs *panel) { dbgprintf("Preview button pressed\n"); panel->doThePrinting(true); // this is the preview switch return; } // This is really the `print' button... void okbutton_cb(Fl_Return_Button *, printprefs *panel) { dbgprintf("Print Button pressed on print prefs panel\n"); if (panel->doThePrinting() == 0) { // hide the window panel->hide(); } // else leave the panel around for the user to correct things return; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/printPrefs.hxx������������������������������������������������������������������������0000644�0000765�0000765�00000010700�07727302474�016672� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: printPrefs.hxx,v 4.4 2003/09/09 07:46:04 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A printPreferenceWindow class * * Experimenting OOP with fluid * * *-----------------------------------------------------------------------*/ #ifndef PRINTPREFS_H #define PRINTPREFS_H #include <stdio.h> #include <FL/Fl.H> #include <FL/Fl_Box.H> #include <FL/Fl_Button.H> #include <FL/Fl_Check_Button.H> #include <FL/Fl_Group.H> #include <FL/Fl_Input.H> #include <FL/Fl_Return_Button.H> #include <FL/Fl_Window.H> #include <FL/Fl_Double_Window.H> #include <FL/Fl_Choice.H> class printprefs { public: printprefs(); void setDefaults(); void toggleToFile(); void toggleToPrinter(); void allowTitle(bool b); void setTitle(const char *title); void printFileName(const char *fn); const char *filenameInputValue(void) { return filenameInput->value(); } void setpapertype(int p) {papertype_ = p;} void setMargins(long whichMargin); void show(); void hide(); int doThePrinting(bool preview=false); friend Fl_Double_Window *printprefs_panel(printprefs &s); private: // in the order they appear in fluid // -- The dialog window Fl_Double_Window *prefWindow; // the main window // Print type group Fl_Group *printtypeGroup; Fl_Check_Button *printerCheck, *fileCheck; // Input group Fl_Group *inputGroup; Fl_Input *commandInput; Fl_Input *filenameInput; Fl_Button *browseButton; Fl_Input *titleInput; // 1- Main parameter tab // Orientation Group Fl_Group *orientationGroup; Fl_Check_Button *portraitCheck, *landscapeCheck; // Paper size group Fl_Group *papersizeGroup; // Replaced by an Fl_Choice // Fl_Check_Button *A4Check, *letterCheck, *A3Check; Fl_Choice *papersizeChoice; // Language Group Fl_Group *languageGroup; Fl_Check_Button *psCheck, *epsCheck; Fl_Input *nbcopiesInput; // fit to page group Fl_Group *fitGroup; Fl_Check_Button *oneImageCheck, *wholeListCheck; // Subset group Fl_Group *subsetGroup; Fl_Check_Button *wholeCheck, *subsetCheck; // 2- Margin tab // Fl_Choice *marginDims; Fl_Menu_Item *standardMarginItem, *smallMarginItem; Fl_Menu_Item *largeMarginItem, *zeroMarginItem; Fl_Menu_Item *customMarginItem; Fl_Input *leftMarginInput, *rightMarginInput; Fl_Input *topMarginInput, *bottomMarginInput; Fl_Input *titleMarginInput; Fl_Return_Button *OKButton; Fl_Button *CancelButton; Fl_Button *PreviewButton; // other data int papertype_; }; #endif // PRINTPREFS_H ����������������������������������������������������������������imview-1.1.9c/printSpect.cxx������������������������������������������������������������������������0000644�0000765�0000765�00000034552�10211352061�016652� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: printSpect.cxx,v 4.1 2005/03/02 14:56:49 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A print preference panel using fluid. * * Hugues Talbot 21 Apr 1998 * *-----------------------------------------------------------------------*/ #include <stdio.h> #include <stdlib.h> #include "imunistd.h" #include <string.h> #include <errno.h> #include <setjmp.h> #include <signal.h> #include <FL/Fl_File_Chooser.H> #include <FL/fl_ask.H> #include "imview.hxx" #include "io/imSystem.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "spectraBox.hxx" #include "profileBox.hxx" #include "io/gplot2.hxx" #include "printSpect.hxx" extern char appName[]; extern imageIO *IOBlackBox; extern profile *profilePanel; extern spectra *spectraPanel; // print panel methods printspect::printspect() { dbgprintf("Print panel constructed\n"); prefWindow = 0; // fluid depend on that... return; } void printspect::setDefaults() { static char buff[100]; char *myenv; // we print to a real printer by default printerCheck->set(); // default printing output if ((myenv = getenv("PRINTER")) != 0) sprintf(buff, "lpr -P%s", myenv); else strcpy(buff, "lpr"); commandInput->value((const char *)buff); // default value for file sprintf(buff, "%s.ps", appName); filenameInput->value(buff); // empty title is fine... // orientation should be landscape landscapeCheck->set(); // Paper size should be A4 A4Check->set(); // no smoothing by default linesCheck->set(); // number of copies should be just one nbcopiesInput->value("1"); // Panel is SPECTRA by default. whichPanel = SPECTRAPANEL; // that's it return; } // this method switches between the `File' and the `Printer' defaults void printspect::toggleToFile() { // disable the Print command commandInput->deactivate(); commandInput->color(47); // got that from fluid... commandInput->textcolor(31); commandInput->labelcolor(31); // enable the "file" command filenameInput->activate(); filenameInput->color(43); filenameInput->textcolor(FL_BLACK); filenameInput->labelcolor(FL_BLACK); // enable the browse button browseButton->activate(); browseButton->labelcolor(FL_BLACK); prefWindow->redraw(); return; } void printspect::toggleToPrinter() { // disable the Print command filenameInput->deactivate(); filenameInput->color(47); // got that from fluid... filenameInput->textcolor(31); filenameInput->labelcolor(31); // enable the "file" command commandInput->activate(); commandInput->color(43); commandInput->textcolor(FL_BLACK); commandInput->labelcolor(FL_BLACK); // disable the browse button browseButton->deactivate(); browseButton->labelcolor(31); prefWindow->redraw(); return; } void printspect::allowTitle(bool b) { if (b) { // setting the title is allowed titleInput->activate(); titleInput->color(43); // fluid... titleInput->textcolor(FL_BLACK); titleInput->labelcolor(FL_BLACK); } else { titleInput->deactivate(); titleInput->color(47); titleInput->textcolor(31); titleInput->textcolor(31); } prefWindow->redraw(); return; } void printspect::printFileName(const char *fn) { // this copies it to something more permanent. filenameInput->value(fn); return; } int printspect::doThePrinting() { int retval = 0; char papertype; char jointype; char orientation; int nbcopies; char *title, *filename = 0, *pipeCommand = 0; static char tmptitle[1024]; int nx = 0; double *dbuff = 0, *rbuff = 0, *gbuff = 0, *bbuff = 0; if (whichPanel == SPECTRAPANEL) { nx = spectraPanel->getNbVal(); dbuff = spectraPanel->getData(); } else if (whichPanel == PROFILEPANEL) { nx = profilePanel->getNbVal(); dbuff = rbuff = profilePanel->getDataR(); gbuff = profilePanel->getDataG(); bbuff = profilePanel->getDataB(); } if (dbuff != 0) { // get all the options now if (A3Check->value()) papertype = A3_PAGE; else if (letterCheck->value()) papertype = LETTER_PAGE; else papertype = A4_PAGE; if (landscapeCheck->value()) orientation = LANDSCAPE; else orientation = PORTRAIT; if (linesCheck->value()) jointype = LINES; else jointype = SPLINES; nbcopies = trivmax(atoi(nbcopiesInput->value()), 1); title = (char *)(titleInput->value()); if ((title != 0) && (title[0] == '\0')) title = 0; // empty string // open the pipe! if (printerCheck->value()) { // we pipe to a command, which hopefully will print // (not our problem if it doesn't... // get the pipe command pipeCommand = (char *)commandInput->value(); if ((pipeCommand != 0) && (pipeCommand[0] == '\0') || (pipeCommand == 0)) { errprintf("Please specify a print command\n"); retval = 1; } else { // prepare a `pipe file name' strcpy(tmptitle, "|"); strcat(tmptitle, pipeCommand); filename = tmptitle; } } else { // we send to a file filename = (char *)filenameInput->value(); if ((filename != 0) && (filename[0] == '\0') || (filename == 0)) { errprintf("Please specify a file to print to\n"); retval = 4; } else { if (access(filename, W_OK) == 0) { // the file aready exist, do we really want to do this? static char alrtmsg[1024]; sprintf(alrtmsg, "File %s already exists\n" "Do you want to overwrite?\n", filename); if (fl_ask(alrtmsg) == 0) { retval = 6; } } } } if (retval == 0) { // all is fine, we can send the postscript code away. dbgprintf("Composing gnuplot code\n"); thePlot = openPlot(title); if (thePlot != 0) { send2plot(thePlot, "set terminal postscript %s", (orientation == PORTRAIT)? "eps": ""); send2plot(thePlot, "set output \"%s\"", filename); if (whichPanel == SPECTRAPANEL) { send2plot(thePlot, "set xlabel 'Spectrum of %s at position x=%d, y=%d'", IOBlackBox->getImName(), spectraPanel->getXpos(), spectraPanel->getYpos()); plotDoubles(dbuff, nx, thePlot, (jointype == SPLINES)); } else if (whichPanel == PROFILEPANEL) { double *vecs[3]; char *lbl[3]; int len[3]; send2plot(thePlot, "set data style lines"); send2plot(thePlot, "set xlabel 'Profile of %s from position x=%d, y=%d" " to position x=%d, y=%d'", IOBlackBox->getImName(), profilePanel->getXstart(), profilePanel->getYstart(), profilePanel->getXend(), profilePanel->getYend()); vecs[0] = rbuff; vecs[1] = gbuff; vecs[2] = bbuff; lbl[0] = "Red"; lbl[1] = "Green"; lbl[2] = "Blue"; len[0] = len[1] = len[2] = nx; dataMPlot(thePlot, // this is to show that we know what we are talking about... (char * (*) (...))writeDoubleVector, 3, (void**)vecs, lbl, len, 0); // no splines } closePlot(thePlot); } } } return retval; } int printspect::doThePreview() { int retval = 0; char jointype; char *title; int nx = 0; double *dbuff = 0, *rbuff = 0, *gbuff = 0, *bbuff = 0; if (whichPanel == SPECTRAPANEL) { nx = spectraPanel->getNbVal(); dbuff = spectraPanel->getData(); } else if (whichPanel == PROFILEPANEL) { nx = profilePanel->getNbVal(); dbuff = rbuff = profilePanel->getDataR(); gbuff = profilePanel->getDataG(); bbuff = profilePanel->getDataB(); } if (dbuff != 0) { if (linesCheck->value()) jointype = LINES; else jointype = SPLINES; title = (char *)(titleInput->value()); if ((title != 0) && (title[0] == '\0')) title = 0; // empty string // all is fine, we can send the postscript code away. dbgprintf("Composing gnuplot code\n"); thePlot = openPlot(title); if (thePlot != 0) { if (whichPanel == SPECTRAPANEL) { char xlabel[1024]; sprintf(xlabel, "spectrum of %s at position x=%d, y=%d", IOBlackBox->getImName(), spectraPanel->getXpos(), spectraPanel->getYpos()); send2plot(thePlot, "set xlabel '%s'", xlabel); plotDoubles(dbuff, nx, thePlot, (jointype == SPLINES)); } else if (whichPanel == PROFILEPANEL) { double *vecs[3]; char *lbl[3]; int len[3]; send2plot(thePlot, "set data style lines"); send2plot(thePlot, "set xlabel 'Profile of %s from position x=%d, y=%d" " to position x=%d, y=%d'", IOBlackBox->getImName(), profilePanel->getXstart(), profilePanel->getYstart(), profilePanel->getXend(), profilePanel->getYend()); if ((gbuff != 0) && (bbuff != 0)) { vecs[0] = rbuff; vecs[1] = gbuff; vecs[2] = bbuff; lbl[0] = "Red"; lbl[1] = "Green"; lbl[2] = "Blue"; len[0] = len[1] = len[2] = nx; dataMPlot(thePlot, (char * (*) (...))writeDoubleVector, 3, (void **)vecs, lbl, len, 0); // n o splines } else { vecs[0] = rbuff; lbl[0] = "Grey level"; len[0] = nx; dataMPlot(thePlot, (char * (*) (...))writeDoubleVector, 1, (void **)vecs, lbl, len, 0); // n o splines } } } } return retval; } int printspect::closePreview() { if (thePlot != 0) closePlot(thePlot); return 0; } void printspect::show() { prefWindow->show(); return; } void printspect::hide() { prefWindow->hide(); return; } // print panel associated callbacks void printercheck_cb(Fl_Check_Button *, printspect *panel) { dbgprintf("Printer check callback\n"); panel->toggleToPrinter(); return; } void filecheck_cb(Fl_Check_Button *, printspect *panel) { dbgprintf("File check callback\n"); panel->toggleToFile(); return; } void commandInput_cb(Fl_Input *, printspect *) { dbgprintf("Command input callback\n"); return; } void filenameInput_cb(Fl_Input *, printspect *) { dbgprintf("filename input callback\n"); return; } void browsebutton_cb(Fl_Button *, printspect *panel) { const char *currentfile; static const char *p = 0; dbgprintf("Browse Button pressed on print prefs panel\n"); currentfile = panel->filenameInputValue(); p = fl_file_chooser("Print to file", "*[pP][sS]", currentfile); if (p) panel->printFileName(p); return; } void titleInput_cb(Fl_Input *, printspect *) { dbgprintf("title input callback\n"); return; } void portraitcheck_cb(Fl_Check_Button *, printspect *) { dbgprintf("Portrait check callback\n"); return; } void landscapecheck_cb(Fl_Check_Button *, printspect *) { dbgprintf("Landscape check callback\n"); return; } void a4check_cb(Fl_Check_Button *, printspect *) { dbgprintf("A4 check callback\n"); return; } void lettercheck_cb(Fl_Check_Button *, printspect *) { dbgprintf("Letter check callback\n"); return; } void a3check_cb(Fl_Check_Button *, printspect *) { dbgprintf("A3 check callback\n"); return; } void pscheck_cb(Fl_Check_Button *, printspect *panel) { dbgprintf("PS check callback\n"); panel->allowTitle(true); return; } void epscheck_cb(Fl_Check_Button *, printspect *panel) { dbgprintf("EPS check callback\n"); panel->allowTitle(false); return; } void nbcopies_cb(Fl_Input *, printspect *) { dbgprintf("Nb of copies callback\n"); return; } void linescheck_cb(Fl_Check_Button *, printspect *) { dbgprintf("Lines check callback\n"); return; } void splinescheck_cb(Fl_Check_Button *, printspect *) { dbgprintf("Splines check callback\n"); return; } void cancelbutton_cb(Fl_Button *, printspect *panel) { dbgprintf("Cancel Button pressed on print prefs panel\n"); // hide the window panel->hide(); return; } void previewbutton_cb(Fl_Button *b, printspect *panel) { dbgprintf("preview Button pressed on print spect panel\n"); if (b->value()) panel->doThePreview(); else panel->closePreview(); return; } // This is really the `print' button... void okbutton_cb(Fl_Return_Button *, printspect *panel) { dbgprintf("Print Button pressed on print prefs panel\n"); if (panel->doThePrinting() == 0) { // hide the window panel->hide(); } // else leave the panel around for the user to correct things return; } ������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/printSpect.hxx������������������������������������������������������������������������0000644�0000765�0000765�00000007674�07653236475�016716� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: printSpect.hxx,v 4.0 2003/04/28 14:39:57 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A printPreferenceWindow class for spectra * * not Experimenting OOP with fluid anymore! * * Hugues Talbot 2 Sep 1998 *-----------------------------------------------------------------------*/ #ifndef PRINTSPECT_H #define PRINTSPECT_H #include <FL/Fl.H> #include <FL/Fl_Box.H> #include <FL/Fl_Button.H> #include <FL/Fl_Check_Button.H> #include <FL/Fl_Group.H> #include <FL/Fl_Input.H> #include <FL/Fl_Return_Button.H> #include <FL/Fl_Window.H> #include "imview.hxx" #include "io/gplot2.hxx" typedef enum { A4_PAGE = 0, LETTER_PAGE = 1, A3_PAGE = 2 } pagetype; typedef enum { LANDSCAPE = 0, PORTRAIT = 1 } pageorient; typedef enum { LINES = 0, SPLINES = 1 } jointype; class printspect { public: printspect(); void setDefaults(); void toggleToFile(); void toggleToPrinter(); void allowTitle(bool b); void printFileName(const char *fn); const char *filenameInputValue(void) { return filenameInput->value(); } void show(); void hide(); int doThePreview(); int closePreview(); int doThePrinting(); void setCallerType(paneltype thisPanel) {whichPanel = thisPanel;} friend Fl_Window *printspect_panel(printspect &s); private: paneltype whichPanel; // the connection to gnuplot plot_t *thePlot; // in the order they appear in fluid // -- The dialog window Fl_Window *prefWindow; // the main window // Print type group Fl_Group *printtypeGroup; Fl_Check_Button *printerCheck, *fileCheck; // Input group Fl_Group *inputGroup; Fl_Input *commandInput; Fl_Input *filenameInput; Fl_Button *browseButton; Fl_Input *titleInput; // Orientation Group Fl_Group *orientationGroup; Fl_Check_Button *portraitCheck, *landscapeCheck; // Paper size group Fl_Group *papersizeGroup; Fl_Check_Button *A4Check, *letterCheck, *A3Check; // Language Group Fl_Group *joinGroup; Fl_Check_Button *linesCheck, *splinesCheck; Fl_Input *nbcopiesInput; Fl_Button *previewButton, *CancelButton; Fl_Return_Button *OKButton; }; #endif // PRINTSPECT_H ��������������������������������������������������������������������imview-1.1.9c/profileBox.cxx������������������������������������������������������������������������0000644�0000765�0000765�00000025635�07653236475�016664� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: profileBox.cxx,v 4.0 2003/04/28 14:39:57 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The code for the profile display panel * * Hugues Talbot 1 Aug 1998 * *-----------------------------------------------------------------------*/ #include <string.h> #include "imview.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "profileBox.hxx" #include "saveSpect.hxx" #include "printSpect.hxx" extern imageViewer *mainViewer; extern savespect *saveSpectPanel; extern printspect *printSpectPanel; void myProfileBox::setProfiles(int startX, int startY, int endX, int endY, double *theProfileR, double *theProfileG, double *theProfileB, int nbval) { if (theProfileR != 0) { if (profileR) delete[] profileR; if (profileG) delete[] profileG; if (profileB) delete[] profileB; // R will be either Red or Grey profileR = new double[nbval]; memcpy(profileR, theProfileR, nbval*sizeof(double)); if (theProfileG) { profileG = new double[nbval]; memcpy(profileG, theProfileG, nbval*sizeof(double)); } else { profileG = 0; } if (theProfileB) { profileB = new double[nbval]; memcpy(profileB, theProfileB, nbval*sizeof(double)); } else { profileB = 0; } nbProfileValues = nbval; sx = startX ; sy = startY; ex = endX; ey = endY; recomputeLimits(); } else { if (profileR) delete[] profileR; if (profileG) delete[] profileG; if (profileB) delete[] profileB; profileR = profileG = profileB = 0; nbProfileValues = 0; } return; } void myProfileBox::recomputeLimits(void) { if (profileR) { if (!absolute) mins = maxs = profileR[0]; // else they have already been set to 0 for (int i = 1 ; i < nbProfileValues ; i++) { if (profileR[i] > maxs) maxs = profileR[i]; if (profileR[i] < mins) mins = profileR[i]; } // same for G and B if they exist if (profileG) { for (int i = 1 ; i < nbProfileValues ; i++) { if (profileG[i] > maxs) maxs = profileG[i]; if (profileG[i] < mins) mins = profileG[i]; } } if (profileB) { for (int i = 1 ; i < nbProfileValues ; i++) { if (profileB[i] > maxs) maxs = profileB[i]; if (profileB[i] < mins) mins = profileB[i]; } } // special case of the char values. if (absolute && (mins >= 0.0) && (maxs <= 255.0)) { mins = 0.0; maxs = 255.0; } // what if they are both equal? if (maxs == mins) maxs = 1.0; if (theProfile) { theProfile->setAxisBoxesLimits(0, nbProfileValues, mins, maxs); } } return; } int myProfileBox::handle(int event) { int retval = 0; int button; if (profileR) { button = Fl::event_button(); switch (event) { case FL_PUSH: handleButtonPushed(); retval = 1; break; case FL_DRAG: handleButtonDragged(); retval = 1; break; case FL_RELEASE: handleButtonReleased(); retval = 1; break; case FL_LEAVE: // Return to normal cursor fl_cursor(FL_CURSOR_DEFAULT); retval = 1; break; default: retval = 0; break; } } return retval; } void myProfileBox::handleButtonPushed() { fl_cursor((Fl_Cursor)MY_CURSOR_VLINE); handleButtonDragged(); return; } void myProfileBox::handleButtonDragged() { int index; int xx = Fl::event_x(); int realwidth = w() - WIDTHMARGIN; index = (int)(((double)xx-x()-WIDTHMARGIN/2)*(nbProfileValues-1)/realwidth + 0.5); if ((index >= 0) && (index < nbProfileValues) && theProfile) { theProfile->setXValue((int)(sx + (double)index*(ex-sx)/nbProfileValues)); theProfile->setYValue((int)(sy + (double)index*(ey-sy)/nbProfileValues)); theProfile->setRValue(profileR[index]); if (profileG) theProfile->setGValue(profileG[index]); else theProfile->setGValue(profileR[index]); if (profileB) theProfile->setBValue(profileB[index]); else theProfile->setBValue(profileR[index]); } return; } void myProfileBox::handleButtonReleased() { fl_cursor(FL_CURSOR_DEFAULT); return; } void myProfileBox::draw() { int xa, ya, xb, yb; int realwidth = w() - WIDTHMARGIN; int realheight = h() - HEIGHTMARGIN; // superclass draw: draw_box(); draw_label(); fl_clip(x(),y(),w(),h()); if (profileR != 0) { if (profileG != 0) fl_color(FL_RED); else fl_color(FL_BLACK); for (int i = 1 ; i < nbProfileValues ; i++) { xa = (int)(((i-1)*realwidth)/(nbProfileValues-1) + WIDTHMARGIN/2 + 0.5); ya = (int)(((1.0 - (profileR[i-1]-mins)/(maxs-mins))*realheight) + HEIGHTMARGIN/2 + 0.5); xb = (int)((i*realwidth)/(nbProfileValues - 1) + WIDTHMARGIN/2 + 0.5); yb = (int)(((1.0 - (profileR[i]-mins)/(maxs-mins))*realheight) + HEIGHTMARGIN/2 +0.5); fl_line(xa+x(), ya+y(), xb+x(), yb+y()); } } if (profileG != 0) { fl_color(FL_GREEN); for (int i = 1 ; i < nbProfileValues ; i++) { xa = (int)(((i-1)*realwidth)/(nbProfileValues-1) + WIDTHMARGIN/2 + 0.5); ya = (int)(((1.0 - (profileG[i-1]-mins)/(maxs-mins))*realheight) + HEIGHTMARGIN/2 +0.5); xb = (int)((i*realwidth)/(nbProfileValues - 1) + WIDTHMARGIN/2 + 0.5); yb = (int)(((1.0 - (profileG[i]-mins)/(maxs-mins))*realheight) + HEIGHTMARGIN/2 + 0.5); fl_line(xa+x(), ya+y(), xb+x(), yb+y()); } } if (profileB != 0) { fl_color(FL_BLUE); for (int i = 1 ; i < nbProfileValues ; i++) { xa = (int)(((i-1)*realwidth)/(nbProfileValues-1) + WIDTHMARGIN/2 + 0.5); ya = (int)(((1.0 - (profileB[i-1]-mins)/(maxs-mins))*realheight) + HEIGHTMARGIN/2 + 0.5); xb = (int)((i*realwidth)/(nbProfileValues - 1) + WIDTHMARGIN/2 + 0.5); yb = (int)(((1.0 - (profileB[i]-mins)/(maxs-mins))*realheight) + HEIGHTMARGIN/2 + 0.5); fl_line(xa+x(), ya+y(), xb+x(), yb+y()); } } fl_pop_clip(); return; } /// The profile stuff profile::profile() { dbgprintf("Profile display dialog created\n"); profileWindow = 0; // fluid depends on that profileBox = 0; return; } void profile::setDefaults(void) { // we display relative values by default relative->set(); // button appearance profileBox->setRelative(); // set the variable correctly profileTitle->value("Position: undefined"); xvalue->value("0"); yvalue->value("0"); // the profileBox needs to know us profileBox->setProfile(this); return; } // pass on the data... void profile::setData(double *R, double *G, double *B, int nb, int startx, int starty, int endx, int endy) { static char buff[100]; profileBox->setProfiles(startx, starty, endx, endy, R, G, B, nb); sprintf(buff, "Position: xs=%d, ys=%d, xe=%d, ye=%d", startx, starty, endx, endy); xS = startx; yS = starty; xE = endx; yE = endy; profileTitle->value(buff); return; } int profile::visible() { return profileWindow->visible(); } void profile::redraw() { profileBox->redraw(); return; } void profile::show() { profileWindow->show(); } void profile::hide() { profileWindow->hide(); } void profile::setAxisBoxesLimits(double xminlimit, double xmaxlimit, double yminlimit, double ymaxlimit) { abcissaBox->setRange(xminlimit, xmaxlimit); ordinateBox->setRange(yminlimit, ymaxlimit); abcissaBox->redraw(); ordinateBox->redraw(); } void profile::setXValue(int xv) { static char a[10]; sprintf(a, "%d", xv); xvalue->value(a); } void profile::setYValue(int yv) { static char a[30]; sprintf(a, "%d", yv); yvalue->value(a); } void profile::setZValue(int zv) { static char a[30]; sprintf(a, "%d", zv); zvalue->value(a); } void profile::setRValue(double Rv) { static char a[10]; sprintf(a, "%g", Rv); Rvalue->value(a); } void profile::setGValue(double Gv) { static char a[30]; sprintf(a, "%g", Gv); Gvalue->value(a); } void profile::setBValue(double Bv) { static char a[30]; sprintf(a, "%g", Bv); Bvalue->value(a); } /// The Profile callbacks. void relativecheck_cb(Fl_Check_Button *, profile *panel) { panel->displayRelative(); return; } void absolutecheck_cb(Fl_Check_Button *, profile *panel) { panel->displayAbsolute(); return; } void keepline_cb(Fl_Check_Button *b, profile *) { if (b->value()) mainViewer->keepLine(); else mainViewer->removeLine(); return; } void printbutton_cb(Fl_Button *, profile *) { dbgprintf("Print button pressed\n"); if (printSpectPanel == 0) { printSpectPanel = new printspect; printspect &printref = *printSpectPanel; // initializes the fluid-generated panel printspect_panel(printref); // do our own initialization printSpectPanel->setDefaults(); } // show the panel printSpectPanel->setCallerType(PROFILEPANEL); printSpectPanel->show(); return; } void savebutton_cb(Fl_Button *, profile *) { dbgprintf("Save button pressed\n"); if (saveSpectPanel == 0) { saveSpectPanel = new savespect; savespect &saveref = *saveSpectPanel; // initializes the fluid-generated panel savespect_panel(saveref); // do our own initialization saveSpectPanel->setDefaults(); } // show the panel saveSpectPanel->setCallerType(PROFILEPANEL); saveSpectPanel->show(); return; } void okbutton_cb(Fl_Return_Button*, profile *panel) { // this is very simple... panel->hide(); } ���������������������������������������������������������������������������������������������������imview-1.1.9c/profileBox.hxx������������������������������������������������������������������������0000644�0000765�0000765�00000012127�07653236477�016663� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: profileBox.hxx,v 4.0 2003/04/28 14:39:59 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The profile display panel * * Hugues Talbot 1 Aug 1998 * *-----------------------------------------------------------------------*/ #ifndef PROFILEBOX_H #define PROFILEBOX_H #include <stdlib.h> #include <stdio.h> #include <FL/Fl.H> #include <FL/x.H> #include <FL/fl_draw.H> #include <FL/Fl_Double_Window.H> #include <FL/Fl_Box.H> #include <FL/Fl_Button.H> #include <FL/Fl_Check_Button.H> #include <FL/Fl_Return_Button.H> #include <FL/Fl_Output.H> #include <FL/fl_ask.H> #include "axisBox.hxx" #define WIDTHMARGIN 4 #define HEIGHTMARGIN 8 #ifdef WIN32 # define MY_CURSOR_VLINE FL_CURSOR_HAND #else # define MY_CURSOR_VLINE 58 #endif class myProfileBox : public Fl_Box { public: myProfileBox(int x, int y, int w, int h, const char *l=0) : Fl_Box(x,y,w,h,l) { profileR = profileB = profileG = 0; nbProfileValues = 0; mins = maxs = 0; } int handle(int event); // we need this for mouse control void handleButtonPushed(); void handleButtonDragged(); void handleButtonReleased(); void setRelative() {absolute = false; recomputeLimits(); redraw();} void setAbsolute() {absolute = true; recomputeLimits(); redraw();} void setProfile(class profile *s) {theProfile = s;} void setProfiles(int startX, int startY, int endX, int endY, double *theProfileR, double *theProfileG, double *theProfileB, int nbval); double *getProfileR() {return profileR;} double *getProfileG() {return profileG;} double *getProfileB() {return profileB;} int getNbValues() {return nbProfileValues;} void recomputeLimits(); void draw(); private: double *profileR, *profileG, *profileB, maxs, mins; int nbProfileValues; int sx, sy, ex, ey; bool absolute; class profile *theProfile; }; class profile { public: profile(); ~profile(); void setDefaults(); void setData(double *R, double *G, double *B, int nb, int xstart, int ystart, int xend, int yend); double *getDataR() {return profileBox->getProfileR();} double *getDataG() {return profileBox->getProfileG();} double *getDataB() {return profileBox->getProfileB();} int getNbVal() {return profileBox->getNbValues();} int getXstart() {return xS;} int getYstart() {return yS;} int getXend() {return xE;} int getYend() {return yE;} int visible(); void redraw(); void show(); void hide(); void displayRelative(void) {profileBox->setRelative();} void displayAbsolute(void) {profileBox->setAbsolute();} void setXValue(int xv); void setYValue(int yv); void setZValue(int zv); void setRValue(double Rv); void setGValue(double Gv); void setBValue(double Bv); void setAxisBoxesLimits(double xminlimit, double xmaxlimit, double yminlimit, double ymaxlimit); friend Fl_Double_Window *profile_panel(profile &s); private: int xS, yS, xE, yE; Fl_Double_Window *profileWindow; myProfileBox *profileBox; axisBox *abcissaBox, *ordinateBox; Fl_Button *saveButton, *printButton; Fl_Return_Button *OKButton; Fl_Output *profileTitle; Fl_Output *xvalue, *yvalue, *zvalue; Fl_Output *Rvalue, *Gvalue, *Bvalue; Fl_Check_Button *absolute, *relative; Fl_Check_Button *keepline; }; #endif // PROFILEBOX_H �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/progressInfo.cxx����������������������������������������������������������������������0000644�0000765�0000765�00000005315�07653236477�017226� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: progressInfo.cxx,v 4.0 2003/04/28 14:39:59 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A simple progress panel. * * Hugues Talbot 16 Mar 2000 * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" // name space and everything... #include <stdio.h> #include "imview.hxx" #include "imageIO.hxx" #include "progressInfo.hxx" extern imageIO *IOBlackBox; progress::progress() { dbgprintf("Progress panel constructed\n"); // must be done (Fluid depens on it) progressWindow = 0; return; } void progress::setDefaults() { dbgprintf("Setting defaults for progress panel\n"); progressSlider->value(0); } void progress::setProgress(double v) { if ((v >= 0) && (v <= 100)) progressSlider->value(v); return; } bool progress::visible() { return (progressWindow->visible() != 0); } void progress::show() { progressWindow->show(); } void progress::hide() { progressWindow->hide(); } void okbutton_cb(Fl_Return_Button *, progress *panel) { dbgprintf("Dismiss button pressed on progress panel\n"); panel->hide(); return; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/progressInfo.hxx����������������������������������������������������������������������0000644�0000765�0000765�00000004453�07653236477�017235� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: progressInfo.hxx,v 4.0 2003/04/28 14:39:59 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A simple progress slider panel * * Hugues Talbot 16 Mar 2000 * *-----------------------------------------------------------------------*/ #ifndef PROGRESSINFO_H #define PROGRESSINFO_H #include <FL/Fl.H> #include <FL/Fl_Slider.H> #include <FL/Fl_Return_Button.H> #include <FL/Fl_Window.H> class progress { public: progress(); void setDefaults(); void setProgress(double v); bool visible(); void show(); void hide(); friend Fl_Window *progress_panel(progress &p); private: Fl_Window *progressWindow; Fl_Slider *progressSlider; }; #endif // PROGRESSINFO_H ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/rawImage.cxx��������������������������������������������������������������������������0000644�0000765�0000765�00000025347�10720437041�016264� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: rawImage.cxx,v 4.4 2007/11/20 01:53:37 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A panel for reading arbitrary uncompressed images. * * Hugues Talbot 8 Apr 2000 * * A wish from the Perth group. * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" #include <stdio.h> #include <string.h> #include <stdlib.h> #include <assert.h> #include <time.h> #include <sys/stat.h> #include <map> // STL #include <string> // STL strings #include <iostream> #include <fstream> #include <sstream> #include "imunistd.h" #include "imview.hxx" #include "imageIO.hxx" #include "rawImage.hxx" #include "menubar.hxx" // for openimage #include "machine.hxx" extern imageIO *IOBlackBox; extern std::map <string, RAWFILE_HEADER> rawfilemap; // we use a global static array so that the // callbacks can see it. static pixtype pixtype_match[NBTYPES] = { IM_UINT1, IM_INT2, IM_UINT2, IM_INT4, IM_UINT4, IM_INT8, IM_UINT8, IM_FLOAT, IM_DOUBLE }; rawimage::rawimage() { dbgprintf("Raw image panel constructed\n"); rawimageWindow = 0; // fluid depends on this return; } rawimage::~rawimage() { // filename is now a char array. } void rawimage::setFileName(const char *v) { strncpy(filename, v, 1023); } void rawimage::setDefaults(void) { // explanatory text bannerOutput->value("If you know the image data is uncompressed and you know the image\n" "dimensions, you can enter them below; otherwise press Cancel."); xInput->value("1"); yInput->value("1"); zInput->value("1"); nbBandsInput->value("1"); bandTypeChoice->deactivate(); // no need if there is only one band assignButton->deactivate(); // same headerSizeInput->value("0"); filesizeOutput->value("0"); // consistent corresponding values nx = ny = nz = 1; spp = 1; interleave = 0; // default from fluid byteOrder = 0; // sameg ptype = IM_UINT1; // same dataSize = headerSize = 0; dataSize = 0; filename[0] = '\0'; } void rawimage::show() { rebuildBoxTitle(); rawimageWindow->show(); loadHeader(); return; } void rawimage::hide() { rawimageWindow->hide(); return; } void rawimage::recomputeHeader(void) { int header; header = computeSkip(); if (header < 0) { headerSizeInput->textcolor(FL_RED); OKButton->deactivate(); } else { headerSizeInput->textcolor(FL_BLACK); OKButton->activate(); } if (spp > 1) { bandTypeChoice->activate(); assignButton->activate(); } else { bandTypeChoice->deactivate(); assignButton->deactivate(); } } int rawimage::computeSkip(void) { int totaldata; totaldata = nx*ny*nz*spp * IOBlackBox->typeSize(ptype); headerSize = dataSize - totaldata; return headerSize; } void rawimage::setHeaderInput(void) { char buf[100]; int v = computeSkip(); snprintf(buf, 100, "%d", v); headerSizeInput->value(buf); } void rawimage::saveHeader(void) { RAWFILE_HEADER rfh; rfh.nx = nx; rfh.ny = ny; rfh.nz = nz; rfh.spp = spp; rfh.byo = (endianness) byteOrder; rfh.itl = interleave; rfh.pixt = ptype; rfh.filesize = dataSize; rfh.skip = headerSize; rawfilemap[filename] = rfh; // save the header as well // std::ostringstream headerfilename; headerfilename << filename << ".ivh" ; // ImView Header std::ofstream headerfile(headerfilename.str().c_str()); if (headerfile) { headerfile << "# header file for " << filename << std::endl; headerfile << "nx=" << nx << std::endl; headerfile << "ny=" << ny << std::endl; headerfile << "nz=" << nz << std::endl; headerfile << "spp=" << spp << std::endl; headerfile << "byo=" << byteOrder << std::endl; headerfile << "itl=" << interleave << std::endl; headerfile << "pixt=" << ptype << std::endl; headerfile << "filesize=" << dataSize << std::endl; headerfile << "skip=" << headerSize << std::endl; headerfile.close(); } } bool rawimage::loadHeader(void) { int nbval = 0; bool retval = false; static char newTitle[100]; std::ostringstream headerfilename; headerfilename << filename << ".ivh" ; // ImView Header std::ifstream headerfile(headerfilename.str().c_str()); if (headerfile) { string currentline; string::size_type pos; dbgprintf("Loading header for raw image %s\n", filename); do { getline(headerfile, currentline); if (currentline[0] == '#') // comment continue; // look for the = sign if ((pos = currentline.find("=")) != string::npos) { int value = atoi(currentline.substr(pos+1).c_str()); string key = currentline.substr(0,pos); dbgprintf("Key=%s, value = %d\n", key.c_str(), value); if (key == "nx") { nx = value; ++nbval ; continue;} if (key == "ny") { ny = value; ++nbval ; continue;} if (key == "nz") { nz = value ; ++nbval ; continue;} if (key == "spp") {spp = value ; ++nbval ; continue;} if (key == "byo") {byteOrder = value; ++nbval ; continue;} if (key == "itl") {interleave = value ; ++nbval ; continue;} if (key == "pixt") {ptype = static_cast<pixtype>(value); ++nbval ; continue;} if (key == "filesize") {dataSize = value ; ++nbval ; continue;} if (key == "skip") {headerSize = value ; ++nbval ; continue;} dbgprintf("Unknown key !\n"); } } while (!currentline.empty()); headerfile.close(); dbgprintf("nbval = %d\n", nbval); if (nbval == 9) { // all fields are filled, save stuff in header. RAWFILE_HEADER rfh; dbgprintf("Setting values into panel\n"); rfh.nx = nx; setInputValue(xInput, nx); rfh.ny = ny; setInputValue(yInput, ny); rfh.nz = nz; setInputValue(zInput, nz); rfh.spp = spp; setInputValue(nbBandsInput, spp); // the byte ordering choice is in the right order rfh.byo = (endianness) byteOrder; byteOrderChoice->value(byteOrder); // the band interleave are in the right order rfh.itl = interleave; bandTypeChoice->value(interleave); // the pixel types are not in order rfh.pixt = ptype; setPixtypeChoice(ptype); rfh.filesize = dataSize; rfh.skip = headerSize; setInputValue(headerSizeInput, headerSize); rawfilemap[filename] = rfh; retval = true; } // Change the dialog's message snprintf(newTitle, 100, "%s: RAW format with header found", myBaseName(filename)); titleBox->label(newTitle); titleBox->labelcolor(FL_DARK_GREEN); } return retval; } void rawimage::tryReading(void) { // try reading the file again... openimage(filename); } // work out the file size as well... void rawimage::rebuildBoxTitle(void) { static char newTitle[100], fst[20]; struct stat statbuf; assert(filename != 0); snprintf(newTitle, 100, "%s: format not recognized", myBaseName(filename)); titleBox->label(newTitle); titleBox->labelcolor(FL_RED); if (stat(filename, &statbuf) == 0) dataSize = statbuf.st_size; else dataSize = 0; snprintf(fst, 20, "%d", dataSize); filesizeOutput->value(fst); } //------- callbacks -------- void xinput_cb(Fl_Int_Input *i, rawimage *panel) { int nx; nx = atoi(i->value()); panel->setnx(nx); } void yinput_cb(Fl_Int_Input *i, rawimage *panel) { int ny; ny = atoi(i->value()); panel->setny(ny); } void zinput_cb(Fl_Int_Input *i, rawimage *panel) { int nz; nz = atoi(i->value()); panel->setnz(nz); } void nbband_cb(Fl_Int_Input *i, rawimage *panel) { int spp; spp = atoi(i->value()); panel->setspp(spp); } void pixeltype_cb(Fl_Choice *c, rawimage *panel) { int rp = c->value(); dbgprintf("pixel type callback: chosen %d\n", rp); assert((rp >= 0) && (rp < NBTYPES)); panel->setPixType(pixtype_match[rp]); } void interleave_cb(Fl_Choice *c, rawimage *panel) { int leav = c->value(); dbgprintf("Interleave callback: %d\n", leav); assert((leav >= 0) && (leav < NBINTER)); panel->setInterleave(leav); } void byteorder_cb(Fl_Choice *c, rawimage *panel) { int bo = c->value(); dbgprintf("Byte order callback: %d\n", bo); assert((bo >= 0) && (bo < NBBYORD)); panel->setByteOrder(bo); } void computeskip_cb(Fl_Button *, rawimage *panel) { panel->setHeaderInput(); } void headersize_cb(Fl_Int_Input *i, rawimage *panel) { int hs = atoi(i->value()); dbgprintf("Header size changed to %d\n", hs); panel->setHeaderSize(hs); } void helpbutton_cb(Fl_Button *, rawimage *panel) { dbgprintf("Help on rawimage called\n"); return; } void cancelbutton_cb(Fl_Button *, rawimage *panel) { panel->hide(); } void okbutton_cb(Fl_Button *, rawimage *panel) { dbgprintf("OK Button pressed, saving the structure... \n"); panel->saveHeader(); panel->tryReading(); //panel->hide(); } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/rawImage.hxx��������������������������������������������������������������������������0000644�0000765�0000765�00000012154�10720437041�016261� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * $Id: rawImage.hxx,v 4.3 2007/11/20 01:53:37 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A class associated with a panel for reading arbitrary uncompressed * images * * Hugues Talbot 8 Apr 2000 * * *-----------------------------------------------------------------------*/ #ifndef RAWIMAGE_H #define RAWIMAGE_H #include <sstream> #include <FL/Fl.H> #include <FL/Fl_Button.H> #include <FL/Fl_Input.H> #include <FL/Fl_Int_Input.H> #include <FL/Fl_Output.H> #include <FL/Fl_Choice.H> #include <FL/Fl_Window.H> #include <FL/Fl_Box.H> #include "imview.hxx" #define NBTYPES 9 // nb of pixel types #define NBINTER 3 // nb of possible band interleaves #define NBBYORD 4 // nb of byte orderings. class rawimage { public: rawimage(); ~rawimage(); void setDefaults(void); void show(void); void hide(void); // access to private data void setDataSize(int v) {dataSize = v;} void setnx(int v) {nx = v; recomputeHeader();} void setny(int v) {ny = v; recomputeHeader();} void setnz(int v) {nz = v; recomputeHeader();} void setspp(int v) {spp = v; recomputeHeader();} void setPixType(pixtype v) {ptype = v; recomputeHeader();} void setInterleave(int v) {interleave = v;} void setByteOrder(int v) {byteOrder = v;} void setHeaderSize(int v) {headerSize = v;} void setHeaderInput(void); // this method saves the user input void saveHeader(void); bool loadHeader(void); void tryReading(void); void setFileName(const char *v); friend Fl_Window *rawimage_panel(rawimage &ri); enum {Uchar = 0, Short, Ushort, Int, Uint, Long, Ulong, Float, Double}; enum {Default = 0, MSB, LSB, Guess }; enum {BIL = 0, BIP, BSQ }; private: // Dialog window Fl_Window *rawimageWindow; // Fl_Box *titleBox; Fl_Output *bannerOutput; // dimensions Fl_Int_Input *xInput, *yInput, *zInput; // bands Fl_Int_Input *nbBandsInput; Fl_Choice *bandTypeChoice; Fl_Button *assignButton; // pixel Fl_Choice *pixelTypeChoice, *byteOrderChoice; // file and header Fl_Int_Input *headerSizeInput; Fl_Output *filesizeOutput; // usual buttons Fl_Button *helpButton, *cancelButton, *OKButton; Fl_Button *computeHeaderButton; // ------- other bits int dataSize, headerSize; int nx, ny, nz; int spp; int interleave; int byteOrder; pixtype ptype; char filename[1024]; void recomputeHeader(void); int computeSkip(void); void rebuildBoxTitle(void); void setInputValue(Fl_Int_Input *fi, int value) { std::ostringstream valss; valss << value; fi->value(valss.str().c_str()); //valss.seekp(0); return; } void setPixtypeChoice(const pixtype p) { int index = 0; switch (p) { case IM_BINARY: case IM_CHAR: index = 0; break; case IM_INT2: index = 1; break; case IM_UINT2: index = 2 ; break; case IM_INT4: index = 3; break; case IM_UINT4: index = 4 ; break; case IM_FLOAT: index = 5 ; break; case IM_DOUBLE: index = 6 ; break; default : index = -1 ; break; } pixelTypeChoice->value(index); } }; #endif // RAWIMAGE_H ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/README��������������������������������������������������������������������������������0000644�0000765�0000765�00000010302�10632004146�014643� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# -*- text -*- # README $Id: README,v 4.2 2007/06/07 13:30:14 hut66au Exp $ # Introduction Imview is an image viewing package intended for image analysis, i.e: getting numbers (measurements) out of images. It is designed to interface easily to image analysis packages such as Khoros or Z-IMAGE (http://www.cmis.csiro.au/IAP/zimage.htm), to perform as an external viewer. It has facilities for histogram-based segmentation, comparing images before and after a series of filtering, etc. It supports many different image format and pixel types (integer and floating point, 1 to 64 bits). It can also perform more than adequately as a general-purpose image display application, but this is not the emphasis. Imview is free software distributed under the GNU public licence. Version 1.1.x: Imview version 1.1.x is the currently unstable version based on FLTK 1.1.x Roadmap IMVIEW consists of a main executable and a few support files. Among the support files there are: .lut files: these are simple Colour Look-Up Table text files that associate a grey-level index to an RGB colour (false colours). .html files: these are the online documentation (very slim at this stage) .jpg file: this is the splash screen. Replace it or delete if you don't like it! Let me know if you make a better one. The main executable (imview) is a semi-static executable linked against a number of imaging libraries (JPEG, PNG, TIFF, ImageMagick) and the GUI toolkit (FLTK). Installer: Imview is provided both in source and binary form. All binary formats come with an installer. If you downloaded the RPM then use the rpm installer to make use of it, otherwise Under Unix: untar the file and type ./setup Under Windows: simply execute the file. NOTE: under windows 9x (95, 98 and me) you must make sure that TCP/IP is installed. If you have an internet connection you will be fine. TCP/IP is always present with Unix, NT, Win2k and WinXP. Documentation: Imview should be very simple to use, but full documentation is available in HTML, PS or PDF format, see the web site http://www.cmis.csiro.au/Hugues.Talbot/imview or http://imview.sourceforge.net/ To compile imview: See the INSTALL text file. Essentially you will need the FLTK library (http://www.fltk.org), and supporting imaging libraries if they are not present on your system. On Unix imview uses the POSIX thread library, TCP/IP sockets and the SYSV IPC if present. Under windows an implementation of POSIX threads is provided (SYSV IPC is not used, sockets are used instead). The directory structure: imview. The main source repository |-- check For regression testing (an interesting concept for GUIs) |-- client Network client code (to remote-control imview) |-- distrib To make distributions | |-- binaries Generic binary distributions | |-- redhat Specific to the RedHat RPM system | | |-- BUILD | | |-- CVS | | |-- RPMS | | |-- SOURCES | | |-- SPECS | | `-- SRPMS | | | `-- windows Uses the Inno Setup installer for Windows | |-- doc Documentation (online one only, full documentation is separate) |-- export Used for making snapshots |-- fluid Interface files (FLUID is the fast light user interface designer) |-- io I/O library (all these different image formats) |-- obj Compilation subdirectory | `-- NT-msvc++ MSVC++ project files | `-- fluid |-- server Imview server (for remote control) |-- stl Missing bits of the STL for egcs/gcc-2.95.x | `-- sstream `-- support Support files (LUT, etc). ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������imview-1.1.9c/README.html���������������������������������������������������������������������������0000644�0000765�0000765�00000012315�07660203535�015626� 0����������������������������������������������������������������������������������������������������ustar �talbot��������������������������talbot��������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>IMVIEW README -- HTML format

Introduction

Imview is an image viewing package intended for image analysis, i.e:  getting numbers (measurements) out of images. It is designed to interface easily to image analysis packages such as Khoros or Z-IMAGE (http://www.cmis.csiro.au/IAP/zimage.htm), to perform as an external viewer.
It has facilities for histogram-based segmentation, comparing images before and after a series of filtering, etc. It supports many different image format and pixel types (integer and floating point, 1 to 64 bits).
It can also perform more than adequately as a general-purpose image display application, but this is not the emphasis.
Imview is free software distributed under the GNU public licence.

Version 1.1.x:

     Imview version 1.1.x is the currently unstable version based on FLTK 1.1.x

Roadmap

IMVIEW consists of a main executable and a few support files. Among the support files there are:

.lut files:

these are simple Colour Look-Up Table text files that associate a grey-level index to an RGB colour (false colours).

.html files:

these are the online documentation (very slim at this stage)

.jpg file:

this is the splash screen. Replace it or delete if you don't like it! Let me know if you make a better one.

The main executable (imview) is a semi-static executable linked against a number of imaging libraries (JPEG, PNG, TIFF, ImageMagick) and the GUI toolkit (FLTK).

Installer:

Imview is provided both in source and binary form. All binary formats come with an installer. If you downloaded the RPM then use the rpm installer to make use of it, otherwise Under Unix: untar the file and type ./setup Under Windows: simply execute the file.

NOTE: 

under windows 9x (95, 98 and me) you must make sure that TCP/IP is installed. If you have an internet connection you will be fine. TCP/IP is always present with Unix, NT, Win2k and WinXP.

Documentation:

Imview should be very simple to use, but full documentation is available in HTML, PS or PDF format, see the web site
or
http://imview.sourceforge.net/

To compile imview:

See the INSTALL text file. Essentially you will need the FLTK library (http://www.fltk.org), and supporting imaging libraries if they are not present on your system.
On Unix imview uses the POSIX thread library, TCP/IP sockets and the SYSV IPC if present. Under windows an implementation of POSIX threads is provided (SYSV IPC is not used, sockets are used instead).

The directory structure:


imview. The main source repository
|-- check For regression testing (an interesting concept for GUIs)
|-- client Network client code (to remote-control imview)
|-- distrib To make distributions
| |-- binaries Generic binary distributions
| |-- redhat Specific to the RedHat RPM system
| | |-- BUILD
| | |-- CVS
| | |-- RPMS
| | |-- SOURCES
| | |-- SPECS
| | `-- SRPMS
| |
| `-- windows Uses the Inno Setup installer for Windows
|
|-- doc Documentation (online one only, full documentation is separate)
|-- export Used for making snapshots
|-- fluid Interface files (FLUID is the fast light user interface designer)
|-- io I/O library (all these different image formats)
|-- obj Compilation subdirectory
| `-- NT-msvc++ MSVC++ project files
| `-- fluid
|-- server Imview server (for remote control)
|-- stl Missing bits of the STL for egcs/gcc-2.95.x
| `-- sstream
`-- support Support files (LUT, etc).


imview-1.1.9c/savePrefs.cxx0000644000076500007650000004555210733752216016476 0ustar talbottalbot00000000000000/* * $Id: savePrefs.cxx,v 4.2 2007/12/24 15:47:26 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A save preference panel using fluid * * Hugues Talbot 27 Apr 1998 * *-----------------------------------------------------------------------*/ #include #include #include #include "imunistd.h" #include #include #include #include #include "imview.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "savePrefs.hxx" #include "io/savetiff.hxx" #include "io/saveZimage.hxx" #include "io/writeMagick.hxx" // typedef void (menucb)(Fl_Menu_ *, void *); // application components extern char appName[]; extern imageIO *IOBlackBox; extern imageViewer *mainViewer; extern saveprefs *savePrefsPanel; // compression names extern char *comp_schemes[]; static const char *formatExtensionList[] = { ".tif", "_z", ".euro", // not implemented, but come in this number ".png", ".jpg", 0 }; saveprefs::saveprefs() { dbgprintf("Save panel constructed\n"); saveWindow = 0; // fluid depends on that return; } void saveprefs::setDefaults() { static char buff[DFLTSTRLEN]; static Fl_Menu_Item *newMenu = 0; int newMenuSize, i; dbgprintf("Setting default for save panel\n"); // the choice format menu is now set up within fluid latestGreyTiffOption = TIFF_CMP_LZW; latestBinaryTiffOption = TIFF_CMP_CCITTG4; setCompression(TIFF_FMT); // we save the whole image by default wholeCheck->set(); // we save the visible image by default visibleCheck->set(); // Let's reactivate the deactivated... Hugues Talbot 2 Dec 2002 //underlyingCheck->deactivate(); //underlyingCheck->labelcolor(40); // deactivated for now... // I'm aghast fluid doesn't do that by itself... formatMenu = formatChoice->menu(); newMenuSize = formatMenu->size(); newMenu = new Fl_Menu_Item[newMenuSize]; for (i = 0 ; i < newMenuSize ; i++) { newMenu[i] = formatMenu[i]; } formatChoice->menu(newMenu); tiffmenuitem = newMenu + TIFF_FMT; pngmenuitem = newMenu + PNG_FMT; jpgmenuitem = newMenu + JPG_FMT; // those CAN be modified. // disable extra formats if ImageMagick not compiled in #ifndef HAVE_MAGICK pngmenuitem->hide(); jpgmenuitem->hide(); #endif #ifndef HAVE_TIFF tiffmenuitem->hide(); #endif // set the default as Z-IMAGE (only format always available) formatChoice->value(ZIMAGE_FMT); // default value for file strncpy(buff, IOBlackBox->getImName(), DFLTSTRLEN); buff[DFLTSTRLEN-1] = '\0'; filenameInput->value(buff); toggleExtension(ZIMAGE_FMT); return; } // this functions changes the .tiff in _z, etc... void saveprefs::toggleExtension(int format) { static char inputContent[DFLTSTRLEN]; char *substr; strcpy(inputContent, filenameInput->value()); dbgprintf("Looking for extensions\n"); if (inputContent != 0) { for (int i = 0 ; formatExtensionList[i] != 0 ; i++) { // look for the common extension of the format if (((substr = strstr(inputContent, formatExtensionList[i])) != 0) && (format < LAST_FMT)) { strcpy(substr, formatExtensionList[format]); filenameInput->value(inputContent); dbgprintf("Extension found\n"); break; } } } return; } void saveprefs::setCompression(int format) { static const Fl_Menu_Item noCompressionMenu[] = { {"None", 0, 0}, {0} }; static const Fl_Menu_Item binaryTiffCompression[] = { {"None", 0, (Fl_Callback *)chosencompression_cb, (void *)TIFF_CMP_NONE}, {"LZW", 0, (Fl_Callback *)chosencompression_cb, (void *)TIFF_CMP_LZW}, {"PackBits", 0, (Fl_Callback *)chosencompression_cb, (void *)TIFF_CMP_PACKBITS}, {"Group 3", 0, (Fl_Callback *)chosencompression_cb, (void *)TIFF_CMP_CCITTG3}, {"Group 4", 0, (Fl_Callback *)chosencompression_cb, (void *)TIFF_CMP_CCITTG4}, {"RLE", 0, (Fl_Callback *)chosencompression_cb, (void *)TIFF_CMP_RLE}, {"RLEW", 0, (Fl_Callback *)chosencompression_cb, (void *)TIFF_CMP_RLEW}, {"Thunderscan", 0, (Fl_Callback *)chosencompression_cb, (void *)TIFF_CMP_THUNDER}, {0} }; static const Fl_Menu_Item greyTiffCompression[] = { {"None", 0, (Fl_Callback *)chosencompression_cb, (void *)TIFF_CMP_NONE}, {"LZW", 0, (Fl_Callback *)chosencompression_cb, (void *)TIFF_CMP_LZW}, {"PackBits", 0, (Fl_Callback *)chosencompression_cb, (void *)TIFF_CMP_PACKBITS}, {0} }; dbgprintf("Setting up the Choice buttons\n"); switch (format) { case TIFF_FMT: compressionChoice->activate(); compressionChoice->labelcolor(FL_BLACK); compressionChoice->textcolor(FL_BLACK); if (IOBlackBox->getCurrImgPixType() == IM_BINARY) { compressionChoice->menu(binaryTiffCompression); compressionChoice->value(latestBinaryTiffOption); } else { compressionChoice->menu(greyTiffCompression); compressionChoice->value(latestGreyTiffOption); } saveWindow->redraw(); break; case ZIMAGE_FMT: case PNG_FMT: case JPG_FMT: compressionChoice->menu(noCompressionMenu); compressionChoice->deactivate(); compressionChoice->labelcolor(40); // from FLUID compressionChoice->textcolor(40); saveWindow->redraw(); break; default: dbgprintf("Unknown file format\n"); compressionChoice->menu(noCompressionMenu); compressionChoice->deactivate(); compressionChoice->labelcolor(40); // from FLUID compressionChoice->textcolor(40); saveWindow->redraw(); break; } return; } void saveprefs::saveFileName(const char *fn) { // this copies it to something more permanent. filenameInput->value(fn); return; } int saveprefs::doTheSaving() { int retval = 0; uchar *buf0, *buf1, *buf2; int origx, origy, origz, nbrows, nbcols, nbcomps; int val; dbgprintf("Doing the saving now\n"); // we can't go any further until we have a writexxx procedure... const char *filename = filenameInput->value(); if ((filename == 0) || (filename[0] == '\0')) { errprintf("Please specify a file to save to\n"); return(1); } else { if (access(filename, W_OK) == 0) { // the file already exists static char alrtmsg[DFLTSTRLEN] ; sprintf(alrtmsg, "File %s already exists\n" "Do you want to overwrite?\n", filename); if (fl_ask(alrtmsg) == 0) { // no, we don't want to overwrite... return(2); } } } buf0 = buf1 = buf2 = 0; // are we saving the visible image? if (visibleCheck->value() == 1) { // we save the whole image if (wholeCheck->value() == 1) { origx = IOBlackBox->getXOffset(); // this is a cop-out for the moment origy = IOBlackBox->getYOffset(); origz = IOBlackBox->getZOffset(); nbcols = IOBlackBox->imageWidth(); nbrows = IOBlackBox->imageHeight(); if ((nbcomps= IOBlackBox->wholeImage(&buf0, &buf1, &buf2)) == 0) { errprintf("Can't save image with %d samples per pixel\n", IOBlackBox->imageDepth()); return(10); } } else { if ((nbcomps= IOBlackBox->subsetImage(&buf0, &buf1, &buf2, origx, origy, nbcols, nbrows)) == 0) { errprintf("Can't save image with %d samples per pixel\n", IOBlackBox->imageDepth()); return(11); } origx += IOBlackBox->getXOffset(); // this is a cop-out for the moment origy += IOBlackBox->getYOffset(); origz = IOBlackBox->getZOffset(); } switch (val = formatChoice->value()) { case TIFF_FMT: { int pi, sf, spp, bps; int pixeltype, imagetype; int start[2], end[2]; void *outbuffp[3]; // get the pixtype & imgtype pixeltype = trivmin(IOBlackBox->getCurrImgPixType(), IM_UINT1); imagetype = (nbcomps == 3) ? IM_RGB : IM_SPECTRUM ; spp = nbcomps; setTifftype(pixeltype, imagetype, &pi, &sf, &spp, &bps); // sanity check if (spp != nbcomps) { errprintf("This can't happen: spp(%d) != nbcomps(%d)\n", spp, nbcomps); break; } outbuffp[0] = buf0; outbuffp[1] = buf1; outbuffp[2] = buf2; start[0] = origx; start[1] = origy; end[0] = origx + nbcols - 1; end[1] = origy + nbrows - 1; retval = save_tiff(outbuffp, 0, start, end, pi, sf, spp, bps, 0, 0, filename, compressionChoice->value()); break; } case PNG_FMT: if (buf0 != 0) // no hard at all... retval = save_magick(filename, "png", nbcomps, nbcols, nbrows, buf0, buf1, buf2); break; case JPG_FMT: if (buf0 != 0) // no hard at all... retval = save_magick(filename, "jpg", nbcomps, nbcols, nbrows, buf0, buf1, buf2); break; case ZIMAGE_FMT: { int nx[3], ny[3], nz[3], x0[3], y0[3], z0[3], ptype[3]; void *outbuffp[3]; nx[0] = nx[1] = nx[2] = nbcols; ny[0] = ny[1] = ny[2] = nbrows; nz[0] = nz[1] = nz[2] = 1; // not a 3D image... x0[0] = x0[1] = x0[2] = origx; y0[0] = y0[1] = y0[2] = origy; z0[0] = z0[1] = z0[2] = origz; ptype[0] = ptype[1] = ptype[2] = \ trivmin(IOBlackBox->getCurrImgPixType(), IM_UINT1); outbuffp[0] = buf0; outbuffp[1] = buf1; outbuffp[2] = buf2; retval = save_zimage(filename, nbcomps, nx, ny, nz, x0, y0, z0, ptype, outbuffp); if (retval != 0) errprintf("Error in Z-IMAGE saving code\n" "writing %s: %s\n", filename, strerror(errno)); break; } default: errprintf("Saving under an unknown format: %d can't do that!\n", val); retval = 5; break; } } else { dbgprintf("Saving the raw data\n"); switch (val = formatChoice->value()) { case TIFF_FMT: { int start[2], end[2], nz; int pi, sf, spp, bps; int ptype, itype; void **outbuffp; // get the pixtype & imgtype ptype = IOBlackBox->getCurrImgPixType(); itype = IOBlackBox->getCurrImgImgType(); spp = IOBlackBox->getCurrImgNbSamples(); setTifftype(ptype, itype, &pi, &sf, &spp, &bps); dbgprintf("TIFF types: pi = %d, sf = %d, spp = %d, bps = %d\n", pi, sf, spp, bps); start[0] = IOBlackBox->getXOffset(); start[1] = IOBlackBox->getYOffset(); end[0] = start[0] + IOBlackBox->imageWidth() - 1; end[1] = start[1] + IOBlackBox->imageHeight() - 1; outbuffp = IOBlackBox->getCurrBuffp(); retval = save_tiff(outbuffp, 0, start, end, pi, sf, spp, bps, 0, 0, filename, compressionChoice->value()); nz = IOBlackBox->imageThickness(); /* save 3D image as extra images (slices) in the file */ /* as in a multi-page document */ if (nz > 1) { void **slices; int nx, ny, bytespersample; warnprintf("3D images saved as a multi-page TIFF image\n"); // Tru64 cxx 6.3 objects with that line for some reason slices = new void *[spp]; nx = IOBlackBox->imageWidth(); ny = IOBlackBox->imageHeight(); bytespersample = trivmax(bps/8, 1); for (int i = 1 ; i < nz ; ++i) { for (int j = 0 ; j < spp ; ++j) { slices[j] = (void*)((char *)(outbuffp[j]) + i * (nx * ny * bytespersample)); } retval = save_tiff(slices, 1, start, end, pi, sf, spp, bps, 0, 0, filename, compressionChoice->value()); } delete[] slices; } } break; case ZIMAGE_FMT: { int *nx = 0, *ny = 0, *nz = 0; int *x0 = 0, *y0 = 0, *z0 = 0, *ptype = 0; int nbcomp = IOBlackBox->getCurrImgNbComps(); int fixedtype = static_cast(IOBlackBox->getCurrImgPixType()); if (nbcomp > 0) { nx = new int[nbcomp]; ny = new int[nbcomp]; nz = new int[nbcomp]; x0 = new int[nbcomp]; y0 = new int[nbcomp]; z0 = new int[nbcomp]; ptype = new int[nbcomp]; for (int i = 0 ; i < nbcomp ; ++i) { nx[i] = IOBlackBox->imageWidth(); ny[i] = IOBlackBox->imageHeight(); nz[i] = IOBlackBox->imageThickness(); x0[i] = IOBlackBox->getXOffset(); y0[i] = IOBlackBox->getYOffset(); z0[i] = IOBlackBox->getZOffset(); ptype[i] = fixedtype; } // this function handles type promotion retval = save_zimage(filename, nbcomp, nx, ny, nz, x0, y0, z0, ptype, IOBlackBox->getCurrBuffp()); if (retval) errprintf("Saving of file %s failed with error %d\n", filename, retval); delete[] nx; delete[] ny; delete[] nz; delete[] x0; delete[] y0; delete[] z0; delete[] ptype; } } break; default: errprintf("Only TIFF and Z-IMAGE format supported for this\n"); retval = 20; break; } } if (buf0 != 0) delete[] buf0; if (buf1 != 0) delete[] buf1; if (buf2 != 0) delete[] buf2; return retval; } void saveprefs::show() { dbgprintf("Showing save window\n"); saveWindow->show(); } void saveprefs::hide() { saveWindow->hide(); } // save panel associated callbacks void filenameinput_cb(Fl_Input *, saveprefs *) { dbgprintf("File name input callback\n"); return; } void browsebutton_cb(Fl_Button *, saveprefs *panel) { const char *currentfile; static const char *p = 0; dbgprintf("Browse button pressed on save prefs panel\n"); currentfile = panel->filenameInputValue(); switch (panel->selectedFileFormat()) { case TIFF_FMT: p = fl_file_chooser("Save to file", "*.[Tt][Ii][Ff]*", currentfile); break; case ZIMAGE_FMT: p = fl_file_chooser("Save to file", "*_z", currentfile); break; case PNG_FMT: p = fl_file_chooser("Save to file", "*.[Pp][Nn][Gg]", currentfile); break; case JPG_FMT: p = fl_file_chooser("Save to file", "*.[Jj][Pp][Gg]", currentfile); break; default: p = fl_file_chooser("Save to file", "*", currentfile); break; } if (p) panel->saveFileName(p); return; } void wholecheck_cb(Fl_Check_Button *, saveprefs *) { dbgprintf("Whole image check button callback\n"); return; } void subsetcheck_cb(Fl_Check_Button *, saveprefs *) { dbgprintf("Subset image check button callback\n"); return; } void visiblecheck_cb(Fl_Check_Button *, saveprefs *) { dbgprintf("Visible image check button callback\n"); return; } void underlyingcheck_cb(Fl_Check_Button *, saveprefs *) { dbgprintf("Underlying image check button callback\n"); return; } void formatchoice_cb(Fl_Choice *, saveprefs *) { dbgprintf("Format choice menu callback\n"); return; } void compressionchoice_cb(Fl_Choice *, saveprefs *) { dbgprintf("Compression choice menu callback\n"); return; } void cancelbutton_cb(Fl_Button *, saveprefs *panel) { dbgprintf("Cancel Button pressed on save prefs panel\n"); // hide the window panel->hide(); return; } void okbutton_cb(Fl_Return_Button *, saveprefs *panel) { dbgprintf("Print Button pressed on save prefs panel\n"); if (panel->doTheSaving() == 0) { // hide the window panel->hide(); } return; } // callback for the choice menu void chosenformat_cb(Fl_Menu_ *, void *fmt) { long val = (long)fmt; switch (val) { case TIFF_FMT: dbgprintf("TIFF Format selected\n"); // selects the compressions available for TIFF savePrefsPanel->setCompression(TIFF_FMT); break; case ZIMAGE_FMT: dbgprintf("Z-IMAGE format selected\n"); savePrefsPanel->setCompression(ZIMAGE_FMT); break; case PNG_FMT: dbgprintf("PNG format selected\n"); savePrefsPanel->setCompression(PNG_FMT); break; case JPG_FMT: dbgprintf("PNG format selected\n"); savePrefsPanel->setCompression(JPG_FMT); break; } savePrefsPanel->toggleExtension(val); } void chosencompression_cb(Fl_Menu_ *, void *cmp) { long val = (long)cmp; switch(val) { case TIFF_CMP_NONE: case TIFF_CMP_LZW: case TIFF_CMP_PACKBITS: savePrefsPanel->setGreyTifComp(val); case TIFF_CMP_CCITTG4: case TIFF_CMP_CCITTG3: case TIFF_CMP_RLE: case TIFF_CMP_RLEW: case TIFF_CMP_THUNDER: savePrefsPanel->setBinTifComp(val); dbgprintf("TIFF compression selected: " "%s\n", comp_schemes[val]); break; default: errprintf("Unknown compression scheme: %d\n", val); break; } return; } imview-1.1.9c/savePrefs.hxx0000644000076500007650000000760007727302474016501 0ustar talbottalbot00000000000000/* * $Id: savePrefs.hxx,v 4.1 2003/09/09 07:46:04 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A save preference window class * * Hugues Talbot 27 Apr 1998 * *-----------------------------------------------------------------------*/ #ifndef SAVEPREFS_H #define SAVEPREFS_H #include #include #include #include #include #include #include #include #include #include #include #include #include "io/savetiff.hxx" // prototypes for the choice menu void chosenformat_cb(Fl_Menu_ *, void *); void chosencompression_cb(Fl_Menu_ *, void *); class saveprefs { public: saveprefs(); void setDefaults(); int doTheSaving(); void saveFileName(const char *fn); const char *filenameInputValue(void) { return filenameInput->value(); } int selectedFileFormat(void) { return formatChoice->value();} void setGreyTifComp(int val) {latestGreyTiffOption = val;} void setBinTifComp(int val) {latestBinaryTiffOption = val;} void show(); void hide(); void toggleExtension(int format); void setCompression(int format); friend Fl_Double_Window *saveprefs_panel(saveprefs &s); private: int latestGreyTiffOption; int latestBinaryTiffOption; // in the order in which they appear in fluid // -- The dialog window Fl_Double_Window *saveWindow; // main window // Filename group Fl_Group *inputGroup; Fl_Input *filenameInput; Fl_Button *browseButton; // save what group Fl_Group *whatGroup; Fl_Check_Button *visibleCheck, *underlyingCheck; // Subset group Fl_Group *subsetGroup; Fl_Check_Button *wholeCheck, *subsetCheck; // Choice menus Fl_Choice *formatChoice; Fl_Choice *compressionChoice; // menu item that may or may not enabled. const Fl_Menu_Item *formatMenu; Fl_Menu_Item *tiffmenuitem, *pngmenuitem, *jpgmenuitem; // expected buttons... Fl_Button *CancelButton; Fl_Return_Button *OKButton; }; #endif // SAVEPREFS_H imview-1.1.9c/saveSpect.cxx0000644000076500007650000002720407653236500016467 0ustar talbottalbot00000000000000/* * $Id: saveSpect.cxx,v 4.0 2003/04/28 14:40:00 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A save preference panel using fluid * * Hugues Talbot 27 Apr 1998 * *-----------------------------------------------------------------------*/ #include #include #include "imunistd.h" #include #include #include #include #include "imview.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "spectraBox.hxx" #include "profileBox.hxx" #include "saveSpect.hxx" #include "io/savetiff.hxx" #include "io/saveZimage.hxx" // typedef void (menucb)(Fl_Menu_ *, void *); // application components extern char appName[]; extern imageIO *IOBlackBox; extern spectra *spectraPanel; extern profile *profilePanel; extern savespect *saveSpectPanel; static const char *formatExtensionList[4] = { ".tif", "_z", ".euro", 0 }; savespect::savespect() { dbgprintf("Save spectrum panel constructed\n"); saveWindow = 0; // fluid depends on that return; } void savespect::setDefaults() { static char buff[100]; dbgprintf("Setting default for save panel\n"); // default value for file sprintf(buff, "%s.euro", appName); filenameInput->value(buff); formatChoice->value(EURO_FMT); whichPanel = SPECTRAPANEL; return; } // this functions changes the .tiff in _z, etc... void savespect::toggleExtension(int format) { static char inputContent[1024]; char *substr; strcpy(inputContent, filenameInput->value()); dbgprintf("Looking for extensions\n"); if (inputContent != 0) { for (int i = 0 ; formatExtensionList[i] != 0 ; i++) { // look for the common extension of the format if (((substr = strstr(inputContent, formatExtensionList[i])) != 0) && (format < LAST_FMT)) { strcpy(substr, formatExtensionList[format]); filenameInput->value(inputContent); dbgprintf("Extension found\n"); break; } } } return; } void savespect::saveFileName(const char *fn) { // this copies it to something more permanent. filenameInput->value(fn); return; } int savespect::doTheSaving() { int retval = 0; dbgprintf("Doing the saving now\n"); // we can't go any further until we have a writexxx procedure... const char *filename = filenameInput->value(); // trivial user-generated possible errors if ((filename == 0) || (filename[0] == '\0')) { errprintf("Please specify a file to save to\n"); return(1); } else { if (access(filename, W_OK) == 0) { // the file already exists static char alrtmsg[1024] ; sprintf(alrtmsg, "File %s already exists\n" "Do you want to overwrite?\n", filename); if (fl_ask(alrtmsg) == 0) { // no, we don't want to overwrite... return(2); } } } switch (formatChoice->value()) { case EURO_FMT: { // this is so simple that I thought there would be // no need to put this in a separate function int nx = 0; if (whichPanel == SPECTRAPANEL) nx = spectraPanel->getNbVal(); else if (whichPanel == PROFILEPANEL) nx = profilePanel->getNbVal(); if (nx > 0) { FILE *spct = fopen(filename, "wb"); if (spct != NULL) { if (whichPanel == SPECTRAPANEL) { double *dbuff= spectraPanel->getData(); fprintf(spct, "%d 1\n", nx); for (int i = 0 ; i < nx ; i++) { fprintf(spct, "%10.5g%c",dbuff[i],(i % 5 == 4)? '\n':' '); } } else if (whichPanel == PROFILEPANEL) { double *rbuff = profilePanel->getDataR(); double *gbuff = profilePanel->getDataG(); double *bbuff = profilePanel->getDataB(); int i; if ((gbuff == 0) && (rbuff != 0)) { fprintf(spct, "%d 1\n", nx); for (i = 0 ; i < nx ; i++) { fprintf(spct, "%10.5g%c",rbuff[i],(i % 5 == 4)? '\n':' '); } } else if ((rbuff != 0) && (gbuff != 0) && (bbuff != 0)) { fprintf(spct, "%d 3\n", nx); for (i = 0 ; i < nx ; i++) { fprintf(spct, "%10.5g%c",rbuff[i],(i % 5 == 4)? '\n':' '); } fprintf(spct, "\n"); for (i = 0 ; i < nx ; i++) { fprintf(spct, "%10.5g%c",gbuff[i],(i % 5 == 4)? '\n':' '); } fprintf(spct, "\n"); for (i = 0 ; i < nx ; i++) { fprintf(spct, "%10.5g%c",bbuff[i],(i % 5 == 4)? '\n':' '); } } } fprintf(spct, "\n"); fclose(spct); } else errprintf("Error in Euro saving code\n" "while writing %s: %s\n", filename, strerror(errno)); } break; } case ZIMAGE_FMT: { int nx[3], ny[3], nz[3], x0[3], y0[3], z0[3], ptype[3]; void *outbuffp[3]; if (whichPanel == SPECTRAPANEL) { if ((nx[0] = spectraPanel->getNbVal()) > 0) { nx[1] = nx[2] = 1; ny[0] = ny[1] = ny[2] = 1; // this is a vector nz[0] = nz[1] = nz[2] = 1; // not a 3D image... x0[0] = x0[1] = x0[2] = 0; y0[0] = y0[1] = y0[2] = 0; z0[0] = z0[1] = z0[2] = 0; ptype[0] = IM_DOUBLE; outbuffp[0] = spectraPanel->getData(); outbuffp[1] = outbuffp[2] = 0; retval = save_zimage(filename, 1, nx, ny, nz, x0, y0, z0, ptype, outbuffp); if (retval != 0) errprintf("Error in Z-IMAGE saving code\n" "while writing %s: %s\n", filename, strerror(errno)); } } else if (whichPanel == PROFILEPANEL) { if ((nx[0] = profilePanel->getNbVal()) > 0) { ny[0] = ny[1] = ny[2] = 1; // this is a vector nz[0] = nz[1] = nz[2] = 1; // not a 3D image... x0[0] = x0[1] = x0[2] = 0; y0[0] = y0[1] = y0[2] = 0; z0[0] = z0[1] = z0[2] = 0; ptype[0] = IM_DOUBLE; outbuffp[0] = profilePanel->getDataR(); outbuffp[1] = profilePanel->getDataG(); outbuffp[2] = profilePanel->getDataB(); if ((outbuffp[0] != 0) && (outbuffp[1] == 0) && (outbuffp[2] == 0)) { nx[1] = nx[2] = 1; retval = save_zimage(filename, 1, nx, ny, nz, x0, y0, z0, ptype, outbuffp); } else if ((outbuffp[0] != 0) && (outbuffp[1] != 0) && (outbuffp[2] != 0)) { nx[1] = nx[2] = nx[0]; ptype[1] = ptype[2] = IM_DOUBLE; retval = save_zimage(filename, 3, nx, ny, nz, x0, y0, z0, ptype, outbuffp); } if (retval != 0) errprintf("Error in Z-IMAGE saving code\n" "while writing %s: %s\n", filename, strerror(errno)); } } break; } case TIFF_FMT: { int pi, sf, spp, bps, nbdata; int pixeltype, imagetype; int start[2], end[2]; void *outbuffp[3]; if (whichPanel == SPECTRAPANEL) { if ((nbdata = spectraPanel->getNbVal()) > 0) { // get the pixtype & imgtype pixeltype = IM_DOUBLE; outbuffp[0] = spectraPanel->getData(); outbuffp[1] = outbuffp[2] = 0; imagetype = IM_SPECTRUM; spp = 1; setTifftype(pixeltype, imagetype, &pi, &sf, &spp, &bps); if (spp != 1) { errprintf("This can't happen: spp(%d) != 1\n", spp); break; } start[0] = 0; end[0] = nbdata -1; start[1] = 0; end[1] = 0; retval = save_tiff(outbuffp, 0, start, end, pi, sf, spp, bps, 0, 0, filename, 0); // always uncompressed } } else { int nbcomps; if ((nbdata = profilePanel->getNbVal()) > 0) { // get the pixtype & imgtype pixeltype = IM_DOUBLE; outbuffp[0] = profilePanel->getDataR(); outbuffp[1] = profilePanel->getDataG(); outbuffp[2] = profilePanel->getDataB(); if ((outbuffp[0] != 0) && (outbuffp[1] == 0) && (outbuffp[2] == 0)) { imagetype = IM_SPECTRUM; nbcomps = 1; setTifftype(pixeltype, imagetype, &pi, &sf, &spp, &bps); } else { imagetype = IM_RGB; nbcomps = 3; setTifftype(pixeltype, imagetype, &pi, &sf, &spp, &bps); } spp = nbcomps; if (spp != nbcomps) { errprintf("This can't happen: spp(%d) != nbcomps(%d)\n", spp, nbcomps); break; } start[0] = 0; end[0] = nbdata -1; start[1] = 0; end[1] = 0; retval = save_tiff(outbuffp, 0, start, end, pi, sf, spp, bps, 0, 0, filename, 0); // always uncompressed } } break; } default: errprintf("This format is not supported yet, sorry!\n"); retval = 5; break; } return retval; } void savespect::show() { saveWindow->show(); } void savespect::hide() { saveWindow->hide(); } // save panel associated callbacks void filenameinput_cb(Fl_Input *, savespect *) { dbgprintf("File name input callback\n"); return; } void browsebutton_cb(Fl_Button *, savespect *panel) { const char *currentfile; static const char *p = 0; dbgprintf("Browse button pressed on save prefs panel\n"); currentfile = panel->filenameInputValue(); switch (panel->selectedFileFormat()) { case EURO_FMT: p = fl_file_chooser("Save to file", "*.[Ee][Uu][Rr][Oo]", currentfile); break; case ZIMAGE_FMT: p = fl_file_chooser("Save to file", "*_z", currentfile); break; case TIFF_FMT: p = fl_file_chooser("Save to file", "*.[tT][iI][fF]*", currentfile); break; default: p = fl_file_chooser("Save to file", "*", currentfile); break; } if (p) panel->saveFileName(p); return; } void formatchoice_cb(Fl_Choice *, savespect *) { dbgprintf("Format choice menu callback\n"); return; } void cancelbutton_cb(Fl_Button *, savespect *panel) { dbgprintf("Cancel Button pressed on save prefs panel\n"); // hide the window panel->hide(); return; } void okbutton_cb(Fl_Return_Button *, savespect *panel) { dbgprintf("Print Button pressed on save prefs panel\n"); if (panel->doTheSaving() == 0) { // hide the window panel->hide(); } return; } // callback for the choice menu void chosenSpectFormat_cb(Fl_Menu_ *, void *fmt) { long val = (long)fmt; switch (val) { case EURO_FMT: dbgprintf("Euro Format selected\n"); break; case ZIMAGE_FMT: dbgprintf("Z-IMAGE format selected\n"); break; case TIFF_FMT: dbgprintf("TIFF format selected\n"); break; } saveSpectPanel->toggleExtension(val); } imview-1.1.9c/saveSpect.hxx0000644000076500007650000000634007653236502016474 0ustar talbottalbot00000000000000/* * $Id: saveSpect.hxx,v 4.0 2003/04/28 14:40:02 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A save spectrum windown class * * Hugues Talbot 28 Aug 1998 * *-----------------------------------------------------------------------*/ #ifndef SAVESPECT_H #define SAVESPECT_H #include #include #include #include #include #include #include #include #include #include #include "imview.hxx" // prototypes for the choice menu void spectrumformat_cb(Fl_Menu_ *, void *); class savespect { public: savespect(); void setDefaults(); int doTheSaving(); void saveFileName(const char *fn); const char *filenameInputValue(void) { return filenameInput->value(); } int selectedFileFormat(void) { return formatChoice->value();} void show(); void hide(); void toggleExtension(int format); void setCompression(int format); void setCallerType(paneltype thisPanel) {whichPanel = thisPanel;} friend Fl_Window *savespect_panel(savespect &s); private: paneltype whichPanel; // in the order in which they appear in fluid // -- The dialog window Fl_Window *saveWindow; // main window // Filename group Fl_Group *inputGroup; Fl_Input *filenameInput; Fl_Button *browseButton; // Choice menus Fl_Choice *formatChoice; // expected buttons... Fl_Button *CancelButton; Fl_Return_Button *OKButton; }; #endif // SAVESPECT_H imview-1.1.9c/server/0000755000076500007650000000000010756342330015304 5ustar talbottalbot00000000000000imview-1.1.9c/server/.cvsignore0000644000076500007650000000003007653237130017300 0ustar talbottalbot00000000000000makedepend *.a *.o .ix* imview-1.1.9c/server/asynchat.cxx0000644000076500007650000001516707660203543017656 0ustar talbottalbot00000000000000/* * $Id: asynchat.cxx,v 4.1 2003/05/13 14:55:31 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ // -*- Mode: C++; tab-width: 4 -*- #include "imview.hxx" #ifdef HAVE_PTHREADS #include "asynchat.hxx" // string allocation issues: // // as much as possible, I want to leave this up to the string class // itself. // // in general, when a user passes in a string object, it belongs to // the user. when the library gives a string to the user, the user // should copy it. // // the only reasonable exception seems to be with the more() method - // these are understood to be temporary strings, and are deleted by // the library. // wait, we want the buffer sizes to be overridable. const unsigned int async_chat::ac_out_buffer_size = 512; const unsigned int async_chat::ac_in_buffer_size = 512; const string async_chat::null_terminator = string(""); void async_chat::set_terminator (const string & t) { terminator = t; } string& async_chat::get_terminator (void) { return terminator; } inline int async_chat::find_prefix_at_end (string haystack, string needle) { int hl = haystack.length(); int nl = needle.length(); for (int i = trivmax (nl-hl, 0); i < nl; i++) { #if (defined(__GNUC__) && (__GNUC__ < 3)) // quirky old gcc if (haystack.compare(needle, hl-(nl-i), nl-i) == 0) { return (nl-i); } #else //most C++ compilers these days if (haystack.compare (0, string::npos, needle, hl-(nl-i), nl-i) == 0) { return (nl-i); } #endif } return 0; } void async_chat::handle_read (void) { char buffer[ac_in_buffer_size]; int result = recv (buffer, ac_in_buffer_size); if (result > 0) { ac_in_buffer.append (buffer, result); // Continue to search for self.terminator in self.ac_in_buffer, // while calling self.collect_incoming_data. The while loop is // necessary because we might read several data+terminator combos // with a single recv(). while (ac_in_buffer.length()) { string terminator = get_terminator(); // special case where we're not using a terminator if (terminator == null_terminator) { collect_incoming_data (ac_in_buffer); ac_in_buffer.erase (); return; } int terminator_len = terminator.length(); int index = ac_in_buffer.find (terminator); // 3 cases: // 1) end of buffer matches terminator exactly: // collect data, transition // 2) end of buffer matches some prefix: // collect data to the prefix // 3) end of buffer does not match any prefix: // collect data if (index != -1) { // we found the terminator collect_incoming_data (ac_in_buffer.substr (0, index)); ac_in_buffer.erase (0, index + terminator_len); found_terminator(); } else { // check for a prefix of the terminator int num = find_prefix_at_end (ac_in_buffer, terminator); if (num) { int bl = ac_in_buffer.length(); // we found a prefix, collect up to the prefix collect_incoming_data (ac_in_buffer.substr (0, bl - num)); ac_in_buffer.erase (0, bl - num); break; } else { // no prefix, collect it all collect_incoming_data (ac_in_buffer); ac_in_buffer.erase(); } } } } } void async_chat::handle_write (void) { srv_internal_dbgprintf("%d: handle_write", fileno); initiate_send(); } void async_chat::send (const string& data) { producer_fifo.push ((producer *) new simple_producer (data)); } void async_chat::send (producer* p) { producer_fifo.push (p); } bool async_chat::readable (void) { srv_internal_dbgprintf("async_chat::readable() buffer.length(): %d", ac_in_buffer.length()); return (dispatcher::readable() && (ac_in_buffer.length() < ac_in_buffer_size)); } bool async_chat::writable (void) { return (ac_out_buffer.length() || producer_fifo.size()); } // refill the outgoing buffer by calling the more() method the first // producer in the queue void async_chat::refill_buffer (void) { while (1) { if (producer_fifo.size()) { producer * p = producer_fifo.front(); srv_internal_dbgprintf("popped producer %p\n", (void*) p); if (!p) { // a NULL producer is a sentinel, telling us to close the channel if (!ac_out_buffer.length()) { srv_internal_dbgprintf("%d: closing because of NULL in producer fifo\n", fileno); producer_fifo.pop(); this->handle_close(); close(); } else { delete p; // << what does this do? delete a NULL pointer? } return; } string* data = p->more(); if (data->length()) { ac_out_buffer.append (*data); delete data; return; } else { srv_internal_dbgprintf("popping fifo\n"); producer_fifo.pop(); delete p; // need to do that Hugues Talbot 2 Mar 2001 delete data; } } else { return; } } } // leaving out the 'more_to_send()' stuff, I think it is now superfluous. void async_chat::initiate_send (void) { if (ac_out_buffer.length() < ac_out_buffer_size) { // try to refill the buffer refill_buffer(); } if (ac_out_buffer.length() && connected) { srv_internal_dbgprintf("%d: sending %d bytes\n", fileno, ac_out_buffer.length()); int num_sent = dispatcher::send (ac_out_buffer.data(), ac_out_buffer.length()); if (num_sent) { ac_out_buffer.erase (0, num_sent); } } } #endif // HAVE_PTHREADS imview-1.1.9c/server/asynchat.hxx0000644000076500007650000001216510632004153017643 0ustar talbottalbot00000000000000/* * $Id: asynchat.hxx,v 4.2 2007/06/07 13:30:19 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ // -*- Mode: C++; tab-width: 4 -*- // ====================================================================== // Copyright 1996 by Sam Rushing // // All Rights Reserved // // Permission to use, copy, modify, and distribute this software and // its documentation for any purpose and without fee is hereby // granted, provided that the above copyright notice appear in all // copies and that both that copyright notice and this permission // notice appear in supporting documentation, and that the name of Sam // Rushing not be used in advertising or publicity pertaining to // distribution of the software without specific, written prior // permission. // // SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN // NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS // OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, // NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // ====================================================================== #ifndef ASYNCHAT_H #define ASYNCHAT_H #include #include #include #include #include "imnmspc.hxx" // namespace def, if any req. #include "asyncore.hxx" using std::list; //using std::queue; // =========================================================================== // producer and simple_producer // =========================================================================== class producer { public: virtual ~producer() { /* necesary */ } virtual string* more (void) = 0; }; class simple_producer : public producer { string data; public: simple_producer (const string& output_string) { data = output_string; } string* more (void) { string * slice = new string (data.substr (0,512)); int l = data.length(); // some string implementations are more fragile than others if (l > 512) data.erase (0,512); else if (l > 0) data.erase(); // the whole string return slice; } }; // =========================================================================== // async_chat // =========================================================================== class async_chat : public dispatcher { string ac_in_buffer; string ac_out_buffer; string terminator; std::queue producer_fifo; static const unsigned int ac_in_buffer_size; static const unsigned int ac_out_buffer_size; static const string null_terminator; inline int find_prefix_at_end (string haystack, string needle); public: virtual ~async_chat(void) { /* necessary */ } virtual void set_terminator (const string & t); virtual string& get_terminator (void); virtual void collect_incoming_data (const string& data) { } ; virtual void found_terminator (void) { } ; virtual void send (const string& data); virtual void send (producer* p); void handle_read (void); void handle_write (void); bool readable (void); bool writable (void); void refill_buffer (void); void initiate_send (void); void close_when_done (void) { producer_fifo.push ((producer *) 0); } }; #endif // ASYNCHAT_H imview-1.1.9c/server/asyncore.cxx0000644000076500007650000002406510364220670017657 0ustar talbottalbot00000000000000/* * $Id: asyncore.cxx,v 4.1 2006/01/20 17:45:28 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ // -*- Mode: C++; tab-width: 4 -*- // first hack at a C++ version of asyncore eventually will support // files also (read/write rather than recv/send) // in python, we're really doing a derivation from a builtin socket _class_, // we might eventually want to reflect here... // TODO: // have all socket-related functions assert that the socket has not // been closed. [a read event may close it, and a write event may try // to write or something...] // Maybe assert valid fileno, too? #include "imnmspc.hxx" // name space definition etc. #include "imview.hxx" #ifdef HAVE_PTHREADS #include "asyncore.hxx" socket_map dispatcher::channels; // empty, pure virtual dispatcher dispatcher::~dispatcher() { } void dispatcher::add_channel () { channels[fileno] = this; } bool dispatcher::create_socket (int family, int type, int protocol) { int result = socket (family, type, protocol); if (result != -1) { set_blocking (0); fileno = result; srv_dbgprintf("dispatcher::create_socket: new socket fd=%d\n", result); add_channel(); } return (result != -1); } void dispatcher::set_fileno (int fd, bool is_connected) { fileno = fd; connected = is_connected; add_channel(); } #ifndef WIN32_NOTCYGWIN // unix version #include void dispatcher::set_blocking (bool blocking) { int flag; flag = ::fcntl (fileno, F_GETFL, 0); if (blocking) { flag &= (~O_NDELAY); } else { flag |= (O_NDELAY); } ::fcntl (fileno, F_SETFL, flag); } #else void dispatcher::set_blocking (bool blocking) { u_long b = blocking; ioctlsocket(fileno, FIONBIO, &b); } #endif int dispatcher::bind (struct sockaddr * addr, size_t length) { return ::bind (fileno, addr, length); } int dispatcher::listen (unsigned int n) { // *** assert valid fileno accepting = 1; return ::listen (fileno, n); } int dispatcher::accept (struct sockaddr * addr, size_t * length_ptr) { #ifdef ACCEPT_USES_SOCKLEN_T // this is EXTREMELY annoying, but apparently the right thing to do... return ::accept (fileno, addr, (socklen_t *)length_ptr); #else return ::accept (fileno, addr, (int*)length_ptr); #endif } int dispatcher::connect (struct sockaddr * addr, size_t length) { int result = ::connect (fileno, addr, length); if (result == 0) { connected = 1; this->handle_connect(); return 0; } else if (is_nonblocking_error (result)) { return 0; } else { // some other error condition return -1; } } int dispatcher::send (const char * buffer, size_t size, int flags) { int result; #ifndef WIN32_NOTCYGWIN if (!flags) { // this allows us to use non-sockets with the library result = ::write (fileno, buffer, size); } else { result = ::send (fileno, buffer, size, flags); } #else result = ::send (fileno, buffer, size, flags); #endif if ((size_t)result == size) { // everything was sent write_blocked = 0; return result; } else if (result >= 0) { // not all of it was sent, but no error write_blocked = 1; return result; } else if (is_nonblocking_error (result)) { write_blocked = 1; return 0; } else { this->handle_error (result); this->handle_close (); close(); closed = 1; return -1; } } int dispatcher::recv (char * buffer, size_t size, int flags) { int result; #ifndef WIN32_NOTCYGWIN if (!flags) { // this allows us to use non-sockets with the library result = ::read (fileno, buffer, size); } else { result = ::recv (fileno, buffer, size, flags); } #else result = ::recv (fileno, buffer, size, flags); #endif if (result > 0) { return result; } else if (result == 0) { closed = 1; this->handle_close(); return 0; } else if (is_nonblocking_error (result)) { return 0; } else { this->handle_error (result); this->handle_close(); close(); closed = 1; return -1; } } void dispatcher::close (void) { #ifdef WIN32_NOTCYGWIN srv_internal_dbgprintf("closing channel #%d\n", fileno); ::closesocket (fileno); #else int res; srv_internal_dbgprintf("closing channel #%d\n", fileno); res = ::close (fileno); if (res < 0) srv_dbgprintf("Fileno %d not closed: %s\n", fileno, strerror(errno)); else srv_dbgprintf("Fileno %d closed properly\n", fileno); #endif closed = 1; return; } void dispatcher::handle_read_event (void) { if (accepting) { if (!connected) { connected = 1; } this->handle_accept(); } else if (!connected) { this->handle_connect(); connected = 1; this->handle_read(); } else { this->handle_read(); } } void dispatcher::handle_write_event (void) { if (!connected) { this->handle_connect(); connected = 1; } write_blocked = 0; this->handle_write(); } // ================================================== // static functions // ================================================== void dispatcher::dump_channels (void) { cerr << "["; socket_map::const_iterator i; for (i = channels.begin(); i != channels.end(); i++) { if (i != channels.begin()) { cerr << ":"; } cerr << ((*i).first); } cerr << "]" << endl; } #include void dispatcher::delete_closed_channels () { // I'd prefer to use remove_if. list hospice; for (socket_map::iterator i = channels.begin(); i != channels.end(); i++) { if (((*i).second)->closed) { srv_dbgprintf("Channel being deleted now\n"); hospice.push_front ((*i).first); } } for (list::iterator h = hospice.begin(); h != hospice.end(); h++) { channels.erase (*h); } } void dispatcher::poll (struct timeval * timeout) { if (channels.size()) { fd_set r,w; socket_map::iterator i; FD_ZERO (&r); FD_ZERO (&w); int num = 0; delete_closed_channels(); if (!channels.size()) { srv_internal_dbgprintf("socket map is empty, should be shutting down\n"); return; } srv_internal_dbgprintf("\a"); for (i = channels.begin(); i != channels.end(); i++) { int fd = (*i).first; if (((*i).second)->readable()) { FD_SET (fd, &r); num++; srv_internal_dbgprintf(" r %d", fd); } if (((*i).second)->writable()) { FD_SET (fd, &w); num++; srv_internal_dbgprintf(" w %d", fd); } } srv_internal_dbgprintf("\b"); if (!num) { srv_internal_dbgprintf("selecting() on no channels, should be shutting down %d FD's set\n", num); return; } srv_internal_dbgprintf("calling select() with %d FD's set\n", num); // It bothers me that select()'s first argument does not appear to // work as advertised... [it hangs like this if called with // anything less than FD_SETSIZE, which seems wasteful?] // Note: we ignore the 'exception' fd_set - I have never had a // need to use it. The name is somewhat misleading - the only // thing I have ever seen it used for is to detect urgent data - // which is an unportable feature anyway. // int n = ::select (channels.size() + 1, &r, &w, 0, timeout); int n = ::select (FD_SETSIZE, &r, &w, 0, timeout); srv_internal_dbgprintf("select : %d, channels.size() %d\n", n, channels.size()); // [we're also trusting it to count down channels in order to quit iterating] for (i = channels.begin(); (i != channels.end() && n); ++i) { int fd = (*i).first; if (FD_ISSET (fd, &r)) { ((*i).second)->handle_read_event(); n--; } if (FD_ISSET (fd, &w)) { ((*i).second)->handle_write_event(); n--; } } } } // do only one loop int dispatcher::loop1(struct timeval * timeout) { if (channels.size()) { poll(timeout); return 1; } else return 0; // no channel left } void dispatcher::loop (struct timeval * timeout) { while (channels.size()) { poll (timeout); } } #endif // HAVE_PTHREADS imview-1.1.9c/server/asyncore.hxx0000644000076500007650000001716410364220670017666 0ustar talbottalbot00000000000000/* * $Id: asyncore.hxx,v 4.2 2006/01/20 17:45:28 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ // -*- Mode: C++; tab-width: 4 -*- // ====================================================================== // Copyright 1996 by Sam Rushing // // All Rights Reserved // // Permission to use, copy, modify, and distribute this software and // its documentation for any purpose and without fee is hereby // granted, provided that the above copyright notice appear in all // copies and that both that copyright notice and this permission // notice appear in supporting documentation, and that the name of Sam // Rushing not be used in advertising or publicity pertaining to // distribution of the software without specific, written prior // permission. // // SAM RUSHING DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN // NO EVENT SHALL SAM RUSHING BE LIABLE FOR ANY SPECIAL, INDIRECT OR // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS // OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, // NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN // CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // ====================================================================== // // slightly hacked by Hugues Talbot 29 Feb 2000 // made it run with (more) standard C++ under gcc-2.95 // changed the style somewhat // relied on mingw32 for WIN32 functionality: fewer #ifdef WIN32 // #ifndef ASYNCORE_H #define ASYNCORE_H // C++ version of asyncore // Getting STL to work on multiple platforms can be quite a challenge, // swimming in a sea of renamed and duplicated headers... #include #ifdef WIN32_NOTCYGWIN # include # undef min # undef max #else # include # include # include # include #endif #include "imunistd.h" #ifdef HAVE_SYS_TIME_H # include #else # include // typically windows will be like that. #endif #include #include #include #include #include #include "imnmspc.hxx" #include "imview.hxx" using std::map; using std::string; using std::list; using std::less; using std::cerr; using std::endl; // horrible hack extern int debugIsOn; extern int serverDebug; #define sdebug if (serverDebug) cerr << "Server> " #define cdebug if (debugIsOn) cerr << "imview-server> " class dispatcher; typedef map > socket_map; class dispatcher { protected: int fileno; bool accepting, connected, closed, write_blocked; public: // constructor dispatcher () { fileno = 0; accepting = 0; connected = 0; closed = 0; write_blocked = 0; } // virtual dispatcher, needed since the class // contains virtual methods. Also non-pure since dispatcher // is used as a base class :-( virtual ~dispatcher () = 0; static bool is_nonblocking_error (int error); // static functions [relevant to the active socket map] static socket_map channels; static void dump_channels (void); static void poll (struct timeval * timeout = 0); static int loop1(struct timeval * timeout); static void loop (struct timeval * timeout = 0); static void delete_closed_channels (); void add_channel(); bool is_closed(void) { return closed; } bool is_accepting(void) { return accepting; } void reopen_channel(void) { closed = 0; } int get_fileno () { return fileno; } // select() eligibility predicates virtual bool readable (void) { return (connected || accepting); } virtual bool writable (void) { return (!connected || write_blocked); } void set_blocking (bool blocking); // -------------------------------------------------- // socket methods // -------------------------------------------------- bool create_socket (int family, int type, int protocol = 0); void set_fileno (int fd, bool is_connected = 1); int bind (struct sockaddr * addr, size_t length); int listen (unsigned int n); int accept (struct sockaddr * addr, size_t * length_ptr); int connect (struct sockaddr * addr, size_t length); int send (const char * buffer, size_t size, int flags = 0); int recv (char * buffer, size_t size, int flags = 0); void close (void); // -------------------------------------------------- // event handlers // -------------------------------------------------- void handle_read_event (void); void handle_write_event (void); // These are meant to be overridden. virtual void handle_connect (void) { cerr << fileno << ":unhandled connect" << endl; } virtual void handle_read (void) { cerr << fileno << ":unhandled read" << endl; } virtual void handle_write (void) { cerr << fileno << ":unhandled write" << endl; } virtual void handle_close (void) { cerr << fileno << ":unhandled close" << endl; } virtual void handle_accept (void) { cerr << fileno << ":unhandled accept" << endl; } #ifdef WIN32_NOTCYGWIN virtual void handle_error (int error) { cerr << fileno << ":unhandled error:" << error << " winsock error: " << WSAGetLastError() << endl; } #else virtual void handle_error (int error) { cerr << fileno << ":unhandled error:" << error << " error: " << strerror(errno) << endl; } #endif }; #ifndef WIN32_NOTCYGWIN inline bool dispatcher::is_nonblocking_error (int error) { switch (errno) { case EWOULDBLOCK: // always == EAGAIN? case EALREADY: case EINPROGRESS: return true; default: return false; } } #else inline bool dispatcher::is_nonblocking_error (int error) { switch (WSAGetLastError()) { case WSAEWOULDBLOCK: case WSAEALREADY: case WSAEINPROGRESS: return true; break; default: return false; } } #endif #endif // ASYNCORE_H imview-1.1.9c/server/config.h.in0000644000076500007650000000157307653237131017341 0ustar talbottalbot00000000000000/* config.h.in. Generated automatically from configure.in by autoheader. */ /* Define to empty if the keyword does not work. */ #undef const /* Define as the return type of signal handlers (int or void). */ #undef RETSIGTYPE /* Define to `unsigned' if doesn't define. */ #undef size_t /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define if you have the select function. */ #undef HAVE_SELECT /* Define if you have the socket function. */ #undef HAVE_SOCKET /* Define if you have the strdup function. */ #undef HAVE_STRDUP /* Define if you have the strerror function. */ #undef HAVE_STRERROR /* Define if you have the strtol function. */ #undef HAVE_STRTOL /* Define if you have the header file. */ #undef HAVE_FCNTL_H imview-1.1.9c/server/configure.in0000644000076500007650000000070707653237131017625 0ustar talbottalbot00000000000000dnl Process this file with autoconf to produce a configure script. AC_INIT(asynchat.C) dnl Checks for programs. AC_PROG_CC dnl Checks for libraries. dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(fcntl.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_TYPE_SIZE_T AC_HEADER_TIME dnl Checks for library functions. AC_TYPE_SIGNAL AC_CHECK_FUNCS(select socket strdup strerror strtol) AC_OUTPUT(Makefile) imview-1.1.9c/server/imserver.cxx0000644000076500007650000004716210364220670017673 0ustar talbottalbot00000000000000/* * $Id: imserver.cxx,v 4.5 2006/01/20 17:45:28 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Imview as an image server!! * * Uses the async library by Sam Rushing. * * Basically the idea is to be able to embed imview more easily. * * Hugues Talbot 29 Feb 2000 * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" #include "imview.hxx" #ifdef HAVE_PTHREADS // otherwise don't even bother #include #include // malloc and friends #include #include "imserver.hxx" #include "imageIO.hxx" #include "io/newprefio.hxx" //--------- only one server extern imview_server *is; extern interpreter *imview_interpreter; extern imageIO *IOBlackBox; extern imprefs *fileprefs; extern bool server_terminate; extern bool darwinChild; extern int portfileDescriptor; extern volatile int serverPortNumber; extern volatile bool im_draw_finished; extern volatile bool hasSynced; extern double simple_progress; extern char portfilename[]; imview_server::imview_server() { dco = 0; // no data channel opener in the beginning. } // not sure this is necessary? imview_server::~imview_server() { imview_channel *c; dbgprintf("imview server destructor called\n"); while (!lc.empty()) { c = lc.front(); delete c; lc.pop_front(); } delete dco; // delete the data channel opener dco = 0; } void imview_server::handle_accept (void) { struct sockaddr addr; size_t addr_len = sizeof(sockaddr); imview_channel *jc; srv_dbgprintf("imview server: handle_accept\n"); int fd = dispatcher::accept (&addr, &addr_len); jc = new imview_channel; jc->set_fileno (fd); jc->set_terminator ("\n"); //jc->send(IMPROMPT); // remember it lc.push_back(jc); } datachannel_opener::~datachannel_opener(void) { imview_data *d; srv_dbgprintf("Data channel destructor called\n"); while (!ld.empty()) { d = ld.front(); delete d; ld.pop_front(); } } void datachannel_opener::handle_accept(void) { struct sockaddr addr; size_t addr_len = sizeof(sockaddr); imview_data *jd; srv_dbgprintf("datachannel opener: open_data_channel\n"); int fd = dispatcher::accept(&addr, &addr_len); srv_dbgprintf("New fd for data channel = %d\n", fd); jd = new imview_data; jd->set_fileno(fd); // remember it ld.push_back(jd); return; } // open another socket for the binary data. // int imview_server::open_data_channel(string &s) { int port, endport; int rescreate, resbind, reslisten; struct sockaddr_in addr; port = 0; if (dco == 0) { // create a new one dco = new datachannel_opener; dco->setparent(this); } if (dco->is_closed()) { // reopen the channel dco->reopen_channel(); } if (!dco->is_accepting()) { port = port_start + 1; // data ports interleaved with command ports srv_dbgprintf("Opening data channel\n"); if ((rescreate = dco->create_socket (AF_INET, SOCK_STREAM)) < 0) { s = "Could not create socket: "; s += strerror(errno); return -1; } addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl (INADDR_ANY); endport = port + 100; while (port < endport) { addr.sin_port = htons (port); if ((resbind = dco->bind ((struct sockaddr *) &addr, sizeof (addr))) < 0) { srv_dbgprintf("Could not bind socket: %s\n", strerror(errno)); } else { srv_dbgprintf("Binding to port: %d\n", port); break; } port += 2; } if (( reslisten = dco->listen (5)) < 0) { s = "Could not listen to socket: "; s += strerror(errno); return -2; } // all went well, remember the port dco->setport(port); } else { // port already exist, is open and accepting connections. port = dco->port(); } // if all went well return port; } // This is a strong action. The closed // channel will not be available for several minutes! (TCP_WAIT) int imview_server::close_data_channel(void) { if (dco) { dco->close(); // this will shutdown the socket //delete dco; //dco = 0; } return 0; } // called by the server thread void imview_server::manage_results(void) { CLI p; // check all the result channels... for (p = lc.begin(); p != lc.end() ; p++) { if (!(*p)->result_isempty()) { // send the result through the socket srv_dbgprintf("sending result throught the socket\n"); (*p)->sendResult(); } } } // called by the GUI thread void imview_server::manage_commands(void) { CLI p; string aCommand, aResult; // check all the command channels... for (p = lc.begin(); p != lc.end() ; p++) { if (!(*p)->command_isempty()) { // evaluate the command aCommand = (*p)->read_command(); imview_interpreter->parseCommand(aCommand, aResult); // we don't write the result yet dbgprintf("Result to be printed: %s\n", aResult.c_str()); (*p)->write_result(aResult); // atomic // that's it... } } return; } //------------ the data channels int imview_data::channels_id(0); imview_data::imview_data(void) { abort = false; identifier = channels_id++; comm_bufsize = IBFSIZE; // initial buffer size... recv_bufsize = IBFSIZE; received = 0; // nothing received yet! expected = 0; recv_buffer = (char *) malloc(recv_bufsize * sizeof(char)); comm_buffer = (char *) malloc(recv_bufsize * sizeof(char)); if ((recv_buffer == 0) || (comm_buffer == 0)) { cerr << "Buffer reception will fail!\n" ; abort = true; // we won't be able to receive anything. } } // // OK, the non-freeing of recv_buffer requires an explanation: // this buffer is passed to the GUI as the buffer that has received the // data. It is copied into the image header and freed when the GUI // closes the image. Any other mechanism requires an extra memcpy. imview_data::~imview_data(void) { /* free(recv_buffer); DON'T free this buffer. The application will do it! */ /* free(comm_buffer); DON'T free this buffer, it gets freed at the end of the transfer! */ return; } void imview_data::handle_connect(void) { srv_dbgprintf("Data channel #%d connection\n", identifier); return; } void imview_data::handle_read(void) { int result; srv_dbgprintf("Data channel #%d reading...\a", identifier); if (!abort) { result = recv(comm_buffer, comm_bufsize); if (result > 0) { srv_dbgprintf("received %d bytes ", result); // put the result at the end of the bits already received... assert(recv_bufsize != 0); // this would be a disaster. if ((result + received) > recv_bufsize) { srv_dbgprintf("Reallocating buffer ", result); if (expected != 0) { // realloc to exactly the needed size recv_buffer = (char *)realloc(recv_buffer, expected * sizeof(char)); recv_bufsize = expected; } else { // realloc to double the size recv_buffer = (char *)realloc(recv_buffer, recv_bufsize * 2 * sizeof(char)); recv_bufsize *= 2; } if (recv_buffer != 0) { srv_dbgprintf("New size = %d ", recv_bufsize); } else { // risky but interesting stderrprintf("Upload realloc failed! not enough memory\n" "Aborting transfer"); abort = true; handle_close(); return ; } } // copy the data to the buffer memcpy(recv_buffer + received, comm_buffer, result); received += result; srv_dbgprintf("moved... ", result); // set progress report if (expected == 0) { if (received >= HEADER_ID_SIZE) { int *id = (int *)recv_buffer; // this call is protected IMAGE_HEADER *img = IOBlackBox->findHeader(*id); if (img != 0) expected = img->expected_size; } srv_dbgprintf("\b"); } // check again: note, expected should NOT be 0 now if (expected != 0) { simple_progress = (100.0 * (double)received)/((double)expected); srv_dbgprintf("progress = %4.1f%%\b", simple_progress); if (received == expected) { srv_dbgprintf("Transfer completed\n"); // last handshake in fact IS necessary for very small buffers dispatcher::send("THE END\n", 8, 0); // close(); // no need to do anything else handle_close(); return; } } // handshake dispatcher::send(HNDSHK, HSLEN, 0); } else { // usually this is OK, really srv_dbgprintf("Recv error: %s\n", strerror(errno)); } } return; } void imview_data::handle_write(void) { srv_dbgprintf("Data channel #%d writing\n", identifier); return; } void imview_data::handle_close(void) { srv_dbgprintf("Data channel #%d closing\n", identifier); srv_dbgprintf("Received: %d bytes\n", received); if (!abort) { srv_dbgprintf("Making callback now\n"); // tell interpreter to do something with the buffer now put::callback(recv_buffer, received); } else { srv_dbgprintf("The upload was aborted for some reason\n"); // realloc the memory to a useable size recv_buffer = (char *)realloc(recv_buffer, IBFSIZE * sizeof(char)); if (recv_buffer != NULL) recv_bufsize = IBFSIZE; else { srv_dbgprintf("\n" "*** Realloc failed when allocating a very small buffer\n" "*** almost surely this indicates a memory management problem\n"); recv_bufsize = 0; // This is sure to create problems later on. } // delete the header... } // freeing the comm_buffer free(comm_buffer); comm_buffer = 0; // closing the channel dispatcher::close(); // will this work? srv_dbgprintf("Channel %d closed\n", identifier); return; } //------------ Many command channels per server // initializes class variable int imview_channel::channels_id(0); imview_channel::imview_channel(void) : async_chat() { identifier = channels_id++; srv_dbgprintf("New channel constructed, id=%d, semaphores allocated\n", identifier); semaphore_init(&access_command); semaphore_init(&access_result); logged_in = false; // no command will work except USER } imview_channel::~imview_channel(void) { srv_dbgprintf("Channel %d destroyed, semaphore deleted\n", identifier); semaphore_destroy(&access_command); semaphore_destroy(&access_result); } void imview_channel::protect_command(void) { semaphore_down(&access_command); return; } void imview_channel::unprotect_command(void) { semaphore_up(&access_command); return; } void imview_channel::write_command(string &c) { protect_command(); commandBuffer.push_back(c); unprotect_command(); return; } string &imview_channel::read_command(void) { // note that cs is an instance variable protect_command(); cs = commandBuffer.front(); commandBuffer.pop_front(); unprotect_command(); return cs; } bool imview_channel::command_isempty(void) { bool res; protect_command(); res = commandBuffer.empty(); unprotect_command(); return res; } void imview_channel::protect_result(void) { semaphore_down(&access_result); return; } void imview_channel::unprotect_result(void) { semaphore_up(&access_result); return; } void imview_channel::write_result(string &c) { protect_result(); resultBuffer.push_back(c); unprotect_result(); return; } string &imview_channel::read_result(void) { protect_result(); rs = resultBuffer.front(); resultBuffer.pop_front(); unprotect_result(); return rs; } bool imview_channel::result_isempty(void) { bool res; protect_result(); res = resultBuffer.empty(); unprotect_result(); return res; } void imview_channel::sendResult(void) { string &c = read_result(); // atomic string sc = c.substr(0,7); // check for log in keywork // check for session-terminating string if (c == "Bye!\n") { srv_dbgprintf("Closing connection %d\n", identifier); logged_in = false; close(); // end of connection. } else if ( sc == "Welcome" ) { logged_in = true; // all commands will go through now srv_dbgprintf("Logged in now\n"); send(c); //send(IMPROMPT); } else { srv_dbgprintf("About to be sent: %s\n", c.c_str()); send(c); //send(IMPROMPT); } return; } void imview_channel::handle_close (void) { srv_dbgprintf("Channel closing\n"); } void imview_channel::collect_incoming_data (const string& data) { int counter = 0; srv_dbgprintf("From: %d, received %s\n", identifier, data.c_str()); while (!hasSynced) { srv_dbgprintf("Waiting for sync\n"); #ifndef WIN32_NOTCYGWIN myusleep(10000); #else _sleep(1); #endif } srv_dbgprintf("Waiting on display\a", counter); while (!im_draw_finished && (++counter < 100)) { #ifndef WIN32_NOTCYGWIN myusleep(1000); #else _sleep(1); #endif } input_buffer.append (data); } void imview_channel::found_terminator (void) { if (input_buffer.length()) { string sc = input_buffer.substr(0,4); // if not logged in, the only command we check for // is `user' if (logged_in || (cmp_nocase(sc, "USER") == 0) || (cmp_nocase(sc, "QUIT") == 0) || (cmp_nocase(sc, "EXIT") == 0)) { // write the string to the common buffer write_command(input_buffer); // this is atomic } else { string as = "deny\r\n"; write_command(as); } // send("Well received: " + input_buffer + "\n"); // send(IMPROMPT); input_buffer.erase(); } } #ifdef WIN32_NOTCYGWIN void init_winsock (void) { WSADATA wd; WSAStartup (MAKEWORD (1,1), &wd); } #endif // This function is meant to be called as a separate thread. void *init_server(int *portnumber) { int port, endport; int rescreate, resbind, reslisten; struct sockaddr_in addr; struct timeval tv; double wp; // create the server! is = new imview_server; #ifdef WIN32_NOTCYGWIN init_winsock(); #endif if (!portnumber) { port = PORTNB; // why not } else { port = *portnumber; } // useful to remember the `prototype' port is->setport(port); if ((rescreate = is->create_socket (AF_INET, SOCK_STREAM)) < 0) { errprintf("Could not create socket: %s", strerror(errno)); return (void*)1; } addr.sin_family = AF_INET; addr.sin_addr.s_addr = htonl (INADDR_ANY); endport = port + 100; while (port < endport) { addr.sin_port = htons (port); if ((resbind = is->bind ((struct sockaddr *) &addr, sizeof (addr))) < 0) { srv_dbgprintf("Could not bind to socket: %s\n", strerror(errno)); } else { srv_dbgprintf("Binding to port: %d\n", port); // report to the command line // the file was opened before the server was started. srv_dbgprintf("Writing port number to a file or a pipe\n"); if (portfileDescriptor >= 0) { // note that the port number is NOT a short here. int nbw = write(portfileDescriptor, &port, sizeof(int)); if (nbw < 0) { srv_dbgprintf("Writing port number failed: %s\n", strerror(errno)); } close(portfileDescriptor); // will flush the file } else if (darwinChild) { // write to standard error write(2, &port, sizeof(int)); } else { srv_dbgprintf("Port: %d\n", port); // just print the port name printf("Port: %d\n", port); } break; } port += 2; } if (( reslisten = is->listen (5)) < 0) { errprintf("Could not listen to socket: %s", strerror(errno)); } srv_dbgprintf("Port number %d saved to global variable\n", port); serverPortNumber = port; tv.tv_sec = 0; // that's right, 0.01 sec. tv.tv_usec = 10000; // I misunderstood what it meant originally. while (dispatcher::loop1(&tv) && !server_terminate) { // basically dumps the content of the result channels through the socket is->manage_results(); if (fileprefs) wp = fileprefs->pollFrequency(); else wp = 100; // reset tv, necessary for Linux tv.tv_sec = 0; // assumption is that wp > 1Hz tv.tv_usec = int(1e6/wp); // controllable amount of time. pthread_testcancel(); } // if we arrive at this point, no sockets are left open if (!server_terminate) { srv_dbgprintf("No more sockets active, shutting down server\n"); pthread_exit((void *)1); } else { srv_dbgprintf("server terminated normally\n"); //pthread_exit((void *)0); } //pthread_debug(); // close server and delete everything is->close(); delete is; is = 0; return (void*)0; } #endif // HAVE_PTHREADS imview-1.1.9c/server/imserver.hxx0000644000076500007650000001221110364220670017663 0ustar talbottalbot00000000000000/* * $Id: imserver.hxx,v 4.1 2006/01/20 17:45:28 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * imserver.H * * The image server part of imview. * * Hugues Talbot 1 Mar 2000 * *-----------------------------------------------------------------------*/ #ifndef IMSERVER_H #define IMSERVER_H #include "asynchat.hxx" #include "semaphore.hxx" #include "interpreter.hxx" #include "machine.hxx" #define IMPROMPT "Imview > " #define HNDSHK "OK\n" #define HSLEN 3 #define PORTNB 7600 // mt is a pointer to a function taking void * as input and returning a void* typedef void *(*mt)(void *); // cb_func is a pointer to a function taking a void*+ulong as input and returning int. typedef int(*cb_func)(void *, unsigned long); void *init_server(int *); #define IBFSIZE 8196 // A channel for binary data upload class imview_data : public dispatcher { private: int identifier; unsigned long comm_bufsize, recv_bufsize; unsigned long received, expected; char *recv_buffer, *comm_buffer; bool abort; // class variable static int channels_id; public: imview_data(); virtual ~imview_data(); void handle_connect(); void handle_read(); void handle_write(); void handle_close(); }; // A channel has all what's needed for command communication. class imview_channel : public async_chat { string input_buffer; string cs, rs; int identifier; list commandBuffer; list resultBuffer; bool logged_in; Semaphore access_command, access_result; // class variable static int channels_id; public: imview_channel(); virtual ~imview_channel(); // commands void protect_command(void); void unprotect_command(void); void write_command(string &c); string& read_command(void); bool command_isempty(void); // results. void protect_result(void); void unprotect_result(void); void write_result(string &r); string& read_result(void); bool result_isempty(void); // socket comm void sendResult(void); void collect_incoming_data (const string& data); void found_terminator (void); // the handle methods void handle_close (void); }; class imview_server; // this class only serves to open a data channel // this is necessary because it's impossible to find out // where an `accept' is coming from. class datachannel_opener:public dispatcher { private: list ld; // list of data channels imview_server *parent; // parent server int port_id; // our private port. public: virtual ~datachannel_opener(void); void handle_accept(void); void setparent(imview_server *p) {parent = p;} void setport(int v) {port_id = v;} int port(void) {return port_id;} }; typedef list::const_iterator CLI; // list iterator class imview_server : public dispatcher { private: list lc; // list of command channels int port_start; // even ports: command, odd ports: data. datachannel_opener *dco; // only one of them! public: imview_server(); virtual ~imview_server(); void handle_accept (void); int open_data_channel(string &s); int close_data_channel(void); void manage_results(void); void manage_commands(void); void setport(int p) { port_start = p; } }; #endif //IMSERVER_H imview-1.1.9c/server/imshared.cxx0000644000076500007650000007647307653237131017651 0ustar talbottalbot00000000000000/* * $Id: imshared.cxx,v 4.0 2003/04/28 14:44:41 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * This is a re-implementation of the `put' command, to put up an * image on to ImView via socket I/O, this time using SYSV shared * memory mechanism. * * Obviously this is complementary to the pure socket I/O mechanism. * Shared memory can only work when both server and client are on the * same host. However, it is much faster. * * Messages are passed using Socket I/O, only the data transfer uses * shared memory. This mechanism is meant to be almost transparent to * the client. The only difference is the command (`putm' instead of `put') * and the response. * * Hugues Talbot 26 Mar 2000 * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" #include "imview.hxx" #ifdef HAVE_PTHREADS #include "imageIO.hxx" #include "pointfile.hxx" #include "interpreter.hxx" #include "imshared.hxx" extern imview_server *is; extern interpreter *imview_interpreter; extern pointfile *PtFileMngr; extern imageIO *IOBlackBox; extern volatile bool syncDisplay; extern volatile bool im_draw_finished; #ifdef HAVE_SYSV_IPC char putm::ref_pathname[L_tmpnam+1]; // definition. putm::putm() { char idsem; char *retpath; FILE *unique_fd; shm_setup_ok = false; // sh_mem not set up yet sem_setup_ok = false; // pessimistically, we think things will go wrong // set up the semaphores, though idsem = 'A'; if (ref_pathname[0] == '\0') { retpath = tmpnam(ref_pathname); if (retpath == NULL) { dbgprintf("putm::putm: could not secure unique temporary file name. This is not good\n"); strncpy(ref_pathname, FPATH1, L_tmpnam); // last ditch effort... } } // else the temporary file name is assumed to exist. // open the file and close it. if ((unique_fd = fopen(ref_pathname, "a")) != NULL) { fprintf(unique_fd, "%d\n", (int)(getpid())); // and why not? fclose(unique_fd); // creates the file. } else { dbgprintf("putm::putm: Unique file could not be created. Semaphore set creation will fail\n"); return; } if ((sem_key = ftok(ref_pathname, idsem)) == -1) { dbgprintf("putm::putm: Could not get sem_key, %s\n", strerror(errno)); return; } /* create a semaphore set with 3 semaphores: */ /* the first is for the clients access to the shared memory (between clients) */ /* the second is for read access and the last for write access */ if ((semid = semget(sem_key, 3, 0666 | IPC_CREAT)) == -1) { dbgprintf("putm::putm: Could not get sem ID, %s\n", strerror(errno)); return; // could not get ID } if (!sem_reset()) // set semaphores in a predictable state. sem_setup_ok = true; // we can proceed data = 0; } putm::~putm() { union semun arg; // can't do with 'em, useless though. // remove the temporary file name unlink(ref_pathname); // who cares if it fails? arg.val = 0; // serves no purpose except shutting up some compiler warnings // get rid of semaphore and shared memory segment, if necessary /* remove semaphore anyway */ if (semctl(semid, 0, IPC_RMID, arg) == -1) { dbgprintf("putm: could not get rid of semaphore: %s\n", strerror(errno)); // don't return right now, try to get rid of the shared memory. } if (shm_setup_ok) { // detach shared memory segment if (shmdt(data) == -1) { dbgprintf("putm: could not detach shared memory: %s\n", strerror(errno)); return; } // try to destroy the memory segment if (shmctl(shmid, IPC_RMID, 0) == -1 ) { dbgprintf("putm: could not remove shared memory segment, %s\n", strerror(errno)); return; } } return; } // in contrast to put::perform, this call has // no callback associated with it. It will block until // the client puts up the data, or until timeout (a few seconds). int putm::perform(vector &l, string &result) { int i, j, ret, expected_size; int so_far = 0; char *newlabel; size_t exp_nb; ostringstream sres; IMAGE_HEADER *img, *previmg; dbgprintf("Data transfer using Unix SysV style shared memory\n"); if (!sem_setup_ok) { result = "Internal semaphore handling failed. shared memory put not available\n"; return 1; } if (l.size() > 3) { ret = 0; img = new IMAGE_HEADER; img->label = 0; // this is important, as otherwise find_header will choke on an invalid pointer img->needswap = 0; // coming from the same host, so we never need to swap the byte order of the data imh.push_back(img); // imh belong to put::, the parent class // fill the header newlabel = strdup(l[0].c_str()); // find out if there is another header with the same // name in use already. If so it will have to be delete // if the data transmission goes fine. dbgprintf("Looking for previous header with same label: %s\n", newlabel); previmg = put::find_header(newlabel); // might be 0 if (previmg != 0) { dbgprintf("Unique ID associated with this previous header: %d\n", previmg->unique_id); img->previous_id = previmg->unique_id; } else { dbgprintf("No previous unique id found\n"); img->previous_id = 0; } img->label = newlabel; img->unique_id = id_pool++; // each header will have its own unique ID. img->nbc = strtol(l[1].c_str(),0,0); img->rawdata = 0 ; // nothing received yet exp_nb = 9 * img->nbc + 2; // expected number of arguments in the list if ((img->nbc > 0) && (exp_nb == l.size())) { // create the suitable number of components img->comp = new IMAGECOMP_HEADER[img->nbc]; for (i = 0, j = 2 ; i < img->nbc ; i++, j+=9) { (img->comp[i]).nx = atoi(l[j].c_str()); (img->comp[i]).ny = atoi(l[j+1].c_str()); (img->comp[i]).nz = atoi(l[j+2].c_str()); (img->comp[i]).ox = atoi(l[j+3].c_str()); (img->comp[i]).oy = atoi(l[j+4].c_str()); (img->comp[i]).oz = atoi(l[j+5].c_str()); (img->comp[i]).imgt = imview_interpreter->translate_img(l[j+6]); (img->comp[i]).pixt = imview_interpreter->translate_pix(l[j+7]); (img->comp[i]).spp = atoi(l[j+8].c_str()); (img->comp[i]).buffp = 0; // to be filled when we actually get some data. // check for each component: if (((img->comp[i]).nx * (img->comp[i]).ny * (img->comp[i]).nz) == 0) { result = "Put: no data\n"; ret = 2; break; } else if ((img->comp[i]).imgt == IM_ERROR) { result = "Put: incorrect image type\n"; ret = 3; break; } else if ((img->comp[i]).pixt == IM_INVALID) { result = "Put: incorrect pixel type\n"; ret = 4; break; } } // check that what we got was sensible if (ret == 0) { int j, ts = 0, spp = 0, smps = 0; int xfer_ok; // size of the raw data expected_size = HEADER_ID_SIZE ; // size of the header for (j = 0 ; j < img->nbc ; j++) { // the multiplier ts = IOBlackBox->typeSize((img->comp[j]).pixt); spp = (img->comp[j]).spp; smps = \ (img->comp[j]).nx * \ (img->comp[j]).ny * \ (img->comp[j]).nz; expected_size += ts * spp * smps; } img->expected_size = expected_size; // this is where we differ from put // port = is->open_data_channel(result); if (!shm_setup_ok && (setup_shm() != 0)) { // shared memory allocated only if needed result = "Shared memory setup failed\n"; ret = 41; } if (!ret) { // all is well // allocate final data img->rawdata = (char *)malloc(expected_size * sizeof(char)); if (img->rawdata == 0) ret = 42; else { // fake a transmission by socket memcpy(img->rawdata, &(img->label), sizeof(int)); memset((char *)(img->rawdata) + sizeof(int), 0, sizeof(int)); so_far = 2*sizeof(int); // data may come in chunks do { xfer_ok = get_data((char *)(img->rawdata) + so_far); if (xfer_ok < 0) { ret = 43; break; } so_far += xfer_ok; } while (so_far < expected_size); if (so_far == expected_size) { // build the image char *curp; int k, l; dbgprintf("putm: transfer was successful, building the image\n"); curp = (char *)img->rawdata + HEADER_ID_SIZE; // start of the real data for (l = 0 ; l < img->nbc ; l++) { // allocate buffp, this is tiny, I'm not expecting problems here (img->comp[l]).buffp = (void **)malloc(spp * sizeof(void*)); for (k = 0 ; k < spp ; k++) { (img->comp[l]).buffp[k] = curp; curp += smps * ts; // size of a single spectrum of the given data } } // delete the previous image with the same name, if any dbgprintf("putm: deleting previous image with same name"); put::delete_header(img->previous_id); // reset the semaphores to known state // finally, post message to GUI to display the image IOBlackBox->pleaseDisplay(img->label); } // what if data transfer is incomplete? the lines below take care of that. } } // when we return, data has been transfered already. if (so_far == expected_size) sres << "OK! Received: " << so_far << " bytes" << '\n'; else sres << "Failed! Received: " << so_far << " bytes, Expected: " << expected_size << '\n'; // overwrite the result with the port number result = sres.str(); } } else { sres << "Put syntax error, expected " << exp_nb << " arguments, \n" << "Got: " << l.size() << "\n"; result = sres.str(); ret = 5; } if (ret > 0) { imh.pop_back(); // forget about this header free(img->label); // had been strduped free(img->rawdata); // may be 0, still OK. delete img; // not useful anymore } } else { result = "Put: incomplete argument list\n"; ret = 10; } if (ret > 0) result += \ "\n" "Syntax: put \"name\" nbcomp nx ny nz ox oy oz IMG_TYPE PIX_TYPE spp\n" " with as many times (nx ny ... spp) as there are nbcomp\n"; else if (syncDisplay) im_draw_finished = false; return ret; } // Sets the shared memory segment up. // int putm::setup_shm(void) { char idshm; struct sembuf sb = {0, -1, 0}; // ----------- setup the shared memory ------ idshm = 'B'; // the shared memory is unique to this imview if ((shm_key = ftok(ref_pathname, idshm)) == -1) { // We use a different path each time dbgprintf("putm::setup: Could not get shm_key, %s\n", strerror(errno)); return(4); } dbgprintf("RefPathname: %s, char: %c, shared memory ID: %p", ref_pathname, idshm, shm_key); /* connect to (and possibly create) the segment: */ if ((shmid = shmget(shm_key, SHM_SIZE, 0644 | IPC_CREAT)) == -1) { dbgprintf("putm::setup: Could not get shm ID, %s\n", strerror(errno)); return(5); } /* attach to the segment to get a pointer to it: */ data = (char *)shmat(shmid, 0, 0); if (data == (char *)(-1)) { dbgprintf("putm::setup: Could not get pointer to data, %s\n", strerror(errno)); return(6); } /* allow clients to connect to now existing shared memory segment */ dbgprintf("setup_shm: server now allowing access to shared memory segment\n"); sb.sem_num = SEM_ACS; sb.sem_op = 1; /* up */ if (semop(semid, &sb, 1) == -1) { dbgprintf("setup_shm: semaphore operation failed\n"); return(7); } // if we get here, all was set up correctly shm_setup_ok = true; return 0; } // to be called in case of errors. Will put the // semaphores in a consistent state: client access // allowed and r/w disabled. int putm::sem_reset(void) { union semun arg; // initializes access semaphore to 1: first client must wait // until memory is setup. arg.val = 0; if (semctl(semid, SEM_ACS, SETVAL, arg) == -1) { dbgprintf("putm::reset_sem: Could not control SEM_ACS semaphore, %s\n", strerror(errno)); return 1; // could not control semaphore } /* initializes read to 0: block */ arg.val = 0; if (semctl(semid, SEM_RD, SETVAL, arg) == -1) { dbgprintf("putm::reset_sem: Could not control SEM_RD semaphore, %s\n", strerror(errno)); return 1; // could not control semaphore } /* initializes write to 1: allowed to write */ arg.val = 1; if (semctl(semid, SEM_WR, SETVAL, arg) == -1) { dbgprintf("putm::reset_sem: Could not control SEM_WR semaphore, %s\n", strerror(errno)); return 1; // could not control semaphore } return 0; } /*------------------------------------------------------------------------ * * It works this way: * * Rv = Read OK, Rx = Read NOT OK. * Wv = Write OK, Wx = Write NOT OK. * * SERVER | CLIENT * -----------------------------+------------------------------ * | w: * r: | Writes (blocks) * Set RxWv | Writes (unblocked) * Reads (blocks) | Writes * (blocks) | Writes * (...) | Sets RvWx * (unblocked) | Writes (blocks) * Reads | Writes (blocks) * Reads | Writes (blocks) * ... | ... * go to r: | go to w: * -----------------------------+------------------------------ * * This must be completely standard but it took me a couple of * hours to get it right again. * *-----------------------------------------------------------------------*/ static jmp_buf sysv_alrm_env; static void sysv_alarmHandler(int sig) { // reset the signal handler signal(sig, sysv_alarmHandler); longjmp(sysv_alrm_env, 1); } // this reads what's in the shared memory buffer. // the semaphores are left in a consistent state as long // as there are no errors. If errors are detected, a reset() will // be necessary. int putm::get_data(char *dest) { int retval; struct sembuf sb = {0, -1, 0}; signal(SIGALRM, sysv_alarmHandler); // timeout is likely if the client screws up // ----------- Blocking waiting for client to fill data buffer, and unlock it if (sigsetjmp(sysv_alrm_env, 1) == 0) { // trying to read. Should block as long as the client is writing. dbgprintf("putm: server now trying to read\n"); sb.sem_num = SEM_RD; sb.sem_op = -1; /* down */ if (semop(semid, &sb, 1) == -1) { dbgprintf("putm: semaphore operation failed\n"); return(-1); } // actual read operation memcpy(&retval, data, sizeof(int)); if ((retval > 0) && (retval <= SHM_SIZE)) memcpy(dest, data+sizeof(int), retval); // allow writing on to the buffer dbgprintf("putm: Server allows client to write to buffer\n"); alarm(15); /* timeout is in 15 seconds */ sb.sem_num = SEM_WR; sb.sem_op = 1; /* up */ if (semop(semid, &sb, 1) == -1) { dbgprintf("putm: semaphore operation failed\n"); return(-1); } } else { dbgprintf("putm: Timeout! this is bad...\n"); return -7; } // if we are here, all is well, the client has filled the data! // it is the caller's role to do something with it. We // return the first 4 bytes interpreted as an int. alarm(0); // cancel the alarm // spot of checking if ((retval <= 0) || (retval > SHM_SIZE)) retval = -9; return retval; } //------------------------------------------------- // this only get into play if sysv ipc are not available // on the system in question. #else // no SYSV IPC int putm::perform(vector &l, string &result) { result = "Unix SVR4 IPC Not supported\n"; return 1; } #endif // HAVE_SYSV_IPC /*------------------------------------------------------------------------ * * Same deal, for POSIX style IPC * * POSIX is nicer because the cruft laying around in case of a * crash of either the server or the client is on the filesystem, * not in the kernel. Most people don't know about ipcs and ipcrm * to check out if they find out they are running out of resources. * * *-----------------------------------------------------------------------*/ #ifdef HAVE_POSIX_IPC // define class variable char putp::ref_pathname[DFLTSTRLEN]; const char *putp::posix_tmp_path = "/tmp/px_imview_XXXXXX"; int ppath::perform(vector &l, string &result) { static string posix_path = string(putp::ref_pathname) + "\n"; result=posix_path; return 0; } putp::putp() { shm_setup_ok = false; sem_setup_ok = false; // nothing is set up yet putsem[SEM_ACCESS] = putsem[SEM_READ] = putsem[SEM_WRITE] = (sem_t *)0; // initialized state. px_templ_name = 0; // create a valid unique file path (don't open it) strcpy(ref_pathname, posix_tmp_path); int tempfd= mkstemp(ref_pathname); if (tempfd < 0) { // find error, will be print out if something goes wrong when putp is // asked. errformat("putp::putp : could not find unique temporary file name", errno); return; } // create semaphores // 1: first massage the temporary file name, get rid of /tmp in the name const char *bsname = strstr(ref_pathname+1, "/")+1; // skip both '/' if (bsname != NULL) { // Jeez it's hard to be standard px_templ_name = px_ipc_name(bsname); // will need to be freed if (init_sem(STR_ACCESS, SEM_ACCESS, 0) == SEM_FAILED) return; if (init_sem(STR_READ, SEM_READ, 0) == SEM_FAILED) return; if (init_sem(STR_WRITE, SEM_WRITE, 1) == SEM_FAILED) return; } // if we get there, all is fine with semaphores dbgprintf("POSIX IPC constructed, temporary file = %s\n", ref_pathname); sem_setup_ok = true; return; } putp::~putp() { dbgprintf("Putp destructor called\n"); // close the semaphores for (int i = 0 ; i < 3 ; ++i) { if (putsem[i] != SEM_FAILED) sem_close(putsem[i]); } // actually remove them from the filesystem remove_sem(STR_ACCESS); remove_sem(STR_READ); remove_sem(STR_WRITE); // close and unlink the shared memory file if (shmfd > 0) { close(shmfd); // can fail if (data != 0) munmap(data, SHM_SIZE); // unmap the data remove_shm(); // unlinks the file } if (tempfd >= 0) { // close(tempfd); // the O/S will do that... dbgprintf("POSIX IPC destructed, removing temporary file = %s\n", ref_pathname); unlink(ref_pathname); // actually remove the file } free(px_templ_name); // It's OK to free a NULL pointer return; } sem_t *putp::init_sem(const char *postfix, int which_sem, int start_val) { char semaphore_name[DFLTSTRLEN]; sem_t *res; dbgprintf("putp: initializing POSIX semaphore %s\n", postfix); strcpy(semaphore_name, px_templ_name); strcat(semaphore_name, postfix); dbgprintf("putp: semaphore name: %s\n", semaphore_name); res = putsem[which_sem] = sem_open(semaphore_name, O_CREAT|O_EXCL, IPC_FILE_MODE, start_val); // access allowed if (res == SEM_FAILED) { errformat("putp::putp : cannot initialize semaphore", errno); } return res; } void putp::remove_sem(const char *postfix) { char semaphore_name[DFLTSTRLEN]; strcpy(semaphore_name, px_templ_name); strcat(semaphore_name, postfix); sem_unlink(semaphore_name); return; } void putp::remove_shm(void) { char shm_name[DFLTSTRLEN]; strcpy(shm_name, px_templ_name); strcat(shm_name, STR_SHM); shm_unlink(shm_name); } // POSIX naming convention is actually non-standard. How // stupid is that. char *putp::px_ipc_name(const char *name) { char *dir, *dst; const char *slash; if ( (dst = (char *)malloc(PATH_MAX * sizeof(char))) == NULL) return(NULL); /* can override default directory with environment variable */ if ( (dir = getenv("PX_IPC_NAME")) == NULL) { #ifdef POSIX_IPC_PREFIX dir = POSIX_IPC_PREFIX; /* from "config.h" */ #else dir = "/tmp/"; /* default */ #endif } /* dir must end in a slash */ slash = (dir[strlen(dir) - 1] == '/') ? "" : "/"; snprintf(dst, PATH_MAX, "%s%s%s", dir, slash, name); return(dst); /* caller can free() this pointer */ } // helper method // saves the error into the error buffer. // this error buffer is printed on the console if for // some reason an error occured and the server is unable // to load up image via POSIX shared memory. void putp::errformat(const char *msg_prefix, int myerrno) { //strerror_r(myerrno, errbuff, DFLTSTRLEN); //snprintf(perrbuff, DFLTSTRLEN, "*** %s, %s", msg_prefix, errbuff); dbgprintf("%s: %s\n", msg_prefix, strerror(myerrno)); return; } // Sets the shared memory segment up. // int putp::setup_shm(void) { char shm_name[DFLTSTRLEN]; // ----------- setup the shared memory ------ strcpy(shm_name, px_templ_name); strcat(shm_name, STR_SHM); shmfd = shm_open(shm_name, O_CREAT|O_EXCL|O_RDWR, IPC_FILE_MODE); if (shmfd < 0) { errformat("putp::setup_shm : cannot initialize shared memory", errno); return 1; } else { dbgprintf("putp::setup_shm : shared memory file is %sw\n", shm_name); } // set the size of the segment if (ftruncate(shmfd, SHM_SIZE) < 0) { errformat("putp::setup_shm : cannot set size of shared memory segment", errno); return 2; } // attach the memory block if ((data = (char *) mmap(NULL, SHM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, shmfd, 0)) == MAP_FAILED) { errformat("putp::setup_shm : cannot map shared memory segment", errno); return 3; } // now allow access to shared memory segment dbgprintf("setup_shm: server now allowing access to shared memory segment\n"); if (sem_post(putsem[SEM_ACCESS]) < 0) { errformat("putp::setup_shm : Post semaphore operation failed", errno); return 4; } // if we get here, all was set up correctly shm_setup_ok = true; return 0; } static jmp_buf px_alrm_env; static void px_alarmHandler(int sig) { // reset the signal handler signal(sig, px_alarmHandler); longjmp(px_alrm_env, 1); } // this reads what's in the shared memory buffer. // the semaphores are left in a consistent state as long // as there are no errors. If errors are detected, a reset() will // be necessary. int putp::get_data(char *dest) { int retval; signal(SIGALRM, px_alarmHandler); // timeout is likely if the client screws up // ----------- Blocking waiting for client to fill data buffer, and unlock it if (sigsetjmp(px_alrm_env, 1) == 0) { // trying to read. Should block as long as the client is writing. dbgprintf("putp: server now trying to read\n"); if (sem_wait(putsem[SEM_READ]) < 0) { errformat("putp: semaphore operation failed\n", errno); return(-1); } // actual read operation retval = ((int*)data)[0]; // first word is size of data if ((retval > 0) && (retval <= SHM_SIZE)) memcpy(dest, data+sizeof(int), retval); // allow writing on to the buffer dbgprintf("putp: Server allows client to write to buffer\n"); alarm(15); /* timeout is in 15 seconds */ if (sem_post(putsem[SEM_WRITE]) < 0) { errformat("putp: semaphore operation failed\n", errno); return(-1); } } else { dbgprintf("putp: Timeout! this is bad...\n"); return -7; } // if we are here, all is well, the client has filled the data! // it is the caller's role to do something with it. We // return the first 4 bytes interpreted as an int. alarm(0); // cancel the alarm // spot of checking if ((retval <= 0) || (retval > SHM_SIZE)) retval = -9; return retval; } // long scary function // does nearly the same thing as putp::perform int putp::perform(vector &l, string &result) { int i, j, ret, expected_size; int so_far = 0; char *newlabel; size_t exp_nb; ostringstream sres; IMAGE_HEADER *img, *previmg; dbgprintf("Data transfer using POSIX style shared memory\n"); if (!sem_setup_ok) { result = "Internal semaphore handling failed. POSIX shared memory put not available\n" + \ string(errbuff); return 1; } if (l.size() > 3) { ret = 0; img = new IMAGE_HEADER; img->label = 0; // this is important, as otherwise find_header will choke on an invalid pointer img->needswap = 0; // coming from the same host, so we never need to swap the byte order of the data imh.push_back(img); // imh belong to put::, the parent class // fill the header newlabel = strdup(l[0].c_str()); // find out if there is another header with the same // name in use already. If so it will have to be delete // if the data transmission goes fine. dbgprintf("Looking for previous header with same label: %s\n", newlabel); previmg = put::find_header(newlabel); // might be 0 if (previmg != 0) { dbgprintf("Unique ID associated with this previous header: %d\n", previmg->unique_id); img->previous_id = previmg->unique_id; } else { dbgprintf("No previous unique id found\n"); img->previous_id = 0; } img->label = newlabel; img->unique_id = id_pool++; // each header will have its own unique ID. img->nbc = strtol(l[1].c_str(),0,0); img->rawdata = 0 ; // nothing received yet exp_nb = 9 * img->nbc + 2; // expected number of arguments in the list if ((img->nbc > 0) && (exp_nb == l.size())) { // create the suitable number of components img->comp = new IMAGECOMP_HEADER[img->nbc]; for (i = 0, j = 2 ; i < img->nbc ; i++, j+=9) { (img->comp[i]).nx = atoi(l[j].c_str()); (img->comp[i]).ny = atoi(l[j+1].c_str()); (img->comp[i]).nz = atoi(l[j+2].c_str()); (img->comp[i]).ox = atoi(l[j+3].c_str()); (img->comp[i]).oy = atoi(l[j+4].c_str()); (img->comp[i]).oz = atoi(l[j+5].c_str()); (img->comp[i]).imgt = imview_interpreter->translate_img(l[j+6]); (img->comp[i]).pixt = imview_interpreter->translate_pix(l[j+7]); (img->comp[i]).spp = atoi(l[j+8].c_str()); (img->comp[i]).buffp = 0; // to be filled when we actually get some data. // check for each component: if (((img->comp[i]).nx * (img->comp[i]).ny * (img->comp[i]).nz) == 0) { result = "Putp: no data\n"; ret = 2; break; } else if ((img->comp[i]).imgt == IM_ERROR) { result = "Putp: incorrect image type\n"; ret = 3; break; } else if ((img->comp[i]).pixt == IM_INVALID) { result = "Putp: incorrect pixel type\n"; ret = 4; break; } } // check that what we got was sensible if (ret == 0) { int j, ts = 0, spp = 0, smps = 0; int xfer_ok; // size of the raw data expected_size = HEADER_ID_SIZE ; // size of the header for (j = 0 ; j < img->nbc ; j++) { // the multiplier ts = IOBlackBox->typeSize((img->comp[j]).pixt); spp = (img->comp[j]).spp; smps = \ (img->comp[j]).nx * \ (img->comp[j]).ny * \ (img->comp[j]).nz; expected_size += ts * spp * smps; } img->expected_size = expected_size; // this is where we differ from put if (!shm_setup_ok && (setup_shm() != 0)) { // shared memory allocated only if needed result = "Shared memory setup failed\n"; ret = 41; } if (!ret) { // all is well // allocate final data img->rawdata = (char *)malloc(expected_size * sizeof(char)); if (img->rawdata == 0) ret = 42; else { // fake a transmission by socket memcpy(img->rawdata, &(img->label), sizeof(int)); memset((char *)(img->rawdata) + sizeof(int), 0, sizeof(int)); so_far = 2*sizeof(int); // data may come in chunks do { xfer_ok = get_data((char *)(img->rawdata) + so_far); if (xfer_ok < 0) { ret = 43; break; } so_far += xfer_ok; } while (so_far < expected_size); if (so_far == expected_size) { // build the image char *curp; int k, l; dbgprintf("putp: transfer was successful, building the image\n"); curp = (char *)img->rawdata + HEADER_ID_SIZE; // start of the real data for (l = 0 ; l < img->nbc ; l++) { // allocate buffp, this is tiny, I'm not expecting problems here (img->comp[l]).buffp = (void **)malloc(spp * sizeof(void*)); for (k = 0 ; k < spp ; k++) { (img->comp[l]).buffp[k] = curp; curp += smps * ts; // size of a single spectrum of the given data } } // delete the previous image with the same name, if any dbgprintf("putp: deleting previous image with same name"); put::delete_header(img->previous_id); // reset the semaphores to known state // finally, post message to GUI to display the image IOBlackBox->pleaseDisplay(img->label); } // what if data transfer is incomplete? the lines below take care of that. } } // when we return, data has been transfered already. if (so_far == expected_size) sres << "OK! Received: " << so_far << " bytes" << '\n'; else sres << "Failed! Received: " << so_far << " bytes, Expected: " << expected_size << '\n'; // overwrite the result with the port number result = sres.str(); } } else { sres << "Putp syntax error, expected " << exp_nb << " arguments, \n" << "Got: " << l.size() << "\n"; result = sres.str(); ret = 5; } if (ret > 0) { imh.pop_back(); // forget about this header free(img->label); // had been strduped free(img->rawdata); // may be 0, still OK. delete img; // not useful anymore } } else { result = "Putp: incomplete argument list\n"; ret = 10; } if (ret > 0) result += \ "\n" "Syntax: put \"name\" nbcomp nx ny nz ox oy oz IMG_TYPE PIX_TYPE spp\n" " with as many times (nx ny ... spp) as there are nbcomp\n"; else if (syncDisplay) im_draw_finished = false; return ret; } #else // HAVE_POSIX_IPC int ppath::perform(vector &l, string &result) { result = "531 POSIX IPC not supported\n"; return 1; } int putp::perform(vector &l, string &result) { result = "531 POSIX IPC Not supported\n"; return 1; } #endif // HAVE_POSIX_IPC #endif // HAVE_PTHREADS imview-1.1.9c/server/imshared.hxx0000644000076500007650000001404110054230061017615 0ustar talbottalbot00000000000000/* * $Id: imshared.hxx,v 4.2 2004/05/23 23:13:53 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Include file for imshared.C * * Contains definitions for mput, a subclass of `put' which does the * same thing, but uses a segment of shared memory instead of a data * stream for image data exchange * * Hugues Talbot 26 Mar 2000 * *-----------------------------------------------------------------------*/ #ifndef IMSHARED_H #define IMSHARED_H // valid for all type of shared memory #define SHM_SIZE 400000 // big enough for one 512*768 char buffer #ifdef HAVE_SYSV_IPC // we are using semaphores and shared memory, which are SVR4-specific features #include #include #include "imunistd.h" #include #include #include #include #include #include #include // this is WEIRD! but required on Unices #ifdef Linux # if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED) #warning Incorrect , workaround used. /* union semun is defined by including */ # else /* according to X/OPEN we have to define it ourselves (!) */ union semun { int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */ unsigned short int *array; /* array for GETALL, SETALL */ struct seminfo *__buf; /* buffer for IPC_INFO */ }; # endif // Gnu stuff #endif // Linux #ifdef __CYGWIN__ // cygwin has an implementation of SYSV shared memory... union semun { int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */ unsigned short *array; /* array for GETALL, SETALL */ }; #endif /* same X/OPEN stuff. there must be a good reason for it... */ #if defined(OSF1) || defined(Solaris) union semun { int val; struct semid_ds *buf; unsigned short *array; }; #endif // OSF1 typedef enum { SEM_ACS = 0, SEM_RD = 1, SEM_WR = 2 } semnames; #define FPATH1 "/tmp/willcrash" // must point to a file that can be opened // same as put, using shared memory instead of data stream class putm:public put { key_t sem_key, shm_key; int semid, shmid; bool shm_setup_ok, sem_setup_ok; char *data; // pointer to shared memory segment // the pathame must be the same across all instances of putm. static char ref_pathname[L_tmpnam+1]; // private methods. int setup_shm(void); int get_data(char *dest); public: putm(); ~putm(); int perform(vector &l, string &result); int sem_reset(void); // static methods static char *unique_filename(void) {return ref_pathname;} // this should be called ONLY once. static void setPathToEmpty(void) {ref_pathname[0] = '\0';} }; #else // shared memory not available // this is basically a useless class. class putm:public put { int perform(vector &l, string &result); }; #endif // HAVE_SYSV_IPC #ifdef HAVE_POSIX_IPC #include #include #include #include #include #define STR_ACCESS "_ACCESS" #define STR_READ "_READ" #define STR_WRITE "_WRITE" #define STR_SHM "_SHM" #define IPC_FILE_MODE 0600 // rw for creator only, must be Octal! class putp:public put { enum {SEM_ACCESS, SEM_READ, SEM_WRITE}; // we'll use 3 semaphores char *data; // pointer to shared memory area bool shm_setup_ok, sem_setup_ok; sem_t *putsem[3]; // array of 3 semaphores int tempfd, shmfd; // file descriptor to temporary file char errbuff[DFLTSTRLEN], perrbuff[DFLTSTRLEN]; // error buffer in case something goes wrong char *px_templ_name; // the pathame must be the same across all instances of putp. static const char *posix_tmp_path; // private methods sem_t *init_sem(const char *postfix, int which_sem, int start_val); void remove_sem(const char *postfix); void remove_shm(void); char *px_ipc_name(const char *name); // from unpv2 void errformat(const char *msg_prefix, int myerrno); int setup_shm(void); int get_data(char *dest); public: putp(); ~putp(); int perform(vector &l, string &result); static char ref_pathname[DFLTSTRLEN]; }; #else // HAVE_POSIX_IPC class putp:public put { public: int perform(vector &l, string &result); }; #endif // HAVE_POSIX_IPC #endif // IMSHARED_H imview-1.1.9c/server/interpreter.cxx0000644000076500007650000015026510364220670020401 0ustar talbottalbot00000000000000/* * $Id: interpreter.cxx,v 4.6 2006/01/20 17:45:28 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * * A minuscule interpreter for Imview, accessed through the socket * interface. * The idea is to be able to control the GUI from the command line, * so that: * 1- remote control of imview from another application is easy * 2- linking two or more imviews is a possibility * 3- regression testing of imview is possible. * * Hugues Talbot 1 Mar 2000 * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" #include "imview.hxx" #ifdef HAVE_PTHREADS // otherwise don't even bother #include // C++ ones #include #include #include #include "imviewWindow.hxx" #include "pointfile.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "menubar.hxx" #include "printPrefs.hxx" #include "savePrefs.hxx" #include "imageInfo.hxx" #include "spectraBox.hxx" #include "transferFunction.hxx" #include "profileBox.hxx" #include "userPrefs.hxx" #include "progressInfo.hxx" #include "bivHist.hxx" #include "toolbar.hxx" #include "FL/Fl_Help_Dialog.H" #include "interpreter.hxx" #include "imshared.hxx" extern imview_server *is; extern interpreter *imview_interpreter; extern linkmanager *imview_linkmanager; extern pointfile *PtFileMngr; extern imageViewer *mainViewer; extern imViewMenuBar *mainMenuBar; extern imageIO *IOBlackBox; extern imviewWindow *mainWindow; extern bool main_terminate; extern char appName[]; extern string truestr, falsestr; extern volatile bool syncDisplay; extern volatile bool im_draw_finished; extern Fl_Box *titleBox ; // marker for when an image is present // fluid-generated extern printprefs *printPrefsPanel; extern saveprefs *savePrefsPanel; extern imageinfo *imageInfoPanel; extern transfer *transferEditorPanel; extern spectra *spectraPanel; extern profile *profilePanel; extern userprefs *userprefsPanel; extern bivhist *bivHistPanel; extern progress *progressPanel; extern Fl_Help_Dialog *help; extern toolbar *toolbarPanel; // these are COMPULSERY definitions!! //map interpreter::tr_img; //map interpreter::tr_pix; #ifndef WIN32 static const char *uservar = "USER"; #else static const char *uservar = "USERNAME"; #endif const char *ActionResult[] = { "500 Command failed\n", "501 Unknown command\n", "502 Unchanged\n", "503 Not moved\n", "504 Not sized\n", "505 Load failed\n", "506 Arghh!\n", "507 Not logged in\n", "508 No data\n", "509 Incorrect image type\n", "510 Incorrect pixel type\n", "511 Incomplete argument list\n", "512 No label\n", "513 Invalid command (", // note: no \n "514 No image present\n", "515 Not implemented yet\n", "516 Unknown dialog box\n", "517 Connection failed\n", "518 Socket exception", // no \n "519 Non-existent variable\n", "520 Pointfile failure\n", "000 OK", // NOTE: no \n NULL }; enum ActionCode { CMD_FAILD = 0, CMD_UNKWN, // 1 CMD_UNCHG, // 2 CMD_NOTMV, // 3 CMD_NOTSZ, // 4 CMD_LFAIL, // 5 CMD_AARGH, // 6 CMD_NOLOG, // 7 CMD_NODTA, // 8 CMD_IMGNG, // 9 CMD_PIXNG, // 10 CMD_LOARG, // 11 CMD_NOLBL, // 12 CMD_INVAL, // 13 CMD_NOIMG, // 14 CMD_NOSYS, // 15 CMD_NODLG, // 16 CMD_CFAIL, // 17 CMD_ESOCK, // 18 CMD_NOVAR, // 19 CMD_PTFIL, // 20 CMD_OK, // Leave that last... CMD_LAST }; // NOTE: // All functions (commands) must do the following: // 1- return 0 in case of success or return a strictly // positive integer in case of failure. // // 2- Either in case of success or failure, functions can // return a result string. The last line in the result // must be 5xx in case of errors. The following codes // are reserved: // // 500 Command failed // 501 Unknown command // 000 OK // // `000 OK' is added automatically if the command completes // sucessfully (return code = 0). // // Commands can also return a negative integer value if they don't // want the evaluator to add the "000 OK" or "500 Command failed" // strings to the result, but be warned that clients will often be // parsing the above code as `end of response' for efficiency. // int complain::perform(vector &l, string &result) { result = ActionResult[CMD_UNKWN]; // This is a key word return -1; // special case for unknown command } int cmap::perform(vector &l, /* */ string &result) /* */ { int retval; if ((l.size() > 0) && (setClut(l[0].c_str()) == 0)) { retval = 0; } else if (l.size() == 0) { // revert to default LUT noclut_cb(0,0); retval = 0; } else { result = ActionResult[CMD_UNCHG]; retval = 1; } return retval; } int move::perform(vector &l, string &result) { int newx, newy; if (l.size() >= 2) { newx = atoi(l[0].c_str()); newy = atoi(l[1].c_str()); mainWindow->position(newx, newy); return 0; } else { result = ActionResult[CMD_NOTMV]; return 1; } } int size::perform(vector &l, string &result) { int neww, newh; if (l.size() >= 2) { neww = atoi(l[0].c_str()); newh = atoi(l[1].c_str()); if (mainViewer) { mainWindow->size(neww, newh); mainViewer->resize(); } return 0; } else { result = ActionResult[CMD_NOTSZ]; return 1; } } int load::perform(vector &l, string &result) { if ((l.size() > 0) && (openimage(l[0].c_str(),0) == 0)) { if (syncDisplay) im_draw_finished = false; return 0; } else { result = ActionResult[CMD_LFAIL]; return 1; } } int quit::perform(vector &l, string &result) { result = "Bye!\n"; // do not change this command, this is a keyword. return -2; // telling the evaluator no to add "000 OK" to the command } int killme::perform(vector &l, string &result) { result = ActionResult[CMD_AARGH]; main_terminate=true; // this will do it... return 0; } int interpreter_help::perform(vector &l, string &result) { result = \ "help/? : this help\n" "---- Connection management\n" "user : log in\n" "quit/bye/end/exit : closes connection\n" "kill : kills the server\n" "link : link to another imview\n" "unlk : unlink from another imview\n" "---- Upload images\n" "put : puts an image for display\n" #ifdef HAVE_SYSV_IPC "putm : puts an image for display using shared memory (localhost only, SYSV IPC)\n" #endif #ifdef HAVE_POSIX_IPC "ppath : return path to IPC resources\n" "putp : puts an image for display using shared memory (localhost only, POSIX IPC)\n" #endif "---- Pointfiles\n" "pf : prints pointfile\n" "stpf : sets the point file name\n" "ldpf : upload a pointfile\n" "svpf : save the pointfile\n" "clpf : clears the pointfile\n" "---- Image management\n" "load : load the image from \n" "cmap [name] : apply colour map to current image, default if no name\n" "zoom : zoom functions, described below:\n" " ... box x y w h : zoom to specified box \n" " ... factor zf : specify zoom factor (real number)\n" " ... default zf : specify default zoom factor\n" "pan x y : pan to specified location, keeping zoom intact\n" "reset : reset the image\n" "close [name] : close an image (name optional)\n" "..... : close the overlay plane\n" "---- Window management\n" "move : move main window to new position\n" "size : change the window dimensions\n" "raise : raise/deiconize the main window to the top\n" "icon/hide : iconize the application\n" "show|hide : show or hide the main window\n" " ... print : show or hide the print image dialog\n" " ... save : show or hide the save image dialog\n" " ... info : show or hide the info image dialog\n" " ... transfer : show or hide the edit transfer dialog\n" " ... spectra : show or hide the spectra display dialog\n" " ... profile : show or hide the profile display dialog\n" " ... user : show or hide the user preference dialog\n" " ... bivhist : show or hide the bivariate histogram dialog\n" " ... progress : show or hide the image download progress dialog\n" " ... help : show or hide the online help dialog\n" " ... toolbar : show or hide the toolbar\n" "---- Variables\n" "set : set some variable\n" "get : obtain a variable value\n" "list : lists all the valid variables\n" ; return 0; } //bool user::matches = false; // no one is authenticated by default user::user(void) { // find out who is running the show // this is a bit flaky, but should do for now. Proper security will // be for later. const char *p = getenv(uservar); // get the user name from the environment if (p) { string rawname = p; string::size_type found = 0; // redundant whitespaces reduced to a single space // 1- replace all other whitespaces with space do { found = rawname.find_first_of("\t\r\n"); if (found != string::npos) { dbgprintf("Space found in username %s at position %d; while npos=%d\n", rawname.c_str(), found, string::npos); rawname.replace(found,1," "); } } while (found != string::npos); // 2- replace pairs of spaces with a single one do { found = rawname.find(" "); // pair of spaces if (found != string::npos) { dbgprintf("Double space found in username %s\n", rawname.c_str()); rawname.replace(found, 2, " "); // a single space } } while (found != string::npos); server_user = rawname; dbgprintf("server_user = %s\n", server_user.c_str()); assert(server_user.size() != 0); } else server_user = ""; // empty string if (server_user.size() != 0) dbgprintf("User action constructor: user = %s\n", server_user.c_str()); else errprintf("User unknown, env. variable %s not defined", uservar); return; } int user::perform(vector &l, string &result) { ostringstream osm, osnm; string fullname; if (l.size() > 0) { // user names can have whitespaces in them osnm << l[0]; for (unsigned int i = 1 ; i < l.size() ; ++i) osnm << " " << l[i]; fullname = osnm.str(); if (server_user.size() == 0) { osm << "516 " << uservar << "environment variable is not defined.\n"; return 3; } else if (fullname == server_user) { osm << "Welcome, " << fullname #ifdef HAVE_SYSV_IPC << ' ' << putm::unique_filename() #else << ' ' << "no_shm" #endif << ' ' ; result = osm.str(); return 0; } else { osm << "505 Go away, " << fullname << '\n'; result = osm.str(); return 1; } } else { result = "200 usage: user \n"; return 2; } } // sets the pointfile path int set_pointfile::perform(vector &l, string &result) { PtFileMngr->setPtFileName((l[0]).c_str()); return 0; // always succeeds } // sets the pointfile path and upload it int load_pointfile::perform(vector &l, string &result) { PtFileMngr->setPtFileName((l[0]).c_str()); PtFileMngr->readlist(); mainViewer->redraw(); return 0; // always succeeds } // sets the pointfile path and save it int save_pointfile::perform(vector &l, string &result) { PtFileMngr->setPtFileName((l[0]).c_str()); PtFileMngr->savelist(); return 0; // always succeeds } // clears the pointfile int clear_pointfile::perform(vector &l, string &result) { PtFileMngr->rmAllPoints(); mainViewer->redraw(); return 0; // always succeeds } // this is the command that always goes through if not logged in int deny::perform(vector &l, string &result) { result = ActionResult[CMD_NOLOG]; return 1; // always fail } // this function can be called both from the GUI AND // from the image server. IMAGE_HEADER *put::find_header(const char *name) { vector::iterator i; IMAGE_HEADER *result; result = 0; if (name != 0) { for (i = imh.begin() ; i != imh.end() ; i++) { if (((*i)->label != 0) && (strcmp(name, (*i)->label) == 0)) { srv_dbgprintf("Found the header associated with %s!\n", name); break; } } if (i != imh.end()) result = *i; } return result; } // data coming from different-endian clients will have their data // swapped. inline unsigned int put::swapid(int id) { uchar *from, *to; int out; from = (uchar *)&id; to = (uchar *)&out; to[0] = from[3]; to[1] = from[2]; to[2] = from[1]; to[3] = from[0]; return out; } // this function can be called both from the GUI AND // from the image server. IMAGE_HEADER *put::find_header(unsigned int given_id) { vector::iterator i; for (i = imh.begin() ; i != imh.end() ; i++) { if (given_id == (*i)->unique_id) { srv_dbgprintf("Found the header associated with %d!\n", given_id); (*i)->needswap = false; break; } else if (swapid(given_id) == (*i)->unique_id) { srv_dbgprintf("Found the header associated with %d, but swapped!\n", given_id); (*i)->needswap = true; break; } } if (i != imh.end()) return *i; else return 0; } void put::delete_header(const char *fname) { vector::iterator i; IMAGE_HEADER *myheader; if (fname != 0) { for (i = imh.begin() ; i != imh.end() ; i++) { if ((*i)->label != 0) { if (strcmp(fname, (*i)->label) == 0 ) { srv_dbgprintf("Found the header associated with %s for deletion...\n", fname); myheader = *i; delete_header(myheader); // actually remove the label from the vector imh.erase(i); // I'm not sure what would work srv_dbgprintf("%s: all freed\n", fname); break; } } } } } void put::delete_header(unsigned int given_id) { vector::iterator i; IMAGE_HEADER *myheader; if (given_id > 0) { for (i = imh.begin() ; i != imh.end() ; i++) { if (given_id == (*i)->unique_id) { srv_dbgprintf("Found the header associated with %d for deletion!\n", given_id); myheader = *i; delete_header(myheader); // actually remove the label from the vector imh.erase(i); // I'm not sure what would work srv_dbgprintf("%d: all freed\n", given_id); break; } } } } void put::delete_header(IMAGE_HEADER *myheader) { int j; // delete the memory associated with it for (j = 0 ; j < myheader->nbc ; j++) { // free the buffp's free((myheader->comp[j]).buffp); } // delete the component headers delete[] myheader->comp; // free the raw data buffer. free(myheader->rawdata); // free the label (strduped) free(myheader->label); // delete the memory associated with the header delete(myheader); myheader = 0; return; } // this will get called when the transmission is // finished. This will be called through the // server thread. int put::callback(void *buf, unsigned long nbbytes) { int res = 0; srv_dbgprintf("Within the put callback, received %d bytes\n", nbbytes); if ((buf == 0) || (nbbytes <= HEADER_ID_SIZE)) { cerr << "Binary transmission failed!\n" ; res = 2; } else { // make up an image from the data we just received, but first // associate the buffer just received with a header IMAGE_HEADER *myheader; unsigned int *idnb; ostringstream uniq; // look in all the headers idnb = (unsigned int *)buf; myheader = find_header(*idnb); if (myheader != 0) { int j, ts, spp, smps; unsigned long expected_size; ts = spp = smps = 0; // first things first: is this header being reused? // if so, free the previous buffer. if (myheader->rawdata != 0) free(myheader->rawdata); // IMPORTANT: the server normally generates a magic number // for the client to use, and header reuse in this fashion // is not expected behaviour, but is possible. expected_size = HEADER_ID_SIZE ; // size of the header for (j = 0 ; j < myheader->nbc ; j++) { // the multiplier ts = IOBlackBox->typeSize((myheader->comp[j]).pixt); spp = (myheader->comp[j]).spp; smps = \ (myheader->comp[j]).nx * \ (myheader->comp[j]).ny * \ (myheader->comp[j]).nz; expected_size += ts * spp * smps; } srv_dbgprintf("We expected %d bytes\n", expected_size); // header found if (nbbytes == expected_size) { int k; char *curp; // keeps the pointer to raw data, so it can be freed later myheader->rawdata = buf; // build an image! // I think it's OK if the buffer stays as it is. We only // need to make the diverse pointers point to the right // location curp = (char *)buf + HEADER_ID_SIZE; // start of the real data for (j = 0 ; j < myheader->nbc ; j++) { // allocate buffp (myheader->comp[j]).buffp = (void **)malloc(spp * sizeof(void*)); for (k = 0 ; k < spp ; k++) { (myheader->comp[j]).buffp[k] = curp; curp += smps * ts; // size of a single spectrum of the given data } } // So, everything went fine. When the GUI comes around to display // the current image, the previous one will have been deleted. // luckily we have its unique_id in the header. srv_dbgprintf("callback: closing previous header: %d \n", myheader->previous_id); delete_header(myheader->previous_id); // finally we need to post a message to the GUI, // saying an image has been transmitted. // constructs a string from a char * label const string uniqs=myheader->label; srv_dbgprintf("Ok so far. Asking the GUI to please diplay img %s\n", myheader->label); IOBlackBox->pleaseDisplay(uniqs); // note: we can't call the GUI directly as we are within // the server's thread. // if we need to synchronize, then we must wait for display at this stage. // otherwise future commands might be lost. if (syncDisplay) { srv_dbgprintf("Blocking future commands until display completed\n"); im_draw_finished = false; } } else { cerr << "Did not receive the expected number of bytes:\n" << "Expected: " << expected_size << "\n" << "Received: " << nbbytes << "\n"; res = 3; } } else { cerr << "Could not match header with Id = " << *idnb << endl; } } // at any rate, we close the data channel // let's not do it, and see // is->close_data_channel(); if (res != 0) { free(buf); buf = 0; // zap the buffer! Worthless! } return res; } // this static variables help us remember what headers // have been created and which images are in the pipe (literally!) // This is all necessary because there might be more than one // image being transmitted at any one time. vector put::imh; unsigned int put::id_pool = (((unsigned int)'A') << 24) + (((unsigned int)'B') << 16) + (((unsigned int)'C') << 8) + ((unsigned int)'D'); // at last some real action! // this opens a binary data connection so that an // an image can go through it. // The end of transmission will generate a callback. int put::perform(vector &l, string &result) { int port, i, j, ret, expected_size; char *newlabel; size_t exp_nb; ostringstream sres, os; IMAGE_HEADER *img, *previmg; if (l.size() > 3) { ret = 0; img = new IMAGE_HEADER; img->label = 0; // this is important, as otherwise find_header will choke on an invalid pointer imh.push_back(img); // we need to remember this header. // fill the header newlabel = strdup(l[0].c_str()); // find out if there is another header with the same // name in use already. If so it will have to be deleted // if the data transmission goes fine. dbgprintf("Looking for previous header with same label: %s\n", newlabel); previmg = find_header(newlabel); // might be 0 if (previmg != 0) { dbgprintf("Unique ID associated with this previous header: %d\n", previmg->unique_id); img->previous_id = previmg->unique_id; } else { dbgprintf("No previous unique id found\n"); img->previous_id = 0; } img->label = newlabel; img->unique_id = id_pool++; // each header will have its own unique ID. img->nbc = strtol(l[1].c_str(),0,0); img->rawdata = 0 ; // nothing received yet exp_nb = 9 * img->nbc + 2; // expected number of arguments in the list if ((img->nbc > 0) && (exp_nb == l.size())) { // create the suitable number of components img->comp = new IMAGECOMP_HEADER[img->nbc]; for (i = 0, j = 2 ; i < img->nbc ; i++, j+=9) { (img->comp[i]).nx = atoi(l[j].c_str()); (img->comp[i]).ny = atoi(l[j+1].c_str()); (img->comp[i]).nz = atoi(l[j+2].c_str()); (img->comp[i]).ox = atoi(l[j+3].c_str()); (img->comp[i]).oy = atoi(l[j+4].c_str()); (img->comp[i]).oz = atoi(l[j+5].c_str()); (img->comp[i]).imgt = imview_interpreter->translate_img(l[j+6]); (img->comp[i]).pixt = imview_interpreter->translate_pix(l[j+7]); (img->comp[i]).spp = atoi(l[j+8].c_str()); (img->comp[i]).buffp = 0; // to be filled when we actually get some data. // check for each component: if (((img->comp[i]).nx * (img->comp[i]).ny * (img->comp[i]).nz) == 0) { result = ActionResult[CMD_NODTA]; ret = 2; break; } else if ((img->comp[i]).imgt == IM_ERROR) { result = ActionResult[CMD_IMGNG]; ret = 3; break; } else if ((img->comp[i]).pixt == IM_INVALID) { result = ActionResult[CMD_PIXNG]; ret = 4; break; } } // check that what we got was sensible if (ret == 0) { int j, ts, spp, smps; // size of the raw data expected_size = HEADER_ID_SIZE ; // size of the header for (j = 0 ; j < img->nbc ; j++) { // the multiplier ts = IOBlackBox->typeSize((img->comp[j]).pixt); spp = (img->comp[j]).spp; smps = \ (img->comp[j]).nx * \ (img->comp[j]).ny * \ (img->comp[j]).nz; expected_size += ts * spp * smps; } img->expected_size = expected_size; // new unsophisticated binary data channel port = is->open_data_channel(result); if (port > 0) { sres << port << " " << img->unique_id << '\n'; // overwrite the result with the port number result = sres.str(); } } } else { os << "511 Put syntax error, expected " << exp_nb << " arguments, \n" << "511 Got: " << l.size() << "\n"; result = os.str(); ret = 5; } if (ret > 0) { imh.pop_back(); // forget about this header free(img->label); // had been strduped delete img; // not useful anymore } } else { result = ActionResult[CMD_LOARG]; // Short argument list ret = 10; } if (ret > 0) result += \ "511 \n" "511 Syntax: put \"name\" nbcomp nx ny nz ox oy oz IMG_TYPE PIX_TYPE spp\n" "511 with as many times (nx ny ... spp) as there are nbcomp\n" "511 Syntax error"; return ret; } int print_pointfile::perform(vector &l, string &result) { if (PtFileMngr) { PtFileMngr->savelist(result); return 0; } else { result = ActionResult[CMD_PTFIL]; return 1; } } // one of the assumptions is that the label is only one word. // this will always be true if only this function is called // to set the label, as whitespace is the separator for l. int set_appname::perform(vector &l, string &result) { int scanned; char tmp[100], realAppName[100]; if (l.size() > 0) { if (appName[0] == '[') { scanned = sscanf(appName, "%*s %s", realAppName); if (scanned == 1) sprintf(tmp, "[%s] %s", l[0].c_str(), realAppName); else // didn't work, revert sprintf(tmp, "[%s] %s", l[0].c_str(), appName); } else { sprintf(tmp, "[%s] %s", l[0].c_str(), appName); } strcpy(appName, tmp); mainWindow->label(appName); return 0; } else { result = ActionResult[CMD_NOLBL]; // No label return 1; } } int zoom::perform(vector &l, string &result) { int retval = 0; if ((l.size() > 0) && mainViewer) { if ((cmp_nocase(l[0],"box") == 0) && (l.size() > 4)) { int bx, by, bw, bh; bx = atoi(l[1].c_str()); by = atoi(l[2].c_str()); bw = atoi(l[3].c_str()); bh = atoi(l[4].c_str()); if (syncDisplay) im_draw_finished = false; // call should not be forwarded to other instances of imview mainViewer->zoomToBox(bx,by,bw,bh,false); } else if ((cmp_nocase(l[0],"factor") == 0) && (l.size() > 1)) { double zf = atof(l[1].c_str()); if (zf > 0) // call should not go to other imviews (last arg) mainViewer->zoomFactor(zf, true, false); // do redraw, call not from GUI } else if ((cmp_nocase(l[0],"default") == 0) && (l.size() > 1)) { double zf = atof(l[1].c_str()); if (zf > 0) mainViewer->setDefaultZoomFactor(zf, false); } else { result = ActionResult[CMD_INVAL] + l[0] + ")\n"; // invalid command retval = 1; } } else { result = "513 No change\n"; retval = 1; } return retval; } int pan::perform(vector &l, string &result) { if ((l.size() == 2) && mainViewer) { int bx, by; bx = atoi(l[0].c_str()); by = atoi(l[1].c_str()); if (syncDisplay) im_draw_finished = false; mainViewer->pan(bx, by); } return 0; } int reset::perform(vector &l, string &result) { if (mainViewer) { unzoom_cb(0,0); mainViewer->resetDisplay(true,false); // do redraw but don't forward return 0; } else { result = ActionResult[CMD_NOIMG]; // no image present return 1; } } int close_image::perform(vector &l, string &result) { if (mainViewer) { if (l.size() == 0) { close_cb(0,0); // close the currently diplayed image return 0; } else if (cmp_nocase(l[0], OVERLAY_MARKER) == 0) { closeoverlay_cb(0,0); return 0; } else { result = ActionResult[CMD_NOSYS]; // command not implemented return 1; } } else { result = ActionResult[CMD_NOIMG]; // no image present return 1; } } int raise_window::perform(vector &l, string &result) { if (mainWindow) mainWindow->show(); return 0; // Always succeed } int iconize_window::perform(vector &l, string &result) { if (mainWindow) mainWindow->iconize(); return 0; // Always succeed } int hide_window::perform(vector &l, string &result) { if ((l.size() == 0) && mainWindow) mainWindow->iconize(); // hide() actually kills the main window else if (l.size() > 0) { if (cmp_nocase(l[0], "toolbar") == 0) { if (toolbarPanel) toolbarPanel->hide(); } else if (cmp_nocase(l[0], "print") == 0) { if (printPrefsPanel) printPrefsPanel->hide(); } else if (cmp_nocase(l[0], "save") == 0) { if (savePrefsPanel) savePrefsPanel->hide(); } else if (cmp_nocase(l[0], "info") == 0) { if (imageInfoPanel) imageInfoPanel->hide(); } else if (cmp_nocase(l[0], "transfer") == 0) { if (transferEditorPanel) transferEditorPanel->hide(); } else if (cmp_nocase(l[0], "spectra") == 0) { if (spectraPanel) spectraPanel->hide(); } else if (cmp_nocase(l[0], "profile") == 0) { if (profilePanel) profilePanel->hide(); } else if (cmp_nocase(l[0], "user") == 0) { if (userprefsPanel) userprefsPanel->hide(); } else if (cmp_nocase(l[0], "bivhist") == 0) { if (bivHistPanel) bivHistPanel->hide(); } else if (cmp_nocase(l[0], "progress") == 0) { if (progressPanel) progressPanel->hide(); } else if (cmp_nocase(l[0], "help") == 0) { if (help) help->hide(); } else { result = ActionResult[CMD_NODLG]; // Unknown Dialog return 1; } } return 0; // Always succeed } int show_window::perform(vector &l, string &result) { int retval = 0; if ((l.size() == 0) && mainWindow) mainWindow->show(); else if (l.size() > 0) { if (cmp_nocase(l[0], "toolbar") == 0) { toolbar_cb(0,0); } else if (cmp_nocase(l[0], "print") == 0) { if (!titleBox) printprefs_cb(0,0); else { result = "520 No image shown\n"; retval = 1; } } else if (cmp_nocase(l[0], "save") == 0) { if (!titleBox) save_cb(0,0); else { result = "520 No image shown\n"; retval = 1; } } else if (cmp_nocase(l[0], "info") == 0) { imageinfo_cb(0,0); } else if (cmp_nocase(l[0], "transfer") == 0) { transfer_cb(0,0); } else if (cmp_nocase(l[0], "spectra") == 0) { showspectrum_cb(0,0); } else if (cmp_nocase(l[0], "profile") == 0) { showprofile_cb(0,0); } else if (cmp_nocase(l[0], "user") == 0) { userprefspanel_cb(0,0); } else if (cmp_nocase(l[0], "bivhist") == 0) { showbivhist_cb(0,0); } else if (cmp_nocase(l[0], "progress") == 0) { showprogress_cb(0,0); } else if (cmp_nocase(l[0], "help") == 0) { onlinehelp_cb(0,0); } else { result = ActionResult[CMD_NODLG]; // unknown dialog return 1; } } return retval; } int imlink::perform(vector &l, string &result) { int retval = 0; if (l.size() < 2) { result = ActionResult[CMD_LOARG]; // short argument list return 1; } connection *imc = new connection; try { // create connection imc->address = l[0]; imc->portnumber = atoi(l[1].c_str()); dbgprintf("Making connection with imview on %s, port %d\n", (imc->address).c_str(), imc->portnumber); imc->stream = new TCPClientStream((imc->address).c_str(), imc->portnumber); // log in const char *p = getenv(uservar); // get the user name from the environment *(imc->stream) << "user " << p << endl; // get response string response; if (getline(*(imc->stream), response).good()) { dbgprintf("Line is OK\n"); if ((response.rfind(ActionResult[CMD_OK]) != string::npos)) { // all is good dbgprintf("Response is OK\n"); // make a new link manager if we don't have one now if (!imview_linkmanager) imview_linkmanager = new linkmanager; imview_linkmanager->save_connection(imc); } else { dbgprintf("Response not OK\n"); result = response + "\n" + ActionResult[CMD_CFAIL]; // connection failed retval = 1; } } else { result = response + "\n" + ActionResult[CMD_CFAIL]; // connection failed retval = 1; } } catch (const SocketRunTimeException &e) { result = ActionResult[CMD_ESOCK] + string(e.what()) + "\n"; // socket exception retval = 1; } if (retval > 0) { delete imc; } return retval; } int imunlink::perform(vector &l, string &result) { if (l.size() < 2) { result = ActionResult[CMD_LOARG]; // missing arguments return 1; } else { result = ActionResult[CMD_NOSYS]; // not implemented yet return 1; } // future work here... return 0; } int set_variable::perform(vector &l, string &result) { if (l.size() < 1) { result = ActionResult[CMD_LOARG]; // short argument list return 1; } else if (imview_interpreter->setVariable(l[0], l[1]) == 0) { return 0; } else { result = ActionResult[CMD_NOVAR]; // incorrect variable return 1; } } int get_variable::perform(vector &l, string &result) { if (imview_interpreter->getVariable(l[0], result) == 0) { return 0; } else { result = ActionResult[CMD_NOVAR]; // incorrect variable return 1; } } int list_variables::perform(vector &l, string &result) { result = imview_interpreter->listVariables(); return 0; } int tokenize::perform(vector &l, string &result) { ostringstream osm; for (unsigned int i = 0 ; i < l.size() ; ++i) osm << l[i] << " "; result = osm.str(); return 0; } // -------- The variables --------- extern bool useOffscreenBuff; void useoffscreenbuf::set (const string &stringval) { fromstr_convert(stringval, useOffscreenBuff); } string &useoffscreenbuf::get (void) { return tostr_convert(useOffscreenBuff); } string useoffscreenbuf::list(void) { ostringstream ost; ost << "useOffscreenBuff : = " << tostr_convert(useOffscreenBuff) << '\n'; return ost.str(); } extern bool lutWraparound; void lutwraparound::set (const string &stringval) { fromstr_convert(stringval, lutWraparound); if (lutWraparound) mainMenuBar->setFlagsByName(WRAPLUT_ITEM, FL_PUP_BOX | FL_MENU_VALUE); else mainMenuBar->setFlagsByName(WRAPLUT_ITEM, FL_PUP_BOX); mainMenuBar->redraw(); mainViewer->displayCurrentImage(); // stronger than just redisplay } string &lutwraparound::get (void) { return tostr_convert(lutWraparound); } string lutwraparound::list(void) { ostringstream ost; ost << "lutWraparound : = " << tostr_convert(lutWraparound) << '\n'; return ost.str(); } void syncdisplay::set (const string &stringval) { bool mydisplay; fromstr_convert(stringval, mydisplay); syncDisplay = mydisplay; if (syncDisplay) mainMenuBar->setFlagsByName(SYNCDISP_ITEM, FL_PUP_BOX | FL_MENU_VALUE); else mainMenuBar->setFlagsByName(SYNCDISP_ITEM, FL_PUP_BOX); mainMenuBar->redraw(); } string &syncdisplay::get (void) { return tostr_convert(syncDisplay); } string syncdisplay::list(void) { ostringstream ost; ost << "syncDisplay : = " << tostr_convert(syncDisplay) << '\n'; return ost.str(); } // controls whether the image always fill the window void imagewindowfit::set (const string &stringval) { int maybenextmode; fromstr_convert(stringval, maybenextmode); switch (maybenextmode) { case IMV_DISPLAY_WINDOW_FIT_IMG: mainMenuBar->setFlagsByName(WIN_FIT_IMG_ITEM, FL_MENU_RADIO | FL_MENU_VALUE); mainViewer->setdisplaymode(static_cast(maybenextmode)); break; case IMV_DISPLAY_IMG_FIT_WINDOW: mainMenuBar->setFlagsByName(IMG_FIT_WIN_ITEM, FL_MENU_RADIO | FL_MENU_VALUE); mainViewer->setdisplaymode(static_cast(maybenextmode)); break; case IMV_DISPLAY_DECOUPLE_WIN_IMG: mainMenuBar->setFlagsByName(DECOUPLE_IMG_WIN_ITEM, FL_MENU_RADIO | FL_MENU_VALUE); mainViewer->setdisplaymode(static_cast(maybenextmode)); break; default: dbgprintf("Diplay mode given (%d) is incorrect\n", maybenextmode); break; // don't change the display mode } mainMenuBar->redraw(); } string &imagewindowfit::get (void) { return tostr_convert(mainViewer->getdisplaymode()); } string imagewindowfit::list(void) { ostringstream ost; ost << "displaymode : = " << tostr_convert(mainViewer->getdisplaymode()) << '\n'; return ost.str(); } // list existing established connections string &connectionlist::get (void) { static string res; if (imview_linkmanager) res = imview_linkmanager->print_connections(); else res = "No connection"; // no connection -> no link manager (at least at init) return res; } string connectionlist::list(void) { ostringstream ost; int nb; if (imview_linkmanager) nb = imview_linkmanager->nb_connections(); else nb = 0; ost << "connectionList : = (" << nb ; if (nb > 1) ost << " connections) \n"; else ost << " connection) \n"; return ost.str(); } // -- conversion helper functions // we can't have this function return a bool because C++ // won't overload it unless bool is in the argument list... void fromstr_convert(const string &strval, bool &value) { if (cmp_nocase(strval, "true") == 0) value = true; else value = false; return; } string &tostr_convert(bool value) { if (value) return truestr; else return falsestr; } void fromstr_convert(const string &strval, int &value) { value = atoi(strval.c_str()); return; } string &tostr_convert(int value) { ostringstream result; static string mystr; //result.seekp(0); // rewind result << value; mystr = result.str(); return mystr; } // -------- The link manager --------- string linkmanager::print_connections(void) { ostringstream result; result << "Live connections:\n"; for (connectionIterator i = otherimview.begin() ; i != otherimview.end() ; ++i) { result << " Host: " << (*i)->address << " port : " << (*i)->portnumber << endl; } return result.str(); } int linkmanager::getresponse(TCPClientStream *stream) { int retval = 0; bool run; string message; // get response while (run = getline(*stream, message).good()) { if (message.rfind("000 OK") != string::npos) { dbgprintf("Response from stream: OK\n"); retval = 0; break; } else if ((message.rfind("500 Command failed") != string::npos) || (message.rfind("501 Unknown command") != string::npos)) { dbgprintf("Response from stream:\n%s\n", message.c_str()); retval = 2; break; } } if (!run) retval = 3; // server down return retval; } // duplicate current zoom box to all imview clients int linkmanager::zoombox(int x, int y, int w, int h) { int retval = 0; if (duplicate_action[ActionZoom]) { for (connectionIterator i = otherimview.begin() ; i != otherimview.end() ; ++i) { *((*i)->stream) << "zoom box " << x << " " << y << " " << w << " " << h << endl; retval = getresponse((*i)->stream); } } else { retval = 1; } return retval; } int linkmanager::zoomfactor(double zf) { int retval = 0; if (duplicate_action[ActionZoom]) { for (connectionIterator i = otherimview.begin() ; i != otherimview.end() ; ++i) { *((*i)->stream) << "zoom factor " << zf << endl; retval = getresponse((*i)->stream); } } else retval = 1; return retval; } int linkmanager::setDefaultZoomFactor(double f) { int retval = 0; if (duplicate_action[ActionZoom]) { for (connectionIterator i = otherimview.begin() ; i != otherimview.end() ; ++i) { *((*i)->stream) << "zoom default " << f << endl; retval = getresponse((*i)->stream); } } else retval = 1; return retval; } int linkmanager::resetDisplay(void) { int retval = 0; if (duplicate_action[ActionZoom]) { for (connectionIterator i = otherimview.begin() ; i != otherimview.end() ; ++i) { *((*i)->stream) << "reset" << endl; retval = getresponse((*i)->stream); } } else retval = 1; return retval; } // -------- The interpreter --------- interpreter::interpreter() { #ifdef HAVE_SYSV_IPC // this must be called before initializing any putm instance putm::setPathToEmpty(); #endif // associate tokens by hand tokens["quit"] = new quit; tokens["bye"] = new quit; tokens["end"] = new quit; tokens["exit"] = new quit; // I hope that's enough ways to quit! tokens["kill"] = new killme; // this is not the same thing: will terminate imview tokens["help"] = new interpreter_help; tokens["?"] = new interpreter_help; tokens["pf"] = new print_pointfile; tokens["user"] = new user; tokens["deny"] = new deny; tokens["put"] = new put; tokens["putm"] = new putm; tokens["ppath"] = new ppath; tokens["putp"] = new putp; tokens["labl"] = new set_appname; tokens["stpf"] = new set_pointfile; tokens["ldpf"] = new load_pointfile; tokens["svpf"] = new save_pointfile; tokens["clpf"] = new clear_pointfile; tokens["load"] = new load; tokens["move"] = new move; tokens["size"] = new size; tokens["cmap"] = new cmap; tokens["zoom"] = new zoom; tokens["pan"] = new pan; tokens["reset"] = new reset; tokens["close"] = new close_image; tokens["raise"] = new raise_window; tokens["icon"] = new iconize_window; tokens["hide"] = new hide_window; tokens["show"] = new show_window; tokens["set"] = new set_variable; tokens["get"] = new get_variable; tokens["list"] = new list_variables; tokens["toks"] = new tokenize; tokens["link"] = new imlink; tokens["unlk"] = new imunlink; // variables varnames["useoffscreenbuff"] = new useoffscreenbuf; varnames["lutwraparound"] = new lutwraparound; varnames["syncdisplay"] = new syncdisplay; varnames["displaymode"] = new imagewindowfit; varnames["connectionlist"] = new connectionlist; // read-only var // associate img type with string tr_img["IM_ERROR"] = IM_ERROR; tr_img["IM_UNSPEC"] = IM_UNSPEC; tr_img["IM_SINGLE"] = IM_SINGLE; tr_img["IM_SPECTRUM"] = IM_SPECTRUM; tr_img["IM_MULTI"] = IM_SPECTRUM; // at this stage, this is what we have to assume tr_img["IM_RGB"] = IM_RGB; tr_img["IM_HLS"] = IM_HLS; // associate pix type with string tr_pix["IM_BINARY"] = IM_BINARY; tr_pix["IM_CHAR"] = IM_CHAR; tr_pix["IM_INT1"] = IM_INT1; tr_pix["IM_UINT1"] = IM_UINT1; tr_pix["IM_SHORT"] = IM_SHORT; tr_pix["IM_INT2"] = IM_INT2; tr_pix["IM_UINT2"] = IM_UINT2; tr_pix["IM_INT"] = IM_INT; tr_pix["IM_INT4"] = IM_INT4; tr_pix["IM_UINT4"] = IM_UINT4; tr_pix["IM_INT8"] = IM_INT8; tr_pix["IM_UINT8"] = IM_UINT8; tr_pix["IM_FLOAT"] = IM_FLOAT; tr_pix["IM_DOUBLE"] = IM_DOUBLE; return; } interpreter::~interpreter() { // delete all the newed stuff map::iterator p; dbgprintf("Deleting all interpreter tokens\n"); for (p = tokens.begin() ; p != tokens.end() ; p++) delete p->second; tokens.clear(); // the rest is not so important tr_img.clear(); tr_pix.clear(); // get rid of connections to other imviews if (imview_linkmanager) delete imview_linkmanager; return; } // evaluate with arguments in a list (optional) void interpreter::evaluate(string &s, vector &args, string &result) { AMI p; int res; if ((p = tokens.find(s)) != tokens.end()) { action *any = p->second; res = any->perform(args, result); if (res == 0) result += ActionResult[CMD_OK] + string("\n"); // keyword! else if (res > 0) result += ActionResult[CMD_FAILD]; /// this is a keyword } else { ourcomplaint.perform(args,result); } } // The parser is called through the GUI via manage_command void interpreter::parseCommand(string &command, string &result) { string::size_type pos, startpos; string firstarg, nextarg, reststr; vector restarg(100); int i; // if command starts with white space, tough pos = command.find_first_of(" \r\t\n"); // whitespaces if (pos == 0) { result = ""; // command still needs to be set up return ; // commands starting with a white space are ignored. } firstarg = command.substr(0,pos); dbgprintf(" interpreter: first argument = (%s)\n", firstarg.c_str()); // rest of the arguments in a list, '\r' or '\n' indicates end of command i = 0; while ((pos != string::npos) && (command[pos] != '\r') && (command[pos] != '\n')) { startpos = command.find_first_not_of(" \t", pos); // skip to non-whitespace if (command[startpos] == '"') { // identify strings pos = command.find_first_of("\"\r\n", startpos+1); if (command[pos] != '"') { nextarg = command.substr(startpos+1, pos-startpos); // no trailing \" } else { nextarg = command.substr(startpos+1, pos-startpos-1); // we don't want the \" pos++; // go past the last \" } } else { pos = command.find_first_of(" \r\t\n", startpos); // whitespaces if (pos == startpos) break; // we have hit the end of the command, and it's all spaces. nextarg = command.substr(startpos, pos-startpos); } dbgprintf(" interpreter: next argument = (%s)\n", nextarg.c_str()); restarg[i++] = nextarg; // we should be using a push_back here } // OK, this is due to MINGW32 crapping out on push_back right here. Why? restarg.erase(restarg.begin()+i, restarg.end()); // This is weird, right? dbgprintf("Ready to evaluate\n"); evaluate(firstarg, restarg, result); return; } int interpreter::setVariable(const string &aVar, const string &value) { map::iterator p = varnames.find(aVar); if (p != varnames.end()) { variable *somevar = p->second; somevar->set (value); } else { return 1; } return 0; } int interpreter::getVariable(const string &aVar, string &value) { map::iterator p = varnames.find(aVar); if (p != varnames.end()) { variable *somevar = p->second; value = somevar->get () + "\n"; } else return 1; return 0; } string &interpreter::listVariables(void) { static string result; map::iterator p; result = ""; for (p = varnames.begin() ; p != varnames.end() ; p++) { variable *somevar = p->second; result += somevar->list(); } return result; } #endif // HAVE_PTHREADS imview-1.1.9c/server/interpreter.hxx0000644000076500007650000002623407726742375020427 0ustar talbottalbot00000000000000/* * $Id: interpreter.hxx,v 4.2 2003/09/07 23:53:33 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * * A minuscule interpreter for Imview, accessed through the socket * interface. * The idea is to be able to control the GUI from the command line, * so that: * 1- remote control of imview from another application is easy * 2- linking two or more imviews is a possibility * 3- regression testing of imview is possible. * * Hugues Talbot 1 Mar 2000 * *-----------------------------------------------------------------------*/ #ifndef INTERPRETER_H #define INTERPRETER_H #ifdef HAVE_PTHREADS #include #include #include #include #include #include #include #include "imview.hxx" #include "../nocase.hxx" #include "imserver.hxx" #include "socketstream.hxx" using std::vector; using std::string; using std::list; using std::map; using std::bitset; #define HEADER_ID_SIZE 8 // so that we align even for doubles // -------- all the actions ---------- class action { public: virtual int perform(vector &l, string &result) { cerr << "default action!" << endl; return 1;} // with a list of arguments virtual ~action() {} }; typedef map::iterator AMI; // action Map iterator class complain:public action { public: int perform(vector &l, string &result); }; class interpreter_help:public action { public: int perform(vector &l, string &result); }; class deny:public action{ public: int perform(vector &l, string &result); }; // much-needed authentication class user:public action{ string server_user; // who is running the server now? // static bool matches; public: user(void); // constructor // static bool unauthenticate(void) {matches = false;} // static bool authenticated(void) {return matches;} int perform(vector &l, string &result); }; class put:public action { private: static inline unsigned int swapid(int id); protected: static vector imh; static unsigned int id_pool; public: virtual int perform(vector &l, string &result); static int callback(void *buf, unsigned long nb); // will be called when the data is received static IMAGE_HEADER *find_header(const char *name); static IMAGE_HEADER *find_header(unsigned int given_id); static void delete_header(const char *name); static void delete_header(unsigned int given_id); static void delete_header(IMAGE_HEADER *myeader); }; class ppath:public action { public: int perform(vector &l, string &result); }; // declaration for mput is in imshared.H class cmap:public action { public: int perform(vector &l, string &result); }; class move:public action { public: int perform(vector &l, string &result); }; class size:public action { public: int perform(vector &l, string &result); }; class load:public action { public: int perform(vector &l, string &result); }; class zoom:public action { public: int perform(vector &l, string &result); }; class pan:public action { public: int perform(vector &l, string &result); }; class reset:public action { public: int perform(vector &l, string &result); }; class close_image:public action { public: int perform(vector &l, string &result); }; class quit:public action { public: int perform(vector &l, string &result); }; class killme:public action { public: int perform(vector &l, string &result); }; class print_pointfile:public action { public: int perform(vector &l, string &result); }; class set_appname:public action { public: int perform(vector &l, string &result); }; class set_pointfile:public action { public: int perform(vector &l, string &result); }; class load_pointfile:public action { public: int perform(vector &l, string &result); }; class save_pointfile:public action { public: int perform(vector &l, string &result); }; class clear_pointfile:public action { public: int perform(vector &l, string &result); }; class iconize_window:public action { public: int perform(vector &l, string &result); }; class raise_window:public action { public: int perform(vector &l, string &result); }; class hide_window:public action { public: int perform(vector &l, string &result); }; class show_window:public action { public: int perform(vector &l, string &result); }; class set_variable:public action { public: int perform(vector &l, string &result); }; class get_variable:public action { public: int perform(vector &l, string &result); }; class list_variables:public action { public: int perform(vector &l, string &result); }; class tokenize:public action { public: int perform(vector &l, string &result); }; // link to another imview class imlink:public action { public: int perform(vector &l, string &result); }; // unlink from another imview class imunlink:public action { public: int perform(vector &l, string &result); }; // -------- The variables --------- class variable { public: virtual void set(const string &stringval) = 0; virtual string &get(void) = 0; virtual string list(void) = 0; virtual ~variable() {} }; class useoffscreenbuf:public variable { public: void set(const string &stringval); string &get(void); string list(void); }; class lutwraparound:public variable { public: void set(const string &stringval); string &get(void); string list(void); }; class syncdisplay:public variable { public: void set(const string &stringval); string &get(void); string list(void); }; class connectionlist:public variable { public: void set(const string &stringval) {/* does nothing */}; string &get(void); string list(void); }; class imagewindowfit:public variable { public: void set(const string &stringval); string &get(void); string list(void); }; // -- conversion helper functions void fromstr_convert(const string &strval, bool &value); string &tostr_convert(bool value); void fromstr_convert(const string &strval, int &value); string &tostr_convert(int value); // -------- The interpreter --------- // connections to other imviews struct connection { string address; int portnumber; TCPClientStream *stream; connection() : stream(0) {}; ~connection() { delete stream ;} }; // this class should be a singleton // this class manages the links with other imviews // i.e: // - remembers which other imviews we are currently connected to // - sends actions to remote imviews class linkmanager { typedef vector::iterator connectionIterator; enum DupActions { ActionZoom = 0, // pan when the controller pans ActionPan, // zoom ... ActionMove, // move window around (keep same distance) ActionResize, // resize all windows ActionDialogs, // pop same dialogs ActionProfile, // draw profiles ActionColormap, // apply same colormap ActionQuit, // quit application ActionMax // MUST BE THE LAST ACTION }; vector otherimview; bitset duplicate_action; // actions to duplicate to other imviews when connected int getresponse(TCPClientStream *stream); public: linkmanager() { duplicate_action = 0xff; // all actions enabled } ~linkmanager() { // kill all connections for (connectionIterator i = otherimview.begin() ; i != otherimview.end() ; ++i) delete *i; } void save_connection(connection *c) {otherimview.push_back(c);} int nb_connections(void) { return otherimview.size(); } string print_connections(void); // real work under here int zoombox(int x, int y, int w, int h); int zoomfactor(double f); int setDefaultZoomFactor(double df); int resetDisplay(void); }; // this should be a singleton class interpreter { private: complain ourcomplaint; map tokens; map varnames; map tr_img; // this is only the declaration!! map tr_pix; vector otherimview; public: interpreter(); ~interpreter(); imgtype translate_img(string &type) { map::iterator p = tr_img.find(type); if (p != tr_img.end()) return p->second; else return IM_ERROR; } pixtype translate_pix(string &type) { map::iterator p = tr_pix.find(type); if (p != tr_pix.end()) return p->second; else return IM_INVALID; } void evaluate(string &s, vector &args, string &result); void parseCommand(string &command, string &result); int setVariable(const string &varname, const string &value); int getVariable(const string &varname, string &value); string &listVariables(void); }; #else // HAVE_PTHREADS // stubs class interpreter { public: // void evaluate(string &s, vector &args, string &result); //void parseCommand(string &command, string &result); //int setVariable(const string &varname, const string &value); //int getVariable(const string &varname, string &value); }; class linkmanager { public: int zoombox(int x, int y, int w, int h) { return 1;} int zoomfactor(double f) { return 1;} int setDefaultZoomFactor(double df) { return 1;} int resetDisplay(void) { return 1;} }; #endif // HAVE_PTHREADS #endif // INTERPRETER_H imview-1.1.9c/server/Makefile.in0000644000076500007650000000426010024306337017346 0ustar talbottalbot00000000000000# -*- Makefile -*- # Hand-generated makefile for the I/O parts of ImView # Hugues Talbot 23 Apr 1998 # SHELL = /bin/sh VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ subdirs = @subdirs@ top_srcdir = @top_srcdir@ srcdir = @srcdir@ bindir = $(exec_prefix)/bin infodir = $(prefix)/info libdir = $(prefix)/lib/gnudl mandir = $(prefix)/man/man1 # compilers and flags CC = @CC@ CXX = @CXX@ CPPFLAGS = @CPPFLAGS@ CFLAGS = $(CPPFLAGS) @CFLAGS@ CXXFLAGS = $(CPPFLAGS) @CXXFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ INSTALL = @INSTALL@ # program to make the archive: LIBNAME = @LIBNAME@ LIBCOMMAND = @LIBCOMMAND@ RANLIB = @RANLIB@ DSONAME = @DSONAME@ DSOCOMMAND = @DSOCOMMAND@ # extra stuff THREADLIB = @THREADLIB@ # extra linking stuff for some compilers LIBXTRA = @LIBXTRA@ # we are building a library TOP = ${top_srcdir} #include ${FLDIR}/makeinclude TARGET = imview_server.a # so as to include the class declarations and config.h CXXFLAGS += -I${TOP} -I.. # if there is no server, we only need to fake it CPPFILES = \ noimserver.cxx \ asynchat.cxx \ asyncore.cxx \ imserver.cxx \ semaphore.cxx \ interpreter.cxx \ imshared.cxx \ socketstream.cxx OBJECTS = $(CPPFILES:.cxx=.o) ## rules for C and H files to be generated from .fl files .SUFFIXES : .cxx .o .cc # DEC Unix has some .cc files to be included. Do not compile them .cc: @echo "Do nothing with $<" .cxx.o : $(CXX) $(CXXTRA) $(CXXFLAGS) -c $< $(TARGET) : $(OBJECTS) $(LIBCOMMAND) $(TARGET) $(OBJECTS) $(LIBXTRA) $(RANLIB) $(TARGET) all: $(TARGET) test: @echo "CPP files:\t" $(CPPFILES) @echo "Object files:\t" $(OBJECTS) @echo "Target: \t" $(TARGET) @echo "Libxtra: \t" $(LIBXTRA) clean: - @rm *.a *.o cxx_repository/*.o realclean: - @rm *.o *.a *~ *.da *.bb *.bbg .ix[0-9]* .inslog* @touch makedepend depend: $(CPPFILES) $(CFILES) $(CXX) $(CXXTRA) $(CXXFLAGS) -M $^ > makedepend makedepend: touch makedepend include makedepend # dependencies imview-1.1.9c/server/noimserver.cxx0000644000076500007650000000403607653237132020231 0ustar talbottalbot00000000000000/* * $Id: noimserver.cxx,v 4.0 2003/04/28 14:44:42 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Only compiled in if no server is available * * Hugues Talbot 8 Aug 2000 * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" #include "imview.hxx" #ifndef HAVE_PTHREADS void *init_server(int *) { warnprintf("Fake init_server called. How is that possible?\n"); return (void*)0; } #endif imview-1.1.9c/server/semaphore.cxx0000644000076500007650000001603307653237132020023 0ustar talbottalbot00000000000000/* * $Id: semaphore.cxx,v 4.0 2003/04/28 14:44:42 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /****************************************************************************\ * * Written by * Tom Wagner (wagner@cs.umass.edu) * at the Distributed Problem Solving Lab * Department of Computer Science, University of Massachusetts, * Amherst, MA 01003 * * Copyright (c) 1995 UMASS CS Dept. All rights are reserved. * * Development of this code was partially supported by: * ONR grant N00014-92-J-1450 * NSF contract CDA-8922572 * * --------------------------------------------------------------------------- * * This code is free software; you can redistribute it and/or modify it. * However, this header must remain intact and unchanged. Additional * information may be appended after this header. Publications based on * this code must also include an appropriate reference. * * This code 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. * \****************************************************************************/ #include "imview.hxx" #ifdef HAVE_PTHREADS // otherwise don't bother #include "machine.hxx" #include "semaphore.hxx" /* * function must be called prior to semaphore use. * */ void semaphore_init (Semaphore * s) { s->v = 1; if (pthread_mutex_init (&(s->mutex), pthread_mutexattr_default) == -1) errprintf ("Error setting up semaphore mutex"); if (pthread_cond_init (&(s->cond), pthread_condattr_default) == -1) errprintf ("Error setting up semaphore condition signal"); } /* * function should be called when there is no longer a need for * the semaphore. * */ void semaphore_destroy (Semaphore * s) { if (pthread_mutex_destroy (&(s->mutex)) == -1) errprintf ("Error destroying semaphore mutex"); if (pthread_cond_destroy (&(s->cond)) == -1) errprintf ("Error destroying semaphore condition signal"); } /* * function increments the semaphore and signals any threads that * are blocked waiting a change in the semaphore. * */ int semaphore_up (Semaphore * s) { int value_after_op; tw_pthread_mutex_lock (&(s->mutex)); (s->v)++; value_after_op = s->v; tw_pthread_mutex_unlock (&(s->mutex)); tw_pthread_cond_signal (&(s->cond)); return (value_after_op); } /* * function decrements the semaphore and blocks if the semaphore is * <= 0 until another thread signals a change. * */ int semaphore_down (Semaphore * s) { int value_after_op; tw_pthread_mutex_lock (&(s->mutex)); while (s->v <= 0) { tw_pthread_cond_wait (&(s->cond), &(s->mutex)); } (s->v)--; value_after_op = s->v; tw_pthread_mutex_unlock (&(s->mutex)); return (value_after_op); } /* * function does NOT block but simply decrements the semaphore. * should not be used instead of down -- only for programs where * multiple threads must up on a semaphore before another thread * can go down, i.e., allows programmer to set the semaphore to * a negative value prior to using it for synchronization. * */ int semaphore_decrement (Semaphore * s) { int value_after_op; tw_pthread_mutex_lock (&(s->mutex)); s->v--; value_after_op = s->v; tw_pthread_mutex_unlock (&(s->mutex)); return (value_after_op); } /* * function returns the value of the semaphore at the time the * critical section is accessed. obviously the value is not guarenteed * after the function unlocks the critical section. provided only * for casual debugging, a better approach is for the programmar to * protect one semaphore with another and then check its value. * an alternative is to simply record the value returned by semaphore_up * or semaphore_down. * */ int semaphore_value (Semaphore * s) { /* not for sync */ int value_after_op; tw_pthread_mutex_lock (&(s->mutex)); value_after_op = s->v; tw_pthread_mutex_unlock (&(s->mutex)); return (value_after_op); } /* -------------------------------------------------------------------- */ /* The following functions replace standard library functions in that */ /* they exit on any error returned from the system calls. Saves us */ /* from having to check each and every call above. */ /* -------------------------------------------------------------------- */ int tw_pthread_mutex_unlock (pthread_mutex_t * m) { int return_value; if ((return_value = pthread_mutex_unlock (m)) == -1) errprintf ("pthread_mutex_unlock"); return (return_value); } int tw_pthread_mutex_lock (pthread_mutex_t * m) { int return_value; if ((return_value = pthread_mutex_lock (m)) == -1) errprintf ("pthread_mutex_lock"); return (return_value); } int tw_pthread_cond_wait (pthread_cond_t * c, pthread_mutex_t * m) { int return_value; if ((return_value = pthread_cond_wait (c, m)) == -1) errprintf ("pthread_cond_wait"); return (return_value); } int tw_pthread_cond_signal (pthread_cond_t * c) { int return_value; if ((return_value = pthread_cond_signal (c)) == -1) errprintf ("pthread_cond_signal"); return (return_value); } #endif // HAVE_PTHREADS imview-1.1.9c/server/semaphore.hxx0000644000076500007650000000725707653237132020040 0ustar talbottalbot00000000000000/* * $Id: semaphore.hxx,v 4.0 2003/04/28 14:44:42 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /****************************************************************************\ * * Written by * Tom Wagner (wagner@cs.umass.edu) * at the Distributed Problem Solving Lab * Department of Computer Science, University of Massachusetts, * Amherst, MA 01003 * * Copyright (c) 1995 UMASS CS Dept. All rights are reserved. * * Development of this code was partially supported by: * ONR grant N00014-92-J-1450 * NSF contract CDA-8922572 * * --------------------------------------------------------------------------- * * This code is free software; you can redistribute it and/or modify it. * However, this header must remain intact and unchanged. Additional * information may be appended after this header. Publications based on * this code must also include an appropriate reference. * * This code 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. * \****************************************************************************/ #ifndef SEMAPHORES_H #define SEMAPHORES_H #ifdef HAVE_PTHREADS #include typedef struct Semaphore { int v; pthread_mutex_t mutex; pthread_cond_t cond; } Semaphore; int semaphore_down (Semaphore * s); int semaphore_decrement (Semaphore * s); int semaphore_up (Semaphore * s); void semaphore_destroy (Semaphore * s); void semaphore_init (Semaphore * s); int semaphore_value (Semaphore * s); int tw_pthread_cond_signal (pthread_cond_t * c); int tw_pthread_cond_wait (pthread_cond_t * c, pthread_mutex_t * m); int tw_pthread_mutex_unlock (pthread_mutex_t * m); int tw_pthread_mutex_lock (pthread_mutex_t * m); #endif #endif //SEMAPHORE_H imview-1.1.9c/server/socketstream.cxx0000644000076500007650000001341707653237132020547 0ustar talbottalbot00000000000000// // socketstream.cxx, derived from Socket.cpp by Maciej Sobczak // C/C++ User Journal, December 2001. // Modified by Hugues Talbot to allow for a timeout on read. // // this file contains the wrappers (implementation) // that can be used as a iostream-compatible TCP/IP sockets // // on Windows the program that uses this library // should be linked with Ws2_32.lib // // Copyright (C) 2001 Maciej Sobczak // // you can use this code for any purpose without limitations // (and for your own risk) as long as this notice remains // #include #include "socketstream.hxx" using namespace std; // class SocketException SocketRunTimeException::SocketRunTimeException(const string &what) : runtime_error(what) { #ifdef WIN32_NOTCYGWIN errnum = ::WSAGetLastError(); #else errnum = errno; #endif } const char * SocketRunTimeException::what() const throw() { ostringstream ss; ss << runtime_error::what(); ss << ", " << strerror(errnum); msg = ss.str(); return msg.c_str(); } // class TCPSocketWrapper::TCPAcceptedSocket TCPSocketWrapper::TCPAcceptedSocket::TCPAcceptedSocket (socket_type s, sockaddr_in a) : sock(s), addr(a) { } // class TCPSocketWrapper TCPSocketWrapper::TCPSocketWrapper() : sockstate(CLOSED) { } TCPSocketWrapper::TCPSocketWrapper (const TCPSocketWrapper::TCPAcceptedSocket &as) : sock(as.sock), sockaddress(as.addr), sockstate(ACCEPTED) { } TCPSocketWrapper::~TCPSocketWrapper() { if (sockstate != CLOSED) { #ifdef WIN32_NOTCYGWIN closesocket(sock); #else ::close(sock); #endif } } void TCPSocketWrapper::listen(int port, int backlog) { if (sockstate != CLOSED) throw SocketLogicException("socket not in CLOSED state"); sock = socket(AF_INET, SOCK_STREAM, 0); if (sock == INVALID_SOCKET) { throw SocketRunTimeException("socket failed"); } sockaddr_in local; memset(&local, 0, sizeof(local)); local.sin_family = AF_INET; local.sin_port = htons((u_short)port); local.sin_addr.s_addr = htonl(INADDR_ANY); if (::bind(sock, (sockaddr*)&local, sizeof(local)) == SOCKET_ERROR) throw SocketRunTimeException("bind failed"); if (::listen(sock, backlog) == SOCKET_ERROR) throw SocketRunTimeException("listen failed"); memset(&sockaddress, 0, sizeof(sockaddress)); sockstate = LISTENING; } TCPSocketWrapper::TCPAcceptedSocket TCPSocketWrapper::accept() { if (sockstate != LISTENING) throw SocketLogicException("socket not listening"); sockaddr_in from; #ifdef ACCEPT_USES_SOCKLEN_T socklen_t len = sizeof(from); #else int len = sizeof(from); #endif memset(&from, 0, len); socket_type newsocket = ::accept(sock, (sockaddr*)&from, &len); if (newsocket == INVALID_SOCKET) throw SocketRunTimeException("accept failed"); return TCPAcceptedSocket(newsocket, from); } void TCPSocketWrapper::connect(const char *address, int port) { if (sockstate != CLOSED) throw SocketLogicException("socket not in CLOSED state"); sock = socket(AF_INET, SOCK_STREAM, 0); if (sock == INVALID_SOCKET) { throw SocketRunTimeException("socket failed"); } hostent *hp; unsigned long addr = inet_addr(address); if (addr != INADDR_NONE) hp = gethostbyaddr((const char*)&addr, 4, AF_INET); else hp = gethostbyname(address); if (hp == NULL) throw SocketRunTimeException("cannot resolve address"); if (hp->h_addrtype != AF_INET) throw SocketRunTimeException ("address resolved with TCP incompatible type"); memset(&sockaddress, 0, sizeof(sockaddress)); memcpy(&(sockaddress.sin_addr), hp->h_addr_list[0], hp->h_length); sockaddress.sin_family = AF_INET; sockaddress.sin_port = htons((u_short)port); if (::connect(sock, (sockaddr*)&sockaddress, sizeof(sockaddress)) == SOCKET_ERROR) throw SocketRunTimeException("connect failed"); sockstate = CONNECTED; } const char * TCPSocketWrapper::address() const { if (sockstate != CONNECTED && sockstate != ACCEPTED) throw SocketLogicException("socket not connected"); return inet_ntoa(sockaddress.sin_addr); } int TCPSocketWrapper::port() const { if (sockstate != CONNECTED && sockstate != ACCEPTED) throw SocketLogicException("socket not connected"); return ntohs(sockaddress.sin_port); } void TCPSocketWrapper::write(const void *buf, int len) { if (sockstate != CONNECTED && sockstate != ACCEPTED) throw SocketLogicException("socket not connected"); int written; while (len > 0) { if ((written = send(sock, (const char*)buf, len, 0)) == SOCKET_ERROR) throw SocketRunTimeException("write failed"); len -= written; buf = (const char*)buf + written; } } int TCPSocketWrapper::read(void *buf, int len) { if (sockstate != CONNECTED && sockstate != ACCEPTED) throw SocketLogicException("socket not connected"); int readn = recv(sock, (char*)buf, len, 0); if (readn == SOCKET_ERROR) throw SocketRunTimeException("read failed"); return readn; } void TCPSocketWrapper::close() { if (sockstate != CLOSED) { #ifdef WIN32_NOTCYGWIN if (closesocket(sock) == SOCKET_ERROR) throw SocketRunTimeException("close failed"); #else if (::close(sock)) throw SocketRunTimeException("close failed"); #endif sockstate = CLOSED; } } bool socketsInit() { #ifdef WIN32_NOTCYGWIN WSADATA wsadata; if (WSAStartup(MAKEWORD(2, 0), &wsadata) == 0) return true; else return false; #else // Linux/Unix do not require any initialization return true; #endif } void socketsEnd() { #ifdef WIN32_NOTCYGWIN // we do not care about the error codes // anyway, we end the program WSACleanup(); #endif } imview-1.1.9c/server/socketstream.hxx0000644000076500007650000003111710064353032020535 0ustar talbottalbot00000000000000// // socketstream.h // // this file contains the wrappers that can be used // as a iostream-compatible TCP/IP sockets // // on Windows the program that uses this utility // should be linked with Ws2_32.lib // // Copyright (C) 2001 Maciej Sobczak // // you can use this code for any purpose without limitations // (and for your own risk) as long as this notice remains // #ifndef SOCKETSTREAMS_H #define SOCKETSTREAMS_H #include "imcfg.h" #ifndef WIN32_NOTCYGWIN // this is for Unix #include #include #include #include #include #include #include #include #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #ifndef INADDR_NONE # define INADDR_NONE ((in_addr_t) 0xffffffff) #endif #else // this is for MS Windows #include typedef int socklen_t; #endif #include /* old guard pseudo standard library */ #if (defined(__GNUC__) && (__GNUC__ < 3)) # include #else # include #endif #include #include using std::streambuf; using std::iostream; // exception class which designates errors from socket functions class SocketRunTimeException : public std::runtime_error { public: explicit SocketRunTimeException(const std::string &what); virtual const char * what() const throw(); int errornumber() const throw() { return errnum; } ~SocketRunTimeException() throw () { } private: // this will serve as a message returned from what() mutable std::string msg; int errnum; }; // exception class which designates logic (programming) errors with sockets class SocketLogicException : public std::logic_error { public: explicit SocketLogicException(const std::string &what) : std::logic_error(what) { } }; // this class serves as a socket wrapper class TCPSocketWrapper { #ifdef WIN32_NOTCYGWIN // on Windows, socket is represented by the opaque handler typedef SOCKET socket_type; #else // on Linux, socket is just a descriptor number typedef int socket_type; #endif // proxy helper for syntax: // Sock s2(s1.accept()); class TCPAcceptedSocket { private: TCPAcceptedSocket(socket_type s, sockaddr_in a); // copy not provided for the proxy TCPAcceptedSocket(const TCPAcceptedSocket &) {} TCPAcceptedSocket& operator=(const TCPAcceptedSocket &) {} socket_type sock; sockaddr_in addr; friend class TCPSocketWrapper; }; public: enum sockstate_type { CLOSED, LISTENING, ACCEPTED, CONNECTED }; TCPSocketWrapper(); ~TCPSocketWrapper(); // this is provided for syntax // TCPSocketWrapper s2(s2.accept()); TCPSocketWrapper(const TCPAcceptedSocket &as); // server methods // binds and listens on a given port number void listen(int port, int backlog = 100); // accepts the new connection // it requires the earlier call to listen TCPAcceptedSocket accept(); // client methods // creates the new connection void connect(const char *address, int port); // general methods // get the current state of the socket wrapper sockstate_type state() const { return sockstate; } // get the network address and port number of the socket const char * address() const; int port() const; // write data to the socket void write(const void *buf, int len); // read data from the socket // returns the number of bytes read int read(void *buf, int len); void close(); private: // not for use TCPSocketWrapper(const TCPSocketWrapper&); TCPSocketWrapper& operator=(const TCPSocketWrapper&); socket_type sock; sockaddr_in sockaddress; sockstate_type sockstate; }; #ifdef HAVE_STANDARD_CHAR_TRAITS // this class is supposed to serve as a stream buffer associated with a socket template > class TCPStreamBuffer : public std::basic_streambuf { typedef std::basic_streambuf sbuftype; typedef typename sbuftype::int_type int_type; typedef charT char_type; public: // the buffer will take ownership of the socket (ie. it will close it // in the destructor) if takeowner == true explicit TCPStreamBuffer(TCPSocketWrapper &sock, bool takeowner = false, std::streamsize bufsize = 512) : rsocket_(sock), ownsocket_(takeowner), bufsize_(bufsize), inbuf_(NULL), outbuf_(NULL), remained_(0), ownbuffers_(false) { } ~TCPStreamBuffer() { if (rsocket_.state() == TCPSocketWrapper::CONNECTED || rsocket_.state() == TCPSocketWrapper::ACCEPTED) _flush(); if (ownbuffers_) { delete [] inbuf_; delete [] outbuf_; } if (ownsocket_ == true) rsocket_.close(); } protected: sbuftype * setbuf(char_type *s, std::streamsize n) { if (this->gptr() == NULL) { setg(s, s + n, s + n); setp(s, s + n); inbuf_ = s; outbuf_ = s; bufsize_ = n; ownbuffers_ = false; } return this; } void _flush() { rsocket_.write(outbuf_, (this->pptr() - outbuf_) * sizeof(char_type)); } int_type overflow(int_type c = traits::eof()) { // this method is supposed to flush the put area of the buffer // to the I/O device // if the buffer was not already allocated nor set by user, // do it just now if (this->pptr() == NULL) { outbuf_ = new char_type[bufsize_]; ownbuffers_ = true; } else { _flush(); } setp(outbuf_, outbuf_ + bufsize_); if (c != traits::eof()) sputc(traits::to_char_type(c)); return 0; } int sync() { // just flush the put area _flush(); setp(outbuf_, outbuf_ + bufsize_); return 0; } int_type underflow() { // this method is supposed to read some bytes from the I/O device // if the buffer was not already allocated nor set by user, // do it just now if (this->gptr() == NULL) { inbuf_ = new char_type[bufsize_]; ownbuffers_ = true; } if (remained_ != 0) inbuf_[0] = remainedchar_; int readn = rsocket_.read(static_cast(inbuf_) + remained_, bufsize_ * sizeof(char_type) - remained_); // if (readn == 0 && remained_ != 0) // error - there is not enough bytes for completing // the last character before the end of the stream // - this can mean error on the remote end if (readn == 0) return traits::eof(); int totalbytes = readn + remained_; setg(inbuf_, inbuf_, inbuf_ + totalbytes / sizeof(char_type)); remained_ = totalbytes % sizeof(char_type); if (remained_ != 0) remainedchar_ = inbuf_[totalbytes / sizeof(char_type)]; return this->sgetc(); } private: // not for use TCPStreamBuffer(const TCPStreamBuffer&); TCPStreamBuffer& operator=(const TCPStreamBuffer&); TCPSocketWrapper &rsocket_; bool ownsocket_; std::streamsize bufsize_; char_type *inbuf_; char_type *outbuf_; int remained_; char_type remainedchar_; bool ownbuffers_; }; // this class is an ultimate stream associated with a socket template > class TCPGenericStream : private TCPStreamBuffer, public std::basic_iostream { public: // this constructor takes 'ownership' of the socket wrapper if btakeowner == true, // so that the socket will be closed in the destructor of the // TCPStreamBuffer object explicit TCPGenericStream(TCPSocketWrapper &sock, bool takeowner = false) : TCPStreamBuffer(sock, takeowner), std::basic_iostream(this) { } private: // not for use TCPGenericStream(const TCPGenericStream&); TCPGenericStream& operator=(const TCPGenericStream&); }; // this is even more specialized for use as a client template > class TCPGenericClientStream : private TCPSocketWrapper, public TCPGenericStream { public: TCPGenericClientStream(const char *address, int port) : TCPGenericStream(*this, false) { TCPSocketWrapper::connect(address, port); } private: // not for use TCPGenericClientStream(const TCPGenericClientStream&); TCPGenericClientStream& operator=(const TCPGenericClientStream&); }; // helper declarations for narrow and wide streams typedef TCPGenericStream TCPStream; typedef TCPGenericStream TCPWStream; typedef TCPGenericClientStream TCPClientStream; typedef TCPGenericClientStream TCPWClientStream; #else // HAVE_STANDARD_CHAR_TRAITS // NO TRAITS HERE, Hmmkeay? // narrow stream buffer only. // this class is supposed to serve as a stream buffer associated with a socket class TCPStreamBuffer : public streambuf { typedef streambuf sbuftype; typedef int int_type; typedef char char_type; public: // the buffer will take ownership of the socket (ie. it will close it // in the destructor) if takeowner == true explicit TCPStreamBuffer(TCPSocketWrapper &sock, bool takeowner = false, std::streamsize bufsize = 512) : rsocket_(sock), ownsocket_(takeowner), bufsize_(bufsize), inbuf_(NULL), outbuf_(NULL), remained_(0), ownbuffers_(false) { } ~TCPStreamBuffer() { if (rsocket_.state() == TCPSocketWrapper::CONNECTED || rsocket_.state() == TCPSocketWrapper::ACCEPTED) _flush(); if (ownbuffers_) { delete [] inbuf_; delete [] outbuf_; } if (ownsocket_ == true) rsocket_.close(); } protected: sbuftype * setbuf(char_type *s, std::streamsize n) { if (gptr() == NULL) { setg(s, s + n, s + n); setp(s, s + n); inbuf_ = s; outbuf_ = s; bufsize_ = n; ownbuffers_ = false; } return this; } void _flush() { rsocket_.write(outbuf_, (pptr() - outbuf_) * sizeof(char_type)); } int sync() { // just flush the put area _flush(); setp(outbuf_, outbuf_ + bufsize_); return 0; } private: // not for use TCPStreamBuffer(const TCPStreamBuffer&); TCPStreamBuffer& operator=(const TCPStreamBuffer&); TCPSocketWrapper &rsocket_; bool ownsocket_; std::streamsize bufsize_; char_type *inbuf_; char_type *outbuf_; int remained_; char_type remainedchar_; bool ownbuffers_; }; // this class is an ultimate stream associated with a socket class TCPGenericStream : private TCPStreamBuffer, public iostream { public: // this constructor takes 'ownership' of the socket wrapper if btakeowner == true, // so that the socket will be closed in the destructor of the // TCPStreamBuffer object explicit TCPGenericStream(TCPSocketWrapper &sock, bool takeowner = false) : TCPStreamBuffer(sock, takeowner), iostream(this) { } private: // not for use TCPGenericStream(const TCPGenericStream&); TCPGenericStream& operator=(const TCPGenericStream&); }; // this is even more specialized for use as a client class TCPGenericClientStream : private TCPSocketWrapper, public TCPGenericStream { public: TCPGenericClientStream(const char *address, int port) : TCPGenericStream(*this, false) { TCPSocketWrapper::connect(address, port); } private: // not for use TCPGenericClientStream(const TCPGenericClientStream&); TCPGenericClientStream& operator=(const TCPGenericClientStream&); }; // helper declarations for narrow streams typedef TCPGenericStream TCPStream; typedef TCPGenericClientStream TCPClientStream; // no possibility of wide stream with this reduced STL version #endif // HAVE_STANDARD_CHAR_TRAITS // 'portable' code should call those on the beginning and end of the program // (Linux/Unix code does not require any initialization and cleanup) bool socketsInit(); // returns true in success void socketsEnd(); #endif // SOCKETSTREAMS imview-1.1.9c/simpleViewer.cxx0000644000076500007650000000531610211621417017172 0ustar talbottalbot00000000000000/* * $Id: simpleViewer.cxx,v 4.1 2005/03/03 14:45:35 hut66au Exp $ * * Imview, The Portable Image Analysis Application * Http://Www.Cmis.Csiro.Au/Hugues.Talbot/Imview * ---------------------------------------------------------- * * Imview Is An Attempt To Provide An Image Display Application * Suitable For Professional Image Analysis. It Was Started In * 1997 And Is Mostly The Result Of The Efforts Of Hugues Talbot, * Image Analysis Project, Csiro Mathematical And Information * Sciences, With Help From Others (See The Credits Files For * More Information) * * Imview Is Copyrighted (C) 1997-2005 By The Australian Commonwealth * Science And Industry Research Organisation (Csiro). Please See The * Copyright File For Full Details. Imview Also Includes The * Contributions Of Many Others. Please See The Credits File For Full * Details. * * 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 Program; If Not, Write To The Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, Ma 02111, Usa. * */ /*------------------------------------------------------------------------ * * A simpler viewer class, suitable for the 3D viewer * * This time (unlike with imageViewer) I'll strive for as little coupling * as necessary... * * Hugues Talbot 2 Mar 2005 * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" // namespace definitions etc. #include #include "imview.hxx" #include "imageIO.hxx" #include "simpleViewer.hxx" simpleViewer::simpleViewer(int x, int y, int w, int h, const char *label) : Fl_Group(x,y,w,h,label) { dbgprintf("SimpleViewer constructor called with arg: (%d,%d)-(%dx%d)\n", x,y,w,h); theImage = 0; whichView = simpleview_top; // by default } simpleViewer::~simpleViewer() { dbgprintf("Image Viewer destructor called\n"); // delete all the objects } void simpleViewer::zapImageObject(void) { if (imageObject) { delete imageObject; imageObject = 0; } return; } void simpleViewer::draw() { dbgprintf("SimpleViewer drawing routine\n"); fl_color(FL_BLACK); fl_rect(x(),y(),w(),h()); } imview-1.1.9c/simpleViewer.hxx0000644000076500007650000000466010211621417017200 0ustar talbottalbot00000000000000/* * $Id: simpleViewer.hxx,v 4.1 2005/03/03 14:45:35 hut66au Exp $ * * Imview, The Portable Image Analysis Application * Http://Www.Cmis.Csiro.Au/Hugues.Talbot/Imview * ---------------------------------------------------------- * * Imview Is An Attempt To Provide An Image Display Application * Suitable For Professional Image Analysis. It Was Started In * 1997 And Is Mostly The Result Of The Efforts Of Hugues Talbot, * Image Analysis Project, Csiro Mathematical And Information * Sciences, With Help From Others (See The Credits Files For * More Information) * * Imview Is Copyrighted (C) 1997-2005 By The Australian Commonwealth * Science And Industry Research Organisation (Csiro). Please See The * Copyright File For Full Details. Imview Also Includes The * Contributions Of Many Others. Please See The Credits File For Full * Details. * * 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 Program; If Not, Write To The Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, Ma 02111, Usa. * */ /*------------------------------------------------------------------------ * * A simpler viewer class, suitable for the 3D viewer * * * *-----------------------------------------------------------------------*/ #ifndef SIMPLEVIEWER_H #define SIMPLEVIEWER_H #include #include #include #include #include "imview.hxx" #include "imageIO.hxx" typedef enum {simpleview_top=0, simpleview_left, simpleview_bottom} SIMPLEVIEW; class simpleViewer: public Fl_Group { public: simpleViewer(int x, int y, int w, int h, const char *label=0); ~simpleViewer(); // has to be implemented void draw(); private: void zapImageObject(void); private: Fl_RGB_Image *imageObject; imageIO *theImage; SIMPLEVIEW whichView; }; #endif // SIMPLEVIEWER_H imview-1.1.9c/sliceSlider.cxx0000644000076500007650000000711707665653123017004 0ustar talbottalbot00000000000000/* * $Id: sliceSlider.cxx,v 1.2 2003/05/30 13:02:11 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A simple linked slider/value panel * * Hugues Talbot 29 May 2003 * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" // name space and everything... #include #include "imview.hxx" #include "menubar.hxx" #include "sliceSlider.hxx" slideinput::slideinput() { dbgprintf("Slide input panel constructed\n"); // must be done (Fluid depens on it) sliceWindow = 0; return; } void slideinput::setDefaults() { dbgprintf("Setting defaults for slide input\n"); ((Fl_Valuator*)sliceSlider)->value(0.0); minSlice=1; maxSlice=1; displayslice = 0; // NULL callback sliceSlider->step(1.0); sliceSlider->linesize(1); // step of the arrow keys sliceValue->step(1.0); } void slideinput::setLimits(int minslice, int maxslice) { minSlice = minslice; maxSlice = maxslice; sliceSlider->bounds(minslice, maxslice); sliceSlider->range(minslice, maxslice); sliceValue->bounds(minslice, maxslice); sliceValue->range(minslice, maxslice); } void slideinput::setSlice(int v) { ((Fl_Valuator*)sliceSlider)->value(v); sliceValue->value(v); // expensive call if (displayslice) displayslice(v); } void slideinput::setWindowTitle(const char *title) { sliceWindow->label(title); } void slideinput::setValueTitle(const char *title) { sliceValue->label(title); } bool slideinput::visible() { return (sliceWindow->visible() != 0); } void slideinput::show() { sliceWindow->show(); } void slideinput::hide() { sliceWindow->hide(); } void sliceslider_cb(Fl_Scrollbar *i, slideinput *panel) { panel->setSlice(i->value()); } void slicevalue_cb(Fl_Value_Input *i, slideinput *panel) { panel->setSlice((int)(i->value())); } void okbutton_cb(Fl_Return_Button *, slideinput *panel) { dbgprintf("Dismiss button pressed on slide input panel\n"); panel->hide(); return; } imview-1.1.9c/sliceSlider.hxx0000644000076500007650000000533607665653123017012 0ustar talbottalbot00000000000000/* * $Id: sliceSlider.hxx,v 1.2 2003/05/30 13:02:11 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A simple linked slider/value panel * * Hugues Talbot 29 May 2003 * *-----------------------------------------------------------------------*/ #ifndef SLICESLIDER_H #define SLICESLIDER_H #include #include #include #include #include typedef void (*cb_slice)(int v); class slideinput { public: slideinput(); void setDefaults(); void setSlice(int v); int getSlice(void) {return sliceSlider->value();} void setLimits(int minslice, int maxslice); void setWindowTitle(const char *title); void setValueTitle(const char *title); void setSliceCB(cb_slice f) {displayslice = f;} // callback bool visible(); void show(); void hide(); friend Fl_Window *slider_panel(slideinput &p); private: Fl_Window *sliceWindow; Fl_Scrollbar *sliceSlider; Fl_Value_Input *sliceValue; int minSlice, maxSlice; cb_slice displayslice; }; #endif // SLICESLIDER_H imview-1.1.9c/spectraBox.cxx0000644000076500007650000001666507653236503016660 0ustar talbottalbot00000000000000/* * $Id: spectraBox.cxx,v 4.0 2003/04/28 14:40:03 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The code for the spectrum display panel * * Hugues Talbot 1 Aug 1998 * *-----------------------------------------------------------------------*/ #include #include "imview.hxx" #include "spectraBox.hxx" #include "saveSpect.hxx" #include "printSpect.hxx" extern savespect *saveSpectPanel; extern printspect *printSpectPanel; void mySpectraBox::setSpectrum(double *theSpectrum, int nbval) { if (theSpectrum != 0) { if (spectrum) delete[] spectrum; spectrum = new double[nbval]; memcpy(spectrum, theSpectrum, nbval*sizeof(double)); nbSpectrumValues = nbval; recomputeLimits(); } else { if (spectrum) delete[] spectrum; spectrum = 0; nbSpectrumValues = 0; } return; } void mySpectraBox::recomputeLimits(void) { if (spectrum) { if (!absolute) mins = maxs = spectrum[0]; // else they have already been set to 0 for (int i = 1 ; i < nbSpectrumValues ; i++) { if (spectrum[i] > maxs) maxs = spectrum[i]; if (spectrum[i] < mins) mins = spectrum[i]; } // special case of the char values. if (absolute && (mins >= 0.0) && (maxs <= 255.0)) { mins = 0.0; maxs = 255.0; } // what if they are both equal? if (maxs == mins) maxs = 1.0; if (theSpectra) { theSpectra->setAxisBoxesLimits(0, nbSpectrumValues, mins, maxs); } } return; } int mySpectraBox::handle(int event) { int retval = 0; int button; if (spectrum) { button = Fl::event_button(); switch (event) { case FL_PUSH: handleButtonPushed(); retval = 1; break; case FL_DRAG: handleButtonDragged(); retval = 1; break; case FL_RELEASE: handleButtonReleased(); retval = 1; break; case FL_LEAVE: // Return to normal cursor fl_cursor(FL_CURSOR_DEFAULT); retval = 1; break; default: retval = 0; break; } } return retval; } void mySpectraBox::handleButtonPushed() { fl_cursor((Fl_Cursor)MY_CURSOR_VLINE); handleButtonDragged(); return; } void mySpectraBox::handleButtonDragged() { int index; int xx = Fl::event_x(); int realwidth = w() - WIDTHMARGIN; index = (int)(((double)xx-x()-WIDTHMARGIN/2)*(nbSpectrumValues-1)/realwidth); if ((index >= 0) && (index < nbSpectrumValues) && theSpectra) { theSpectra->setXValue(index); theSpectra->setYValue(spectrum[index]); } return; } void mySpectraBox::handleButtonReleased() { fl_cursor(FL_CURSOR_DEFAULT); return; } void mySpectraBox::draw() { // superclass draw: draw_box(); draw_label(); if (spectrum != 0) { int xa, ya, xb, yb; int realwidth = w() - WIDTHMARGIN; int realheight = h() - HEIGHTMARGIN; fl_clip(x(),y(),w(),h()); fl_color(FL_BLACK); for (int i = 1 ; i < nbSpectrumValues ; i++) { xa = ((i-1)*realwidth)/(nbSpectrumValues-1) + WIDTHMARGIN/2; ya = (int)((1.0 - (spectrum[i-1]-mins)/(maxs-mins))*realheight) + HEIGHTMARGIN/2; xb = (i*realwidth)/(nbSpectrumValues - 1) + WIDTHMARGIN/2; yb = (int)((1.0 - (spectrum[i]-mins)/(maxs-mins))*realheight) + HEIGHTMARGIN/2; dbgprintf("Drawing from: (%d, %d) to (%d, %d)\n", xa, ya, xb, yb); fl_line(xa+x(), ya+y(), xb+x(), yb+y()); } fl_pop_clip(); } return; } /// The spectra stuff spectra::spectra() { dbgprintf("Spectra display dialog created\n"); spectraWindow = 0; // fluid depends on that spectraBox = 0; return; } void spectra::setDefaults(void) { // we display relative values by default relative->set(); // button appearance spectraBox->setRelative(); // set the variable correctly spectrumTitle->value("Position: undefined"); xvalue->value("0"); yvalue->value("0"); // the spectraBox needs to know us spectraBox->setSpectra(this); return; } // pass on the data... void spectra::setData(double *s, int nb, int x, int y) { static char buff[100]; spectraBox->setSpectrum(s,nb); sprintf(buff, "Position: x=%d, y=%d", x, y); xIm = x; yIm = y; spectrumTitle->value(buff); return; } int spectra::visible() { return spectraWindow->visible(); } void spectra::redraw() { spectraBox->redraw(); return; } void spectra::show() { spectraWindow->show(); } void spectra::hide() { spectraWindow->hide(); } void spectra::setAxisBoxesLimits(double xminlimit, double xmaxlimit, double yminlimit, double ymaxlimit) { abcissaBox->setRange(xminlimit, xmaxlimit); ordinateBox->setRange(yminlimit, ymaxlimit); abcissaBox->redraw(); ordinateBox->redraw(); } /// The Spectra callbacks. void relativecheck_cb(Fl_Check_Button *, spectra *panel) { panel->displayRelative(); return; } void absolutecheck_cb(Fl_Check_Button *, spectra *panel) { panel->displayAbsolute(); return; } void printbutton_cb(Fl_Button *, spectra *) { dbgprintf("Print button pressed\n"); if (printSpectPanel == 0) { printSpectPanel = new printspect; printspect &printref = *printSpectPanel; // initializes the fluid-generated panel printspect_panel(printref); // do our own initialization printSpectPanel->setDefaults(); } // show the panel printSpectPanel->setCallerType(SPECTRAPANEL); printSpectPanel->show(); return; } void savebutton_cb(Fl_Button *, spectra *) { dbgprintf("Save button pressed\n"); if (saveSpectPanel == 0) { saveSpectPanel = new savespect; savespect &saveref = *saveSpectPanel; // initializes the fluid-generated panel savespect_panel(saveref); // do our own initialization saveSpectPanel->setDefaults(); } // show the panel saveSpectPanel->setCallerType(SPECTRAPANEL); saveSpectPanel->show(); return; } void okbutton_cb(Fl_Return_Button*, spectra *panel) { // this is very simple... panel->hide(); } imview-1.1.9c/spectraBox.hxx0000644000076500007650000001113007665653123016647 0ustar talbottalbot00000000000000/* * $Id: spectraBox.hxx,v 4.1 2003/05/30 13:02:11 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The spectrum display panel * * Hugues Talbot 1 Aug 1998 * *-----------------------------------------------------------------------*/ #ifndef SPECTRABOX_H #define SPECTRABOX_H #include #include #include #include #include #include #include #include #include #include #include #include #include "axisBox.hxx" #define WIDTHMARGIN 4 #define HEIGHTMARGIN 8 #ifdef WIN32 # define MY_CURSOR_VLINE FL_CURSOR_HAND #else # define MY_CURSOR_VLINE 58 #endif class mySpectraBox : public Fl_Box { public: mySpectraBox(int x, int y, int w, int h, const char *l=0) : Fl_Box(x,y,w,h,l) { spectrum = 0; nbSpectrumValues = 0; mins = maxs = 0; } int handle(int event); // we need this for mouse control void handleButtonPushed(); void handleButtonDragged(); void handleButtonReleased(); void setRelative() {absolute = false; recomputeLimits(); redraw();} void setAbsolute() {absolute = true; recomputeLimits(); redraw();} void setSpectra(class spectra *s) {theSpectra = s;} void setSpectrum(double *theSpectrum, int nbval); double *getSpectrum() {return spectrum;} int getNbValues() {return nbSpectrumValues;} void recomputeLimits(); void draw(); private: double *spectrum, maxs, mins; int nbSpectrumValues; bool absolute; class spectra *theSpectra; }; class spectra { public: spectra(); ~spectra(); void setDefaults(); void setData(double *s, int nb, int x, int y); double *getData() {return spectraBox->getSpectrum();} int getNbVal() {return spectraBox->getNbValues();} int getXpos() {return xIm;} int getYpos() {return yIm;} int visible(); void redraw(); void show(); void hide(); void displayRelative(void) {spectraBox->setRelative();} void displayAbsolute(void) {spectraBox->setAbsolute();} void setXValue(int xv) { static char a[10]; sprintf(a, "%d", xv); xvalue->value(a); } void setYValue(double yv) { static char a[30]; sprintf(a, "%g", yv); yvalue->value(a); } void setWindowTitle(const char *title) {spectraWindow->label(title);} void setXValueLabel(const char *lbl) { xvalue->label(lbl); } void setAxisBoxesLimits(double xminlimit, double xmaxlimit, double yminlimit, double ymaxlimit); friend Fl_Double_Window *spectra_panel(spectra &s); private: int xIm, yIm; Fl_Double_Window *spectraWindow; mySpectraBox *spectraBox; axisBox *abcissaBox, *ordinateBox; Fl_Button *saveButton, *printButton; Fl_Return_Button *OKButton; Fl_Output *spectrumTitle, *xvalue, *yvalue; Fl_Check_Button *absolute, *relative; }; #endif // SPECTRABOX_H imview-1.1.9c/statisize.py0000755000076500007650000000747707653236507016423 0ustar talbottalbot00000000000000#! /usr/bin/env python # # $Id: statisize.py,v 4.0 2003/04/28 14:40:07 hut66au Exp $ # # This file takes a linking command line as input (as in c++ -o imview etc), # finds out all the -L library dependencies and uses static library whereever # possible, by creating a subdirectory `static' with links to the .a files, then changes # the compilation line by replacing the -lsomething with static/libsomething.a # # This is the only portable way I've found to make an executable as static as possible. # On some machines (notably DECs and Suns) creating a pure static executable is impossible # as some .a are missing. # import os, errno, sys, string # set to one if you need debug messages debug = 0 # list of libraries to exclude from this process excludelib = ["c", "m", "X11", "Xext", "pthread", "socket", "nsl", "dpstk", "dps", "Xt", "SM", "ICE", "dl", "mp"] includepath = ["/usr/lib"] atend = [] # for silent libraries that need to be appended # returns a copy of the input list with items unique def uniq(strlist): strlist.sort() cpl = strlist[:] # make a copy l = len(strlist) for item in range(l-1): index = l - item -1 if (strlist[index] == strlist[index-1]): cpl.pop(index) # remove from the end return cpl # process arguments for this script def processOwnArgs(arglist): global debug while arglist[0][0] == "-": if debug: print "argument ", arglist[arg][1:] if arglist[0][1:] == "debug": debug = 1 arglist.pop(0) # get rid of this argument if arglist[0][1:] == "append": if debug: print "Will append ", arglist[1], " at the end of compilation stanza" atend.append(arglist[1]) arglist.pop(0) # get rid of two arguments arglist.pop(0) if arglist[0][1:] == "-": # end of arguments arglist.pop(0) break; # main part of the script words = sys.argv[1:] processOwnArgs(words) nbwords = len(words) if debug: print "*** Debug information" # finds the -Lsomething libpath = [] for row in range(nbwords): if words[row][0:2] == "-L": libpath.append(words[row][2:]) # append the automatically included libs libpath = libpath + includepath if debug: print "Lib path: ", libpath # finds the -lsomething libraries = [] for row in range(nbwords): if words[row][0:2] == "-l": libraries.append(words[row][2:]) # print out the somethings libpath = uniq(libpath) if debug: print "Libpath =", libpath libraries = uniq(libraries) if debug: print "Libraries =", libraries # walk the library tree, creates symbolic links, remember them assoc = {} for lib in libraries: for dir in libpath: if (excludelib.count(lib) != 0): if debug: print "Excluding ", lib break; libname = "lib" + lib + ".a" pathlib = dir + "/" + libname if os.access(pathlib, os.R_OK) == 1: if debug: print "Found static version of ", lib, " as: ", pathlib assoc[lib] = pathlib break if debug: print assoc # now re-creates a compilation line with -l changed to direct library calls # change the -l into blabla/lib.a for index in (range(nbwords)): if words[index][0:2] == "-l": try: remainder = words[index][2:] words[index] = assoc[remainder] except KeyError: if debug: print "library ", remainder, " was unchanged" # print the new command cmd = "" for index in (range(nbwords)): cmd = cmd + words[index] + " " # add the extra stuff for stuff in atend: cmd = cmd + stuff + " " words.append(stuff) if debug: print "Words contains: ", words print "*** End of debug information" print cmd # execute it os.execvp(words[0], words) imview-1.1.9c/StatusBox.cxx0000644000076500007650000001146707653236451016477 0ustar talbottalbot00000000000000/* * $Id: StatusBox.cxx,v 4.0 2003/04/28 14:39:37 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /* Copyright (C) 1998 Craig P. Earls 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 program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include "imview.hxx" // might be useful if we are missing vsnprintf etc. #include "StatusBox.hxx" #include "machine.hxx" #include "imunistd.h" #define LINELENGTH 1024 StatusBox *StatusBox::_Instance=0; StatusBox* StatusBox::Instance() { if (_Instance==0){ _Instance= new StatusBox(); }; return _Instance; } inline void StatusBox::cb_clear_i(Fl_Button*, void*) { list->clear(); } void StatusBox::cb_clear(Fl_Button* o, void* v) { ((StatusBox*)(o->parent()->user_data()))->cb_clear_i(o,v); } StatusBox::StatusBox(int x, int y, int w, int h, char *l): Fl_Window(x, y, w, h, l) { box(FL_UP_BOX); user_data((void*)(this)); { Fl_Browser* o = list = new Fl_Browser(10, 10, 410, 120); o->color(FL_BLACK); Fl_Group::current()->resizable(o); } { Fl_Button* o = clear = new Fl_Button(10, 135, 410, 30, "&Clear"); o->callback((Fl_Callback*)cb_clear); } end(); } // allows multi-line messages now. void StatusBox::status(char *format, ...) { static char s1[LINELENGTH+24], s2[LINELENGTH], mess[LINELENGTH+4]; int i, j; va_list arg; im_va_start (arg, format); // add lines one by one vsnprintf(s2, LINELENGTH, format, arg); for (i=0, j= 0; ((i < LINELENGTH) && (s2[i] != '\0')); i++, j++) { mess[j] = s2[i]; if (s2[i] == '\n') { mess[j+1] = '\0'; // OK due to +4 snprintf(s1, LINELENGTH+24, "@s@B%d@C%d@.%s", FL_BLACK, FL_GREEN, mess); list->add(s1); j = -1; // j++ gets executed } } if (!shown()) show(); list->bottomline(list->size()); va_end(arg); } void StatusBox::warning(char *format, ...) { static char s1[LINELENGTH], s2[LINELENGTH]; va_list arg; im_va_start (arg, format); vsnprintf(s2, LINELENGTH, format, arg); snprintf(s1, LINELENGTH, "@B%d@C%d@.%s", FL_BLACK, FL_YELLOW, s2); list->add(s1); // if (!shown()) // show(); list->bottomline(list->size()); va_end(arg); } void StatusBox::error(char *format, ...) { static char s1[LINELENGTH], s2[LINELENGTH]; va_list arg; im_va_start (arg, format); vsnprintf(s2, LINELENGTH, format, arg); snprintf(s1, LINELENGTH, "@m@B%d@C%d@.%s", FL_BLACK, FL_RED, s2); list->add(s1); if (!shown()) show(); list->bottomline(list->size()); va_end(arg); } /* * Local variables: * compile-command: "make -C .. -k" * End: */ imview-1.1.9c/StatusBox.hxx0000644000076500007650000001051507653236451016475 0ustar talbottalbot00000000000000/* * $Id: StatusBox.hxx,v 4.0 2003/04/28 14:39:37 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /* Copyright (C) 19998 Craig P. Earls 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 program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* *HOWTO: * * Simply #include the header file "StatusBox.hpp" in any source code * you want use it from. Three MACROS are defined for simple messages: STATUS("This is the message"); STATUS(somestring); WARNING("A warning"); ERROR("An Error"); * These macros accept a single character string argument. The only * differences are the color fo the text output to the list. If you * would like to send more detailed information with formatting you * must call status(char *format, ...) directly as follows: StatusBox::Instance()->status( "I want to print out the following %d %f", anInteger, aFloat); or use warning(char *format, ...), or error(char *format, ...); * StatusBox is implemented as a singleton, which means the constructor * is protected and there is a single static instance. You can only * get to the object using the Instance() method, which returns a * pointer to the static object. This means all status messages go the * same place. This a convenient substitute for a terminal window */ #ifndef StatusBox_hpp #define StatusBox_hpp #include #include #include #include #include #define DEBUG #ifdef DEBUG #define IM_STATUS(a) StatusBox::Instance()->status(a); #define IM_WARNING(a) StatusBox::Instance()->warning(a); #define IM_ERROR(a) StatusBox::Instance()->error(a); #else #define IM_STATUS(a) {}; #define IM_WARNING(a) {} #define IM_ERROR(a) {}; #endif class StatusBox : public Fl_Window { public: static StatusBox *Instance(); void status(char *s, ...); void warning(char *s, ...); void error(char *s, ...); protected: StatusBox(int x=0, int y=0, int w=428, int h=171, char *l="Status"); private: Fl_Browser *list; Fl_Button *clear; inline void cb_clear_i(Fl_Button*, void*); static void cb_clear(Fl_Button*, void*); Fl_Button *hideb; static StatusBox *_Instance; }; #endif /* * Local variables: * compile-command: "make -C .. -k" * End: */ imview-1.1.9c/stl/0000755000076500007650000000000010756342330014600 5ustar talbottalbot00000000000000imview-1.1.9c/stl/secure.c0000644000076500007650000000150507752637130016242 0ustar talbottalbot00000000000000#include #include size_t strlcpy(char *dst, const char *src, size_t size) { char *dstptr = dst; size_t tocopy = size; const char *srcptr = src; if (tocopy && --tocopy) { do { if (!(*dstptr++ = *srcptr++)) break; } while (--tocopy); } if (!tocopy) { if (size) *dstptr = 0; while (*srcptr++); } return (srcptr - src - 1); } size_t strlcat(char *dst, const char *src, size_t len) { char *dstptr = dst; size_t dstlen, tocopy; const char *srcptr = src; while (tocopy-- && *dstptr) dstptr++; dstlen = dstptr - dst; if (!(tocopy = size - dstlen)) return (dstlen + strlen(src)); while (*strptr) { if (tocopy != 1) { *dstptr++ = *srcptr; tocopy--; } srcptr++; } *dstptr = 0; return (dstlen + (srcptr - src)); } imview-1.1.9c/stl/sstream/0000755000076500007650000000000010756342330016256 5ustar talbottalbot00000000000000imview-1.1.9c/stl/sstream/iotraits.h0000644000076500007650000000577107653237132020304 0ustar talbottalbot00000000000000// // // // // // // // // // // // // // Author: Dietmar Kühl dietmar.kuehl@uni-konstanz.de www.informatik.uni-konstanz.de/~kuehl // Title: The definition of the iotraits classes //------------------------------------------------------------------------------ #if !defined(IOTRAITS_H) #define IOTRAITS_H #include #include #include #if defined(__GNUC__) && __GNUC_MINOR__ <= 7 # define PORT_TEMPLATE_SPECIALIZATION #else # define PORT_TEMPLATE_SPECIALIZATION template <> #endif //------------------------------------------------------------------------------ template struct ctype {}; PORT_TEMPLATE_SPECIALIZATION struct ctype { typedef char char_type; typedef int int_type; //--- fix needed: bool isspace(int_type c) const { return isspace(c); } char_type newline() const { return '\n'; } }; //------------------------------------------------------------------------------ template struct ios_traits {}; //------------------------------------------------------------------------------ PORT_TEMPLATE_SPECIALIZATION struct ios_traits { typedef char char_type; typedef int int_type; typedef streampos pos_type; typedef streamoff off_type; typedef int state_type; static inline char_type eos() { return char_type(); } static inline int_type eof() { return -1; } static inline int_type not_eof(char_type c) { return int_type(c); } static inline char_type newline() { return '\n'; } static inline bool eq(char_type c1, char_type c2) { return c1 == c2; } static inline bool eq_int_type(int_type i1, int_type i2) { return i1 == i2; } static inline void assign(char& to, char from) { to = from; } static inline char_type to_char_type(int_type c) { return char_type(c); } static inline int_type to_int_type(char_type c) { return int_type(c); } static inline char_type *copy(char_type *dst, char_type const *src, pos_type n) { memcpy(dst, src, n); return dst; } static inline size_t length(char_type const *s) { return strlen(s); } }; //------------------------------------------------------------------------------ #endif /* IOTRAITS_H */ imview-1.1.9c/stl/sstream/sstream0000644000076500007650000000006607653237135017671 0ustar talbottalbot00000000000000#if !defined(SSTREAM_H) # include #endif imview-1.1.9c/stl/sstream/sstream.cc0000644000076500007650000002661207653237135020262 0ustar talbottalbot00000000000000// -*-C++-*- srccxx/sstream.cc // // // // // // // // // // // // Author: Dietmar Kuehl dietmar.kuehl@claas-solutions.de // Title: Implementation of the string stream classes // -------------------------------------------------------------------------- #if !defined(SSTREAM_CC) #define SRCCXX_SSTREAM_CC 1 #if !defined(SSTREAM_H) # include #endif #include // ------------------------------------------------------------------------- template basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::basic_stringbuf(ios_base::openmode _CS_m): _CS_m_mode(_CS_m), _CS_m_beg(0), _CS_m_end(0) { } template basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::basic_stringbuf(string_type const &_CS_s, ios_base::openmode _CS_m): _CS_m_mode(_CS_m), _CS_m_beg(_CS_s.size() > 0? new _CS_cT[_CS_s.size()]: 0), _CS_m_end(_CS_m_beg + _CS_s.size()) { traits_type::copy(_CS_m_beg, _CS_s.data(), _CS_s.size()); if (_CS_m & ios_base::in) setg(_CS_m_beg, _CS_m_beg, _CS_m_end); if (_CS_m & ios_base::out) setp(_CS_m_beg, _CS_m_end); } template basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::~basic_stringbuf() { delete[] _CS_m_beg; } template basic_string<_CS_cT, _CS_Tr, _CS_Al> basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::str() const { if (pbase() == epptr()) if (eback() == egptr()) return basic_string<_CS_cT, _CS_Tr, _CS_Al>(); else return basic_string<_CS_cT, _CS_Tr, _CS_Al>(eback(), egptr()); else return basic_string<_CS_cT, _CS_Tr, _CS_Al>(pbase(), epptr()); } template void basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::str(string_type const &_CS_s) { _CS_cT* _CS_nv = new _CS_cT[_CS_s.size()]; traits_type::copy(_CS_nv, _CS_s.data(), _CS_s.size()); delete[] _CS_m_beg; _CS_m_beg = _CS_nv; _CS_m_end = _CS_m_beg + _CS_s.size(); traits_type::copy(_CS_m_beg, _CS_s.data(), _CS_s.size()); if (_CS_m_mode & ios_base::in) setg(_CS_m_beg, _CS_m_beg, _CS_m_end); if (_CS_m_mode & ios_base::out) setp(_CS_m_beg, _CS_m_end); } template typename basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::int_type basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::underflow() { return gptr() == egptr()? traits_type::eof() : traits_type::to_int_type(*gptr()); } template typename basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::int_type basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::pbackfail(int_type _CS_c) { if (eback() != gptr()) { if (traits_type::eq_int_type(_CS_c, traits_type::eof())) { gbump(-1); return traits_type::not_eof(_CS_c); } else if (traits_type::eq(traits_type::to_char_type(_CS_c), gptr()[-1]) || (_CS_m_mode & ios_base::out) != 0) { gbump(-1); traits_type::assign(*gptr(), traits_type::to_char_type(_CS_c)); return _CS_c; } } // fails if // - no read position is available // - c is not eof, does not match the last read char, and the stream is // read-only return traits_type::eof(); } template typename basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::int_type basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::overflow(int_type _CS_c) { if (traits_type::eq_int_type(_CS_c, traits_type::eof())) return traits_type::not_eof(_CS_c); else if (_CS_m_mode & ios_base::out) { if (_CS_m_beg == 0) { _CS_m_beg = new _CS_cT[64]; _CS_m_end = _CS_m_beg + 64; setp(_CS_m_beg, _CS_m_beg); } if (pptr() != epptr()) { traits_type::assign(*pptr(), traits_type::to_char_type(_CS_c)); pbump(1); } else if (epptr() != _CS_m_end) { traits_type::assign(*pptr(), traits_type::to_char_type(_CS_c)); setp(pbase(), epptr() + 1); pbump(epptr() - pbase()); if (_CS_m_mode & ios_base::in) setg(eback(), gptr(), pptr()); } else { streamsize _CS_size = _CS_m_end - _CS_m_beg; _CS_cT* _CS_nv = new _CS_cT[2 * _CS_size]; traits_type::copy(_CS_nv, _CS_m_beg, _CS_size); delete[] _CS_m_beg; _CS_m_beg = _CS_nv; _CS_m_end = _CS_nv + 2 * _CS_size; traits_type::assign(_CS_m_beg[_CS_size], traits_type::to_char_type(_CS_c)); setp(_CS_m_beg, _CS_m_beg + _CS_size + 1); pbump(_CS_size + 1); if (_CS_m_mode & ios_base::in) setg(pbase(), pbase() + (egptr() - gptr()), pptr()); } return _CS_c; } return traits_type::eof(); } template basic_streambuf<_CS_cT, _CS_Tr>* basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::setbuf(char_type*, streamsize) { //-dk:TODO document that setbuf() has no effect! (implementation defined) return this; } template typename basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::pos_type basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::seekoff(off_type _CS_off, ios_base::seekdir _CS_dir, ios_base::openmode _CS_which) { _CS_cT* _CS_np = 0; _CS_cT* _CS_e = _CS_m_mode & ios_base::out? epptr(): egptr(); switch (_CS_dir) { case ios_base::beg: if (_CS_off < 0 || (_CS_e - _CS_m_beg) < _CS_off) return pos_type(off_type(-1)); _CS_np = _CS_m_beg + _CS_off; break; case ios_base::end: if (_CS_off > 0 || (_CS_e - _CS_m_beg) < -_CS_off) return pos_type(off_type(-1)); _CS_np = _CS_e + _CS_off; break; case ios_base::cur: if ((_CS_which & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out) && pptr() != gptr()) return pos_type(off_type(-1)); _CS_np = (_CS_which & ios_base::in)? gptr(): pptr(); if (_CS_off < -(_CS_np - _CS_m_beg) || _CS_e - _CS_np < _CS_off) return pos_type(off_type(-1)); _CS_np += _CS_off; break; } switch (_CS_which & (ios_base::in | ios_base::out)) { case ios_base::in: if (_CS_m_mode & ios_base::in) gbump(_CS_np - gptr()); else return pos_type(off_type(-1)); break; case ios_base::out: if (_CS_m_mode & ios_base::out) pbump(_CS_np - pptr()); else return pos_type(off_type(-1)); break; case ios_base::in | ios_base::out: if ((_CS_m_mode & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out)) { gbump(_CS_np - gptr()); pbump(_CS_np - pptr()); } else return pos_type(off_type(-1)); break; default: return pos_type(off_type(-1)); } return pos_type(_CS_np - _CS_m_beg); } template typename basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::pos_type basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::seekpos(pos_type _CS_pos, ios_base::openmode _CS_which) { _CS_cT* _CS_p = (_CS_m_mode & ios_base::out)? epptr(): egptr(); if (_CS_pos < 0 || (_CS_p - _CS_m_beg) < _CS_pos) return pos_type(off_type(-1)); _CS_p = _CS_m_beg + _CS_pos; switch (_CS_which & (ios_base::in | ios_base::out) & _CS_m_mode) { case ios_base::in: gbump(_CS_p - gptr()); break; case ios_base::out: pbump(_CS_p - pptr()); break; case ios_base::in | ios_base::out: gbump(_CS_p - gptr()); pbump(_CS_p - pptr()); break; default: return pos_type(off_type(-1)); } return _CS_pos; } template int basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>::sync() { // do nothing, except signaling success return traits_type::not_eof(traits_type::eof()); } // -------------------------------------------------------------------------- template _CS_basic_sstream_base<_CS_cT, _CS_Tr, _CS_Al>:: _CS_basic_sstream_base( ios_base::openmode _CS_mode): _CS_m_ssbuf(_CS_mode) { } template _CS_basic_sstream_base<_CS_cT, _CS_Tr, _CS_Al>:: _CS_basic_sstream_base(_CS_string_type const& _CS_str, ios_base::openmode _CS_mode): _CS_m_ssbuf(_CS_str, _CS_mode) { } template basic_string<_CS_cT, _CS_Tr, _CS_Al> _CS_basic_sstream_base<_CS_cT, _CS_Tr, _CS_Al>::str() const { return _CS_m_ssbuf.str(); } template void _CS_basic_sstream_base<_CS_cT, _CS_Tr, _CS_Al>::str( _CS_string_type const& _CS_str) { _CS_m_ssbuf.str(_CS_str); } // -------------------------------------------------------------------------- template basic_istringstream<_CS_cT, _CS_Tr, _CS_Al>::basic_istringstream( ios_base::openmode _CS_mode): _CS_basic_sstream_base<_CS_cT, _CS_Tr, _CS_Al>(_CS_mode | ios_base::in), ios(&_CS_m_ssbuf), basic_istream<_CS_cT, _CS_Tr>(&_CS_m_ssbuf) { init(&_CS_m_ssbuf); } template basic_istringstream<_CS_cT, _CS_Tr, _CS_Al>::basic_istringstream( _CS_string_type const& _CS_str, ios_base::openmode _CS_mode): _CS_basic_sstream_base<_CS_cT, _CS_Tr, _CS_Al>(_CS_str, _CS_mode | ios_base::in), ios(&_CS_m_ssbuf) { init(&_CS_m_ssbuf); } // -------------------------------------------------------------------------- template basic_ostringstream<_CS_cT, _CS_Tr, _CS_Al>::basic_ostringstream( ios_base::openmode _CS_mode): _CS_basic_sstream_base<_CS_cT, _CS_Tr, _CS_Al>(_CS_mode | ios_base::out) { init(&_CS_m_ssbuf); } template basic_ostringstream<_CS_cT, _CS_Tr, _CS_Al>::basic_ostringstream( _CS_string_type const& _CS_str, ios_base::openmode _CS_mode): _CS_basic_sstream_base<_CS_cT, _CS_Tr, _CS_Al>(_CS_str, _CS_mode | ios_base::out), ios(&_CS_m_ssbuf), basic_ostream<_CS_cT, _CS_Tr>(&_CS_m_ssbuf) { init(&_CS_m_ssbuf); } // -------------------------------------------------------------------------- template basic_stringstream<_CS_cT, _CS_Tr, _CS_Al>::basic_stringstream( ios_base::openmode _CS_mode): _CS_basic_sstream_base<_CS_cT, _CS_Tr, _CS_Al>(_CS_mode | in | out), ios(&_CS_m_ssbuf), basic_iostream<_CS_cT, _CS_Tr>(&_CS_m_ssbuf) { init(&_CS_m_ssbuf); } template basic_stringstream<_CS_cT, _CS_Tr, _CS_Al>::basic_stringstream( _CS_string_type const& _CS_str, ios_base::openmode _CS_mode): _CS_basic_sstream_base<_CS_cT, _CS_Tr, _CS_Al>(_CS_str, _CS_mode | in | out), ios(&_CS_m_ssbuf), basic_iostream<_CS_cT, _CS_Tr>(&_CS_m_ssbuf) { init(&_CS_m_ssbuf); } // -------------------------------------------------------------------------- #endif /* SSTREAM_CC */ imview-1.1.9c/stl/sstream/sstream.h0000644000076500007650000001735207653237135020125 0ustar talbottalbot00000000000000// // // // // // // // // // // // // // Author: Dietmar Kühl dietmar.kuehl@uni-konstanz.de www.informatik.uni-konstanz.de/~kuehl // Title: An implementation of the string stream classes //------------------------------------------------------------------------------ // The first thing to do is to protect the file against multiple inclusion: #if !defined(SSTREAM_H) #define SSTREAM_H //------------------------------------------------------------------------------ // Next, some headerfiles are included: #include #include #include #include #include //------------------------------------------------------------------------------ #if defined(__GNUC__) // NOTE: This hack will work for character type 'char' only! // However, the actual code was taken from a fully templatized code base. template class basic_streambuf: public streambuf { public: typedef char char_type; typedef int int_type; typedef ios_traits traits_type; typedef streampos pos_type; typedef streamoff off_type; }; template class basic_istream: public istream { public: typedef char char_type; typedef int int_type; typedef ios_traits traits_type; typedef streampos pos_type; typedef streamoff off_type; }; template class basic_ostream: public ostream { public: typedef char char_type; typedef int int_type; typedef ios_traits traits_type; typedef streampos pos_type; typedef streamoff off_type; }; template class basic_iostream: public iostream { public: typedef char char_type; typedef int int_type; typedef ios_traits traits_type; typedef streampos pos_type; typedef streamoff off_type; }; struct ios_base: public ios { typedef seek_dir seekdir; }; #endif //------------------------------------------------------------------------------ template > class basic_stringbuf: public basic_streambuf<_CS_cT, _CS_traits> { public: typedef basic_string<_CS_cT, _CS_traits, _CS_alloc> string_type; typedef typename basic_streambuf<_CS_cT, _CS_traits>::char_type char_type; typedef typename basic_streambuf<_CS_cT, _CS_traits>::traits_type traits_type; typedef typename basic_streambuf<_CS_cT, _CS_traits>::int_type int_type; typedef typename basic_streambuf<_CS_cT, _CS_traits>::pos_type pos_type; typedef typename basic_streambuf<_CS_cT, _CS_traits>::off_type off_type; basic_stringbuf(ios_base::openmode = ios_base::in | ios_base::out); basic_stringbuf(basic_string<_CS_cT, _CS_traits, _CS_alloc> const&, ios_base::openmode = ios_base::in | ios_base::out); ~basic_stringbuf(); basic_string<_CS_cT, _CS_traits, _CS_alloc> str() const; void str(basic_string<_CS_cT, _CS_traits, _CS_alloc> const&); protected: int_type underflow(); int_type pbackfail(int_type); int_type overflow(int_type); basic_streambuf<_CS_cT, _CS_traits>* setbuf(char_type*, streamsize); pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode); pos_type seekpos(pos_type pos, ios_base::openmode); int sync(); private: basic_stringbuf(basic_stringbuf const&); // deliberatly not accessible void operator=(basic_stringbuf const&); // deliberatly not accessible ios_base::openmode _CS_m_mode; _CS_cT* _CS_m_beg; _CS_cT* _CS_m_end; }; // -------------------------------------------------------------------------- template class _CS_basic_sstream_base { public: typedef basic_string<_CS_cT, _CS_Tr, _CS_Al> _CS_string_type; explicit _CS_basic_sstream_base(ios_base::openmode); _CS_basic_sstream_base(_CS_string_type const&, ios_base::openmode); _CS_string_type str() const; void str(_CS_string_type const&); protected: mutable basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al> _CS_m_ssbuf; }; // -------------------------------------------------------------------------- template class basic_istringstream: public virtual _CS_basic_sstream_base<_CS_cT, _CS_Tr, _CS_Al>, public basic_istream<_CS_cT, _CS_Tr> { public: typedef typename basic_istream<_CS_cT, _CS_Tr>::char_type char_type; typedef typename basic_istream<_CS_cT, _CS_Tr>::int_type int_type; typedef typename basic_istream<_CS_cT, _CS_Tr>::pos_type pos_type; typedef typename basic_istream<_CS_cT, _CS_Tr>::off_type off_type; typedef typename basic_istream<_CS_cT, _CS_Tr>::traits_type traits_type; typedef basic_string<_CS_cT, _CS_Tr, _CS_Al> _CS_string_type; explicit basic_istringstream(ios_base::openmode = ios_base::in); explicit basic_istringstream(_CS_string_type const&, ios_base::openmode = ios_base::in); basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>* rdbuf() const { return &_CS_m_ssbuf; } }; // -------------------------------------------------------------------------- template class basic_ostringstream: public virtual _CS_basic_sstream_base<_CS_cT, _CS_Tr, _CS_Al>, public basic_ostream<_CS_cT, _CS_Tr> { public: typedef typename basic_ostream<_CS_cT, _CS_Tr>::char_type char_type; typedef typename basic_ostream<_CS_cT, _CS_Tr>::int_type int_type; typedef typename basic_ostream<_CS_cT, _CS_Tr>::pos_type pos_type; typedef typename basic_ostream<_CS_cT, _CS_Tr>::off_type off_type; typedef basic_string<_CS_cT, _CS_Tr, _CS_Al> _CS_string_type; explicit basic_ostringstream(ios_base::openmode = ios_base::out); explicit basic_ostringstream(_CS_string_type const&, ios_base::openmode = ios_base::out); basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>* rdbuf() const { return &_CS_m_ssbuf; } }; // -------------------------------------------------------------------------- template class basic_stringstream: public virtual _CS_basic_sstream_base<_CS_cT, _CS_Tr, _CS_Al>, public basic_iostream<_CS_cT, _CS_Tr> { public: typedef basic_string<_CS_cT, _CS_Tr, _CS_Al> _CS_string_type; explicit basic_stringstream(ios_base::openmode = ios_base::in | ios_base::out); explicit basic_stringstream(_CS_string_type const&, ios_base::openmode = ios_base::in|ios_base::out); basic_stringbuf<_CS_cT, _CS_Tr, _CS_Al>* rdbuf() const { return &_CS_m_ssbuf; } }; typedef basic_stringbuf, alloc> stringbuf; typedef basic_istringstream, alloc> istringstream; typedef basic_ostringstream, alloc> ostringstream; typedef basic_stringstream, alloc> stringstream; //------------------------------------------------------------------------------ #if !defined(SSTREAM_CC) # include #endif #endif /* SSTREAM_H */ imview-1.1.9c/support/0000755000076500007650000000000010756342331015513 5ustar talbottalbot00000000000000imview-1.1.9c/support/binary.lut0000644000076500007650000000003007653237135017525 0ustar talbottalbot00000000000000255 255 255 0 0 0 imview-1.1.9c/support/blue.lut0000644000076500007650000000362207653237135017202 0ustar talbottalbot000000000000000 0 0 0 0 1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 6 0 0 7 0 0 8 0 0 9 0 0 10 0 0 11 0 0 12 0 0 13 0 0 14 0 0 15 0 0 16 0 0 17 0 0 18 0 0 19 0 0 20 0 0 21 0 0 22 0 0 23 0 0 24 0 0 25 0 0 26 0 0 27 0 0 28 0 0 29 0 0 30 0 0 31 0 0 32 0 0 33 0 0 34 0 0 35 0 0 36 0 0 37 0 0 38 0 0 39 0 0 40 0 0 41 0 0 42 0 0 43 0 0 44 0 0 45 0 0 46 0 0 47 0 0 48 0 0 49 0 0 50 0 0 51 0 0 52 0 0 53 0 0 54 0 0 55 0 0 56 0 0 57 0 0 58 0 0 59 0 0 60 0 0 61 0 0 62 0 0 63 0 0 64 0 0 65 0 0 66 0 0 67 0 0 68 0 0 69 0 0 70 0 0 71 0 0 72 0 0 73 0 0 74 0 0 75 0 0 76 0 0 77 0 0 78 0 0 79 0 0 80 0 0 81 0 0 82 0 0 83 0 0 84 0 0 85 0 0 86 0 0 87 0 0 88 0 0 89 0 0 90 0 0 91 0 0 92 0 0 93 0 0 94 0 0 95 0 0 96 0 0 97 0 0 98 0 0 99 0 0 100 0 0 101 0 0 102 0 0 103 0 0 104 0 0 105 0 0 106 0 0 107 0 0 108 0 0 109 0 0 110 0 0 111 0 0 112 0 0 113 0 0 114 0 0 115 0 0 116 0 0 117 0 0 118 0 0 119 0 0 120 0 0 121 0 0 122 0 0 123 0 0 124 0 0 125 0 0 126 0 0 127 0 0 128 0 0 129 0 0 130 0 0 131 0 0 132 0 0 133 0 0 134 0 0 135 0 0 136 0 0 137 0 0 138 0 0 139 0 0 140 0 0 141 0 0 142 0 0 143 0 0 144 0 0 145 0 0 146 0 0 147 0 0 148 0 0 149 0 0 150 0 0 151 0 0 152 0 0 153 0 0 154 0 0 155 0 0 156 0 0 157 0 0 158 0 0 159 0 0 160 0 0 161 0 0 162 0 0 163 0 0 164 0 0 165 0 0 166 0 0 167 0 0 168 0 0 169 0 0 170 0 0 171 0 0 172 0 0 173 0 0 174 0 0 175 0 0 176 0 0 177 0 0 178 0 0 179 0 0 180 0 0 181 0 0 182 0 0 183 0 0 184 0 0 185 0 0 186 0 0 187 0 0 188 0 0 189 0 0 190 0 0 191 0 0 192 0 0 193 0 0 194 0 0 195 0 0 196 0 0 197 0 0 198 0 0 199 0 0 200 0 0 201 0 0 202 0 0 203 0 0 204 0 0 205 0 0 206 0 0 207 0 0 208 0 0 209 0 0 210 0 0 211 0 0 212 0 0 213 0 0 214 0 0 215 0 0 216 0 0 217 0 0 218 0 0 219 0 0 220 0 0 221 0 0 222 0 0 223 0 0 224 0 0 225 0 0 226 0 0 227 0 0 228 0 0 229 0 0 230 0 0 231 0 0 232 0 0 233 0 0 234 0 0 235 0 0 236 0 0 237 0 0 238 0 0 239 0 0 240 0 0 241 0 0 242 0 0 243 0 0 244 0 0 245 0 0 246 0 0 247 0 0 248 0 0 249 0 0 250 0 0 251 0 0 252 0 0 253 0 0 254 0 0 255 imview-1.1.9c/support/green.lut0000644000076500007650000000362207653237135017353 0ustar talbottalbot000000000000000 0 0 0 1 0 0 2 0 0 3 0 0 4 0 0 5 0 0 6 0 0 7 0 0 8 0 0 9 0 0 10 0 0 11 0 0 12 0 0 13 0 0 14 0 0 15 0 0 16 0 0 17 0 0 18 0 0 19 0 0 20 0 0 21 0 0 22 0 0 23 0 0 24 0 0 25 0 0 26 0 0 27 0 0 28 0 0 29 0 0 30 0 0 31 0 0 32 0 0 33 0 0 34 0 0 35 0 0 36 0 0 37 0 0 38 0 0 39 0 0 40 0 0 41 0 0 42 0 0 43 0 0 44 0 0 45 0 0 46 0 0 47 0 0 48 0 0 49 0 0 50 0 0 51 0 0 52 0 0 53 0 0 54 0 0 55 0 0 56 0 0 57 0 0 58 0 0 59 0 0 60 0 0 61 0 0 62 0 0 63 0 0 64 0 0 65 0 0 66 0 0 67 0 0 68 0 0 69 0 0 70 0 0 71 0 0 72 0 0 73 0 0 74 0 0 75 0 0 76 0 0 77 0 0 78 0 0 79 0 0 80 0 0 81 0 0 82 0 0 83 0 0 84 0 0 85 0 0 86 0 0 87 0 0 88 0 0 89 0 0 90 0 0 91 0 0 92 0 0 93 0 0 94 0 0 95 0 0 96 0 0 97 0 0 98 0 0 99 0 0 100 0 0 101 0 0 102 0 0 103 0 0 104 0 0 105 0 0 106 0 0 107 0 0 108 0 0 109 0 0 110 0 0 111 0 0 112 0 0 113 0 0 114 0 0 115 0 0 116 0 0 117 0 0 118 0 0 119 0 0 120 0 0 121 0 0 122 0 0 123 0 0 124 0 0 125 0 0 126 0 0 127 0 0 128 0 0 129 0 0 130 0 0 131 0 0 132 0 0 133 0 0 134 0 0 135 0 0 136 0 0 137 0 0 138 0 0 139 0 0 140 0 0 141 0 0 142 0 0 143 0 0 144 0 0 145 0 0 146 0 0 147 0 0 148 0 0 149 0 0 150 0 0 151 0 0 152 0 0 153 0 0 154 0 0 155 0 0 156 0 0 157 0 0 158 0 0 159 0 0 160 0 0 161 0 0 162 0 0 163 0 0 164 0 0 165 0 0 166 0 0 167 0 0 168 0 0 169 0 0 170 0 0 171 0 0 172 0 0 173 0 0 174 0 0 175 0 0 176 0 0 177 0 0 178 0 0 179 0 0 180 0 0 181 0 0 182 0 0 183 0 0 184 0 0 185 0 0 186 0 0 187 0 0 188 0 0 189 0 0 190 0 0 191 0 0 192 0 0 193 0 0 194 0 0 195 0 0 196 0 0 197 0 0 198 0 0 199 0 0 200 0 0 201 0 0 202 0 0 203 0 0 204 0 0 205 0 0 206 0 0 207 0 0 208 0 0 209 0 0 210 0 0 211 0 0 212 0 0 213 0 0 214 0 0 215 0 0 216 0 0 217 0 0 218 0 0 219 0 0 220 0 0 221 0 0 222 0 0 223 0 0 224 0 0 225 0 0 226 0 0 227 0 0 228 0 0 229 0 0 230 0 0 231 0 0 232 0 0 233 0 0 234 0 0 235 0 0 236 0 0 237 0 0 238 0 0 239 0 0 240 0 0 241 0 0 242 0 0 243 0 0 244 0 0 245 0 0 246 0 0 247 0 0 248 0 0 249 0 0 250 0 0 251 0 0 252 0 0 253 0 0 254 0 0 255 0 imview-1.1.9c/support/heat.lut0000644000076500007650000000521607653237136017176 0ustar talbottalbot000000000000000 0 255 0 3 255 0 7 255 0 11 255 0 15 255 0 19 255 0 23 255 0 27 255 0 31 255 0 35 255 0 39 255 0 43 255 0 47 255 0 51 255 0 55 255 0 59 255 0 63 255 0 67 255 0 71 255 0 75 255 0 79 255 0 83 255 0 87 255 0 91 255 0 95 255 0 99 255 0 103 255 0 107 255 0 111 255 0 115 255 0 119 255 0 123 255 0 127 255 0 131 255 0 135 255 0 139 255 0 143 255 0 147 255 0 151 255 0 155 255 0 159 255 0 163 255 0 167 255 0 171 255 0 175 255 0 179 255 0 183 255 0 187 255 0 191 255 0 195 255 0 199 255 0 203 255 0 207 255 0 211 255 0 215 255 0 219 255 0 223 255 0 227 255 0 231 255 0 235 255 0 239 255 0 243 255 0 247 255 0 251 255 0 255 252 0 255 248 0 255 244 0 255 240 0 255 236 0 255 232 0 255 228 0 255 224 0 255 220 0 255 216 0 255 212 0 255 208 0 255 204 0 255 200 0 255 196 0 255 192 0 255 188 0 255 184 0 255 180 0 255 176 0 255 172 0 255 168 0 255 164 0 255 160 0 255 156 0 255 152 0 255 148 0 255 144 0 255 140 0 255 136 0 255 132 0 255 128 0 255 124 0 255 120 0 255 116 0 255 112 0 255 108 0 255 104 0 255 100 0 255 96 0 255 92 0 255 88 0 255 84 0 255 80 0 255 76 0 255 72 0 255 68 0 255 64 0 255 60 0 255 56 0 255 52 0 255 48 0 255 44 0 255 40 0 255 36 0 255 32 0 255 28 0 255 24 0 255 20 0 255 16 0 255 12 0 255 8 0 255 4 0 255 0 1 255 0 5 255 0 9 255 0 13 255 0 17 255 0 21 255 0 25 255 0 29 255 0 33 255 0 37 255 0 41 255 0 45 255 0 49 255 0 53 255 0 57 255 0 61 255 0 65 255 0 69 255 0 73 255 0 77 255 0 81 255 0 85 255 0 89 255 0 93 255 0 97 255 0 101 255 0 105 255 0 109 255 0 113 255 0 117 255 0 121 255 0 125 255 0 129 255 0 133 255 0 137 255 0 141 255 0 145 255 0 149 255 0 153 255 0 157 255 0 161 255 0 165 255 0 169 255 0 173 255 0 177 255 0 181 255 0 185 255 0 189 255 0 193 255 0 197 255 0 201 255 0 205 255 0 209 255 0 213 255 0 217 255 0 221 255 0 225 255 0 229 255 0 233 255 0 237 255 0 241 255 0 245 255 0 249 255 0 253 255 0 255 250 0 255 246 0 255 242 0 255 238 0 255 234 0 255 230 0 255 226 0 255 222 0 255 218 0 255 214 0 255 210 0 255 206 0 255 202 0 255 198 0 255 194 0 255 190 0 255 186 0 255 182 0 255 178 0 255 174 0 255 170 0 255 166 0 255 162 0 255 158 0 255 154 0 255 150 0 255 146 0 255 142 0 255 138 0 255 134 0 255 130 0 255 126 0 255 122 0 255 118 0 255 114 0 255 110 0 255 106 0 255 102 0 255 98 0 255 94 0 255 90 0 255 86 0 255 82 0 255 78 0 255 74 0 255 70 0 255 66 0 255 62 0 255 58 0 255 54 0 255 50 0 255 46 0 255 42 0 255 38 0 255 34 0 255 30 0 255 26 0 255 22 0 255 18 0 255 14 0 255 10 0 255 6 0 255 2 0 255 0 0 imview-1.1.9c/support/hue.lut0000644000076500007650000000740007653237136017033 0ustar talbottalbot00000000000000 255 0 0 248 7 0 241 14 0 235 20 0 230 25 0 225 30 0 220 35 0 215 40 0 211 44 0 207 48 0 203 52 0 199 56 0 196 59 0 192 63 0 189 66 0 186 69 0 183 72 0 180 75 0 178 77 0 175 80 0 173 82 0 170 85 0 168 87 0 165 90 0 163 92 0 161 94 0 159 96 0 156 99 0 154 101 0 152 103 0 150 105 0 148 107 0 146 109 0 145 110 0 143 112 0 141 114 0 139 116 0 137 118 0 135 120 0 133 122 0 132 123 0 130 125 0 128 127 0 126 129 0 125 130 0 123 132 0 121 134 0 119 136 0 117 138 0 116 139 0 114 141 0 112 143 0 110 145 0 108 147 0 106 149 0 104 151 0 102 153 0 100 155 0 98 157 0 96 159 0 94 161 0 92 163 0 90 165 0 87 168 0 85 170 0 83 172 0 80 175 0 78 177 0 75 180 0 72 183 0 69 186 0 66 189 0 63 192 0 60 195 0 57 198 0 53 202 0 50 205 0 46 209 0 42 213 0 37 218 0 33 222 0 28 227 0 23 232 0 17 238 0 11 244 0 5 250 0 0 252 3 0 245 10 0 239 16 0 233 22 0 228 27 0 223 32 0 218 37 0 214 41 0 210 45 0 206 49 0 202 53 0 199 56 0 195 60 0 192 63 0 189 66 0 186 69 0 183 72 0 180 75 0 178 77 0 175 80 0 172 83 0 170 85 0 168 87 0 165 90 0 163 92 0 161 94 0 159 96 0 157 98 0 155 100 0 153 102 0 151 104 0 149 106 0 147 108 0 145 110 0 143 112 0 141 114 0 139 116 0 137 118 0 135 120 0 134 121 0 132 123 0 130 125 0 128 127 0 126 129 0 124 131 0 123 132 0 121 134 0 119 136 0 117 138 0 115 140 0 113 142 0 111 144 0 110 145 0 108 147 0 106 149 0 104 151 0 102 153 0 100 155 0 98 157 0 95 160 0 93 162 0 91 164 0 89 166 0 86 169 0 84 171 0 81 174 0 79 176 0 76 179 0 73 182 0 70 185 0 67 188 0 64 191 0 61 194 0 58 197 0 54 201 0 51 204 0 47 208 0 42 213 0 38 217 0 33 222 0 29 226 0 23 232 0 18 237 0 11 244 0 5 250 3 0 252 10 0 245 16 0 239 22 0 233 27 0 228 32 0 223 37 0 218 41 0 214 45 0 210 49 0 206 53 0 202 56 0 199 60 0 195 63 0 192 66 0 189 69 0 186 72 0 183 75 0 180 77 0 178 80 0 175 83 0 172 85 0 170 87 0 168 90 0 165 92 0 163 94 0 161 96 0 159 98 0 157 100 0 155 102 0 153 104 0 151 106 0 149 108 0 147 110 0 145 112 0 143 114 0 141 116 0 139 118 0 137 120 0 135 121 0 134 123 0 132 125 0 130 127 0 128 129 0 126 131 0 124 132 0 123 134 0 121 136 0 119 138 0 117 140 0 115 142 0 113 144 0 111 145 0 110 147 0 108 149 0 106 151 0 104 153 0 102 155 0 100 157 0 98 160 0 95 162 0 93 164 0 91 166 0 89 169 0 86 171 0 84 174 0 81 176 0 79 179 0 76 182 0 73 185 0 70 188 0 67 191 0 64 194 0 61 197 0 58 201 0 54 204 0 51 208 0 47 213 0 42 217 0 38 222 0 33 226 0 29 232 0 23 237 0 18 244 0 11 250 0 5 imview-1.1.9c/support/imview.sh0000644000076500007650000000040307653237136017354 0ustar talbottalbot00000000000000#!/bin/sh # # Imview fake shell script # This shell script will be overwritten by the installation script echo "If you get this message, imview's installation somehow failed" echo "Contact the author: Hugues.Talbot@csiro.au" echo "Sorry about that" exit 1 imview-1.1.9c/support/imview_banner.jpg0000644000076500007650000015110307653237136021053 0ustar talbottalbot00000000000000ÿØÿàJFIFHHÿþCreated with The GIMPÿÛC    $.' ",#(7),01444'9=82<.342ÿÛC  2!!22222222222222222222222222222222222222222222222222ÿÀrX"ÿÄÿÄI!1"AQaq2#BR‘±3b¡ÁÑá$Cðñ4r’5Sc‚“%DU¢²ÂÿÄÿÄ:!1AQ"a2q‘¡±Áð#Ñá3BR$4rñ%b’ÿÚ ?ùþ•*UJ•*UJ•*UJ•*UJ•*UJ•*UJ•*UJ•*UJ•*UJž¶µšîQ1³êŠh}=q«Ïæ dÈTàü ½Gg›Án§¸œüRŸ(n)eä Ú/NÅk0É̉†UjÂÆ;cáÆæ®`‚Gà’‰Ü’;Ô§³…[ wÎ}ë#¤³e=¬¡ADDyÛ’ÇçÚ¦Ån°•l–Ç${Ó±@X€€ý½‡HŽÛl0ç–ãÒ•ê ƒ{JÓ¡JF9 ŒîIUŠŒð&åVFÙ8üþµÅÌ*¥rdnù&î‘UÄ“»(@p¾ÕË[A 9óSc·ŠÝ‘ó'úR’}Ò¬1RÀR­C:tÇ Ò`}ÏhÒ61†,G¯¥yYÁ$gŽ1éP&$¸FÛžø«¢7oug"ÂÌÌAp>k‡c,›•{úSÙËxv!ç¶'hÓúX,;wáˆätp9ü .è«Ö»c”óY×YÙGuªãUgÉÉÈ­kPÒ^(A÷è m>]:k½ø àx`îoœöãŸé[b‰Í!¶>¸VÆ6K°ã_ñ~uc Ó®®4»Ðð‚ìÖ‡qEïµÛ»¹TÚ–û|ÉÆìúÑë½$Þ¦GDºæDAÏT-# |ÑÊÂØÃÈ Á÷ªô9Ç­}—CQ³BÆÂÇ×ñÐÞ>ÞùPæ3ݹžrò9;FáœcÒ¼…Ì`r¼ñFµÍ:=>]ð¾ç`ÇÖ¡ÆYíáºF^ùÅ1„ar5QË®d¿^¨}Èy¥,#Ú)ÏoŠh;©E'~P8ýh£(uX¥RŹ$S3ÚÃ*L®8òŽÞŠ–{CY› ÈRqN~í¤S+yO}éélÂâÌ0?Þ£˜ ̽ðvóŠ¥iéíÞ(á”ñ”ºàzv¦Ä<¬#ŒŽ*kß™£Š9‘\À»¯{Ô½3M}__µÓÄ˪3Ž@?ûÕ ¬¦I³w£„p(I=øÀ¯¥ÿ ´ ?Tü/³ºU¤×O½KÈ9à÷ÍR-ÿÃj§É¬$wxÝTœdò=ªÃo{©t·M·KG, kî!¹ßž|¿z; G¤pc’¹Ô´ë;}Bâ¶…eXƒøã8Ö‚™uôµí m%IB°).ЧvO>ôÄ2Ég¨Ý߬ÆYfTÜ̘%—×õ§"—RÔ£ŠËJ®Fç¹gwüÃàÕ»ÃÝ’CMâýý½Óõ¾®Ä`¹®ôhæû "¯¹Uéô«‹ÝB{ÛYÌVìÛ¶ àÿjÔlµ-:#Nµ»µV¿X¶øª¸8÷>õH¾Ò¥´¿T»Y"šÜ`‚1|ÓžwZhÔ@°0¹#’M–O²ÝâZ6Ó©<Ý“ŒŸ½þ€¾Ò®ãC4Š»¶ãzkufºêÃÂo ©x!€ÿÜÐ.™»ºž'£_6üåŽGÆ*E¯ìù敦…"%dp™çŽþ¹¤‡?~ÖÛºéh´Ðŧl¬9viÖŽÇ¿cÇ*ÙÕðÙ\A¦î¿¹hä ’è1öEŸz=ÐKÒ¬/Âk¨®ŽŠpî?†£h:&ŸÔ:þ’/á‘á§â_X k¡"#í¬ˆIâMÃ’n¾ò©´©R¤®:T©R¨¢T©R¨¢T©R¨¢T©R¨¢T©R¨¢T©R¨¢T©R¨¢@dàU§¦úN]AÅÅì2%°åAñ?íDz;¦#–/Úwëå1#rãÍZ%µºlQÇ b²É6vµ=‘u(P¶úH+X.0ìA1Ëãu$ç=êÔmÁäú­2bتw8ô¤0YÊ “vd$ügRcÜ (Ú=*tvË–$îøíMM&ÜC¤ÁÊ•f¶¶öîòe'…ö®e¹{‰Q’Iì*âsͳ‰`C3¯˜ Ž{Ñ ݃ æÔømcTÉÆà2OÅ žà°ËæÇñŽsSK‹ÈZ4R­I‚Ö”FÐgÙ‰äÖ†z™µ£ê…”PÓ°}Œ~ßÞ£„ä=Zn…²ÛE ÍÆ*«p†)›‚{Re‡hµmviM€¡C–Á>¿"öVÑV-C g“ qz3evª9{žçÚ® Ž<ÞP}.=I.Ï… n7Øâ®Ú|3Ûâk‰™ßÔ+¸¢Š(‰ŽOµ>°¼Ë…_‘ÍtaÒ†zœR!8Õîæ¸f Þ³]fËPѵ&¸½–ÀNÈÛ¶ã§æ´ŽªŒè¶‘´n¯1åч¦Gýêƒø¢£O´Ó4Ø móFgBX† Xþj’¹Îu-3$Ìî[ÇÎ=ÇJëj‰uÔ—ÒK¸N-†0QFìüƒB.yS.…9m½ÿZ}¢ƒbÅX ØcýkÅÅVx‰ØÍ·ã‰¬ ácÔj¦Ô;t®'÷ø',îÔÛø2*~ ¶Kð}*V£àÈ#k=àãÌ®sµ‡®}h\ä9ðüq±Få\zýýêE²µüè£$nQ€@÷¥•bG<†nºgè”ÈSÆaÜí`AÆE:$Ú]IÀÜ™çx©—v6–HðAvn&f'j@Çæ†É#+‡]ÈäciíÇÅF¼8Z­F™ÐHcu;eq#îF÷ 9ROoŠ“&•p.6î|@ °`ÓI.ï2ó)#Žkë]2Á®t=&å,m^e¶Etu#9Þ¡)[Hå|Ÿ=‰KdÝirn×"G)…9íD:V9m:¿J–HÝ!I™™2=‰?­nú弓ݾm`¶•Æ×FBãŽÞõCÔ4¹£··–K‡ÝŒ"!AçŸNÔ!Ý Ó'S(Ž>kòUzê-^ÖÂO2!ÂÄT‘†$wàÓ¶:ÿL=í›Æ&(áa¹Pžrx%½+::­ýœÉq¥ÁÜV)ù‡¯`›©5‹3é¦RÐ/!ž,2ü=ªåÑ49ãÝng…ÈeNû"¯‘_+«©Uïô­BÓ¨¦ŠêXÂ['† ¹ˆäüã?éDôý^}"y¦†Ö0ï ,G`Ùž9v4;mÞð^U*\±ãœ{S’DèVw/áÊ gŸ|U´0\eÁÀ‹Eß0<ÃëɧP¶žjŽ8g¿VÞYÜô}¦©arÓ]\&Öà–FϘEúK—Ré–¼0ùìA¡Ö—«m§F°˜Cx€Ây™‰õ«€ RÅ-ÌÉÈ Ã“ŒûÒÁX^7PÉbw“-½?²«ßôÑéö”N«c’¡ÇÎ(lv“,eŒ¬Í¸3Œ‘íVMkJ»ÕnDFOÜ:HÈ#îj šÖV‘²I$²ìÜ‘÷ uòÜ×ðÝG’æ¶gáÀí`Á=²­]3ƒ©tT@yäw*3R.ÖçXëF·Ž%XüÍ!PpOÏj‡¦ê¦êÚDoxã“yN7 z“ë]A¨C?\Ù®›n"»,ÓÊL„‡Sü'ÐzÑ.l0÷¶B —ßû{«•……ƃq&™$ J¥wŸ)ïõ›Mgqg©ÛÝÀ…ÒRVÉïƒÛÞ´+¥šæÎím¬í ,Ò®ìå†Køª×NjzM­›¬ÑÞ\ݳ1-ŒzlU›Ihhiq9íÞÿ²´kºÍÏí=6Ö‰t«È]®gfà ôÁ÷¬»Zº‚Öâþ î×éÉL®¼Žs»w©?ïFoú‡M‡§®´øuÕ¹úvš2È…¿6=U éþ¯ºº¶ŠxZH§ÀWhÃGµ¾qÇUc*¢•Ñ=²3‘”å„Q]\$PírÜ«çŽÙ£º…¼pÙÁ`ó·8ù«]Ö›û+I·¶^š"·c•'ärI·4 Vn.¢Ž4G`ˆúÿ7=Á¥†P -³ë4‘½î8ç>ù®œ#zVûVEŒ«$aI2ã ž0)K£ÚÞF’Y£å‡ï¶ïøÒÓ¿m¬,–Ýt×{øÜ}éÕ—CüN™‡$r餑oæÉõ"Ž–HºAã°:zÍ 9G| †ÈïŠmÔC½ˆUF)UAZ~â'²WX»ÄĨ—¸Ç½qgi/PÝï’(­Ü‚2…\÷$Q MYä0¯ìÛAi¿ÂñælƒœÜcàñ^E ÃÛo ÐËÉø©:ΉÓÏq¥Í:…†WxÙc+¼ß>¹ªëk7ñ2„m§ÊgÜ+š]0Dî”mk›§÷×§u>Âáì­&i.YX¸YX–Øþ‚£jÒøíáe6>j,:‘ƒM+3Œ ýÇz—u: R×ÈØ$ØGõ£‚±—@è‚8®¿?ð‡¬&MEœÂJ(ÎñÛ>”qä¡W‘d‘rãó.ÓÁ?ÓŠè4Ë?¼òGÙSÄìG¯j-¶÷’Zܲ¼w Èf9ííM‰Í%ÝÜŠ _‡¶>K…’Ñž€'=걜ªŒ›£ 1*ìp=Á§m“Ä]’Œ78#òŸ“W‹¾[hcÔdb “°`àýÈãÿz ~ŠH¤0«$€ÿ„ãiSïŠQ%¤PtN™’4†’{~¹áFI wÀÚ?—œ`zTK¢&|d‘ÆW=ªu½¿H%Hrì`ã‚1OãɦÍ6©à¬¶°8"5Î}Øw£ÎpkFOèbðùžóLžÃ½~]ú#½!£¶ž—¬ñJ¦X±ƒœÿ~iPkÍcRÔm-ì¼)">#IA·({ïŽy¥]ÆiC^ð¿ÿBó¯Ôx¤¦f3Ò0ÑDÐÈêl“óì³*T©Wv’¥J•E¥J•E¥J•E¥J•E¥J•E¥J•E«çHô‚̉¨j ¹IýÜ'^æ¼èÞ“[õú„JñœxQœ~Mh‰Gçô¬’Ê\v1hŽ*õ9yôɵS(ô¢F#})@›2O'±?éÚFµe‘Ío¥kc ÊãÃFsßÞ˜‘~·Í>Á‚’OjlÀäѰâÊ Òe°±î=ª «\\Ó–5&i7 Ú¦é°à– 0ZY;ÝH€ ™])¢óH}³ëSÏs&TøjFáÚˆÚZË3³SÛ=…?tΑíF=‡zÐÝ0vPo¥Ú2 P¬¨eì*ýÜvÀ®w¹íŠ{z^l@ã5XI(3=}j;PéhSmä©ö²ÜË3¾2¤c‘ïRm4èçüp7Ùõ¥ks;0€ap)Ï[¿Õ9bü"…´jÍåY LÖ±C•DM§¿¸ —8I‡z‘RæÕåŠÂ¥A=Ïz‰<³M¶2 =*¦•ŽÃU†’¤YÜÍWW,¹ÆÓGãÕ'Dsg°” OŠW!ޝ‡m‰Ïõ äÐýû-šm#žáÈÆ,óÐtùœ*Æ•¤^MuG–IŒ=qWk¶Õ¯þ–ÞÔKp0Ç#ÀïV ~•˜l2<*Oæq’ÀcòØ ´ôîŸ&ƒ¦Éq#¬«>!¢ƒ(÷ãÆi2œxùQýVȧÓhƒ¶Ï÷§cíÎyâºÚB›&{A ƪv,q†ìHïéÍk];dmtH䕤&'ŽÔ-~Õ..ôóq²)I6Ù_.ݼ¯Çj²é "Óÿ {P0€°k52êdódë¯é3I06îÉm#o›Ê ©¹ïϯڳË&kËæ•Þ?¦ŠRˆëüc>Þ•¨jºÅ¤—_°íîÐj3ŒlÏ*=Iý*›k¤Ü´—ÐZ˜¤hä,á\åÀ>žø¨æ‡rƒOª~™ÅÑŒ‘WÛä«Z­„ÊÑKó™ ¦ÀþƒŠâ[Mj}>[5¹Ø' ’qïVqcx®Ðí‰IÚr8ç?5Þ“£]\4öìËÚ1>ÍËý±WA#Í—¹ý›üò¨ —4PO/ŒÜª“åÀíÅF¹·»·J„˜]<ë·ç šºG¢\\€˜”û §9§¢Òî.¦[2S¸â0˜íž*mmÝ&99nÂâB«é¶·–ÒÛÝÇl7¬Û™PÉõ­X\ÛØA¨4Ê‘i”¬[Ânç‘ú 50Ëhëµe‘Gt7AÔ-ìíï­HºŽ#e‘¶•QÁ'5hfó¿|œÿdί¯^ÙtýÖ¥i5‹´iµmJ¸ù ·oùªŽ…¥5Ľô÷«y â "$ð>h¶³Ó½!æí¯dY%ÛâG)À>Üú|ÕšÕºY-¡xäDUÝ7·pZ‰\ª¾¥¥ÝÚkVfëiVW*«’1·&•”¶¯Üq§I“Œ¯pAö©Q©iš6·§>Ÿn³ÙžRä²°#·ýsUÛþ¥i¦f‚%† T@P3šð9Z´ú F£1·ú}Ö³Ñ6~"‰QcŒãeü¼àúÖaep"™Á¸Al€\$ÿµ7gÕoæ,,‘Ÿ¥@³êF“L†ÊîîM¨p 18Æj>¯ÔÚUýŠé ¨0‘¥Ž¥v‘ÝÇ5Aí9´ri5 v×°ƒò^{»3$Q²Ç´åœç?Ó±¢]¢Ëõ×gJ¿{Yü1âHè$ÝÍ ³¾ŽÚ)Ö)c* “ @'ãC§:ÆÇLÔn.UTG2…iÉûqŒÑ%˜ä‰ÔáGÜ+n¥ÑZæ©*I/Qª:úÇh~üóT®«Òµt6zÔm& ³ø@)ê«®[êwv:^«©êæî_4FÆÌonh;Æu=ýjÛ¬ô¦¯=œPؘ^H. $ÈõÆ2EWntJÅֻߜÇÊÿõv§–:<‚¼“[¿Ô¢[?6Q†Š•Ø×_C¦ó ¥¢/±ëûÆV_l¯ˆhšAÜZHi=1×=p #Ú`¸×/à“rn¤G’0ŠxQíšUßMGw’­> Z …ÊÄãçŠUÌÔ¿Ì™Î^>]?r°B0®ÄsøÚÆiR¥KJJ•*UJ•*UJ•*UJ•*UJ•*UJ­!Óµ§k«~–>ä?zÓú<ºÖ«²«³™ …²iºtZm´Vð'• VyåÚ6ŽSbeå;(TãÐcÐQGÈÁ¸ï\Å0ƒ'o<ñMMpò¨H¬í!‚ܵU”ñ”¹ {Š÷y`qœÔ-øÇ=©Ø§< Vu­b€¥,‚@\çýê4²3Éá.G§µpn$$…îxäVÌâÊÀ|gÖ›¿BVÜÙ]ÚY¬³€9Á-ØQËhó¼ø‘Æ "…‹„u1¢ùXÇ=è¶conÄeõl1Nƒâê}íËXÚ˜ãE WÛÊ–Èò6æeÉÏ¡ö«,–ê-Ù¶‡‘W9½v %Jé–mx³òIu–áW¦·Mæ<Ô ”E“rŒfŠÞݤ[—n[³B™üHÏ`sœ×&aµÄ'°Ø\.N÷¢aŒˆ¨£€>ù¨Vð´Ó*(xÜqÀeÞ+X²vñéó@ÀU’•­šÄ7²å­tmUœ¿”9Ú¸ƒV‹Ã%ÀÜ@ÝÞ»7Fá  Â·¥i±í÷@âS¨Ñ€ {\É:¤d.I'Ž*p2Ìò³“è¹§¿6vùO½67tœ/!Ç›Š¬uTWnm5 /aVY1åçãŒUž8S¹²*‰ø‚³tÄv²‹An²JÀ’ ñûÓC¥µ‡žV½ºXglºdq€kõNz¡’h7’é÷w0@mÒL, 0_M¾ƒ½Wáé­Õ$¶MBÜeH Òë÷ɉ[už£ ²ŠWŒ2($a˜¨ª£#Koq$Eáyc%ËrÕ¿U4R¹¾PªÇïXbsõDKn;H8óÏb´ë 3BÐl€iMü¶©Ÿk9#8ô8>Ƴ½RæïHÖ̰Ýwø¨ëÊO85Ö›ª?Mº’'’Id "ù8å³B܉¦™ ; –üÍï@ùŒk*ƒ}ÖY#Š6ËŸ%פ +§µ|ÖÕÑ?ˆöz½´Z~¡gjº†w ŸÞoƒ[Ÿ¬i²Ú¬2¤P…šõñ¼ïjÂXæ1Œc•>Õ°iZÕ÷ìÛg¸¼ˆƒ}ÁJHüËÇcH"–K¥aê£hòHðÜKm“0…\î«ïCj6w]7k7«<‘¯™O¿^k»¼–ò?Îdˆ¶1ŽÄgNˆ6¤d{Ƶ(¹ñar®8ϸÏ zœ~ÿø½ò“B;¨¡óÇÎío—VpA©ÛÞä¤÷R>É'PF¸üÄšm¬ÙÙjÒZ4jf’é£FP2óý3U^›¾·[9/îµ}RÚ4L̲HJ«9šÉõ Õ_\º’ JâlJÛ%^8ÏSµçŽ9_FjײjÿC¦YÝZdx“K0Vó¶¦Ä[&PX¾àÇpcì{×Í0õïRÙ0‰î3°C,{†äQ3øÃÖh¨©j@%­A'ýjö•V:­,krôþ¶ÿWnnU¶œù—žù5 ºŽ=WT’aY¸;pǸ¬sTëþ¤×5X¤º½‰œ6Ï,A?LVßáÍ”ðÛO.§uâÜ 0Q´p'úÐBÕ§Žßšý½±ht·pCwS¿†%$øÈ{Õ§MÒa¿Ñ¡¾´¹Õ1EÈcϨ½OÓMa¬ÚYéóOw Ð’6A’ ƒÛÚ¢ëQõ'GAôŸµ–*E~VìAãšXqÝEm›Ã˜4ÑË·Çqœý:¢§§†›s2Ëss%Áà»Í¸/¯°¨ sáÝ"[‰§w“2?¨ûzñT¤Öú‡T·ðƯ?„™¸¦qC/u½cHºǨMæYäP¸ÏÛÂ/ zwÇóc§cóöZ¹fah&ËKÈQ·v^21Ö«wQ]lG9òäg#Þ„éºö­¨IãjweìpRÃ…|`Ž}h…ÎÔ‹ Ýü1‡üÒÈåp?â£XÑ”3ju%¢7¸ííÀû(wZÒ\ÜÅog0XãuY'#9>êÝ¢ë÷ú&¼’iq)yJÄé'Ê3ÁϦ3TÈô›8åŠÒÞS<3:«àì?æ®QéŽÈ#†ᢕTÝÊžÀÕ¸Â-;;„r¼†|ÿ¾Å­kvöò5Ô1Ü G-Æqÿ5…¢¾ë;«éQç€ckFöÁõ8­w}§¼3øWA¤‚³¦ˆtý¼Qݬ^ƈo‰6àqéH3v…ׇÂNŽÕ=ÁÍ‘·Ÿ˜í\õ¥TÖõ íod‚ß„9lùˆÏðóíB-gj)yz^UH@ÜàûŠÖ5ïÃ)õ {Þ¥{¨áv_é° ž;gÒ…tïá}ÇQôò_[^Em¼²+»n4òÖžz®SüKTç‡n86LqŽ¿TÇIk°•ksØʉy$óÛ±çûTéçÓἑVÅJFÅqáˆî{ÔÒít[k%îc¸ž7ï©cŒcÆö¦õFÆX úIYu5ä1È<‚>çÒž÷Û=yq7žÕí]P?NÐïæ†æ Á¤´’Müöþ4‰ ì’tÒ™£g‘•Ü21œ÷ã?­qÿPÛÛL-…¤ÃJ Ú PHäÐ+ûä–HÖТ¸3 o?®îa§¬bŽƒ°ãz¡#I>€/óŸÁQ‡HêlÒHöó—6rÒ/¶.óò+‰zÎö;ç6ñÚA¾&PÅ01žÔBË®ã,1 –FÚ|~W•ÿJ ÿO¬z…íä„—q^G©ªñ°’ ™LQØH[~y>Ø¢0s÷YÛä’0F:hv"ˆ q•§CscªC4`¡‘¿xIðߟP{‡{ÒÿS–ÞáÑI:ù¾ÇWa¨Ûíwº]®¿”/üÔÍ3«/lM¼7A¤ Ÿ®ïF EûžÚ¾ß¿î˜æÎÖ–i5›ÿ GN€:Éü‡t?Nê;½ÏTÓîa1Ët6åãh$í®( \˜VMAüFˆŸ+©íúÖ“,7RO8–)DÚÞaÇ›³f«úA:ÝÉô×!íåB¥ />”ÙtŹïì²Ã®‰³l.òåo-v(õÉô‘õÏe\Ñ#KÔMFùüE‹ FËŸR{UžË¦nu+¹–ÚÞv›_.ÕÆGŸÖÚØiÂ!µ ôæ«|Ö²„¹™mð¹XÔãhÇÕV’*'ÔñÈè=îÊ_ý_©qÒøs/“¸äžçš®(ž9åqgÓ‰,2¤ÊUn"ݤz)öš¤YéÄ_ΪûcVxϘýªÁ^}|ßAh`Ž6ýÛ0BIã§¾MŠØ2æ0#˜àð?æ´¿Ä?¤æ0|]ø0?}ÔðÝ$º-KµLJºÁ O>æ¿+ù¢=ßN¹K¹RÚb®w` n>€üÒ¦,t駉Ä3(Enäy‰ã¿ÇÅ*䇡uµi÷Ü2{¿É`©R¦¬IR¥J¢‰R¥J¢‰R¥J¢‰R¥J¢‰S¶Ð5ÍÌp %‚Œ ÷4Õi}Ó› mFêâ1ýÖîêïK–Am26º•ƒ¦´ô[…|ò·/!}ªÀÃÂǹ®¢Bˆ_qÆk‡G;üVŸ[–ÊÛ€£»’HUÒ›ÚÀù>ÔAV8т࿾*&ÜÈsúÖc&âåí\„2pÇ©© ªSŠõ);yû׌Yw;(.Ó*¹MK„ Gqê*lËöf?È*-³Dìg¹©é̈Þ$nÊÀð‰ý0UÞGÓÚêXqŸzÔXÂ^O)Z_ÞÜöìsÏÕÝÉEû eŠ–qžV£ÌØŒðI=¾ôbGg(Hèk†ÊLϽz6àùŠõ£•d&Lî4ý¢“)]ƒqzÖ" œš 6ÏÊ1†›ŒŸ½CÔe/.Ü/zuf†"UÀ¯ µÅݳI'‹ü$fš[覡¼åARªëŽsŒæŒ¢€1Baµidí…jÚÞO W’7sžø¢ÓFIC#°¸1†>cÈçµv¼wqjêÃÃ\r=yÅxê"‰™ÛÛ­Ì®\'»|ÐOÇm9âéý¡yWÇvvaœ’(”3ÅoIpØ…O$rGÚ—ãDøy£ÎBÒÇ u=²½‡­ '%À _8îšÆá$ØÑJeãS¡–êFô•u¨Mu",ù’HWab£‘žç4åžã+ò3Ǹÿ×ÅjmõJ”´a%¾ê ¦é“Î¥Tpð?J—je–6,ù9ÛŒci÷©€ŒãÛÒ”hû2ÊÉü´IV°E¹™àqÊ&ç>ŸÖ·ëÎ…¸ÔzKBm>í„‘Ãó¶ .Ѧ¾|WcnX€P63Ïl×Õ/=®·ÑvqFádKhÃs’Œ`Ð:í¤€ÏU]›B°Ò4µÓu)EõÞ_âXǹùïR-cé \Ù•Î" #‡ñ3Û i޳š+M:;{­MÞ÷Êå0ÙçîöÆEf ©5ÓÉãÌÍ0ÚÌh>ÜúÕ6×9ºåt4™v²I64œ_×Úÿ\#–šÝþ–e‚ÝÑ!¹gH¸õY[;[[‡¸Î$%•°~ø®î#¸À·Ý ÛÙM@“J¸šyŽÀc*[žM$4sK§$²6èÄ{È"ʲO_ª…®ÞG4Š‘¨Ìm—“Ôv¡Š¼®p®(¼úÊ«2]¨lÍÛæ‚ÞE¡ÿóQÐåH4Ö9¼Ëñu^g›;vßË÷ûµÄvjò“o É?å œšú2.¸Ñl:JÛN‘æ–â+DÉ@B‡±=ûÖ×¶º}ÌwŠï&ï6óµTc¾­l=­×J({Hž[¥IŒû2ñÿ”p*‹‰9WzHÅÎë8Àà|Ï_?U`¶×tµÒá7BIè\hÈ î1ïíU޵Óõ+MrêÿQ´ Öó߀§8\‘‘ÛÒ‚®‰ª6ª‘¨QõD`|¥Ï&´]~麕4Þ›²¸>; {‰2…>cÁçÂtôÒͮن¹•íD±$7¨5 ßèz-û«Gcµ-½KŸ8=ûüšX`i7Õ\ºÇÈÖ1¢ƒE}ùû«ŸUº— @Ðb7KvSPyÇô¨×Z{t§áäpÚÜÜ[O´.Üÿæ9ûz×;¨'ô†ÀN0q´ŸïQ:é5]N[ Rí JÝ«3*ÊÁ§^|0’=÷¬Ú6´6ÂO†G·C»«œ~À ümYºoKýŽ¢îí”An`Š› ⮚¥¦ë7²Ãem8”  \mÎN;gŠÎ4!%í¾£ ±‘¦HÔøx9ïÉ«—Fè·:CIªÝ­á’±ÜÍëÈïúV§-+A“D¼·¹0ZXÉ( È»GošTÝk6M£:‡ˆ«Nİð¥Aipå|—J•*5IR¥J¢‰R¥J¢‰R¥J¢‰R¥H œ Š#}1 M¯jb$LÅSé·=«tЬ«€;vÇ¢t_ØÝ;øˆ¸ŸÏ&{ж[Çå'Ås'y‘ÞË£ {¹e '•{ùsš)Ú ç=ÍOijÙ#ŸJ8fV=·Š H ¤qÙu¨œ€ÌkÍÛbÝ·“ëS$µ2F±!çÌǵzöª±…<¨¬{–š´Å´y]Äw®§·vÆ8Þ§ÚÛ 0Ç#í^L…ÈFŽ8¦µ¸´·ˆNe…ü¿ïD,džIçûSöö7cÍI½O§·$c VˆáqÏ EÁ4ÚÞ©æUîxïOÝ^ xÏÍ 3żg=«„áNHÎM.9VH ¯¬S“ƒÏ=©©.ŒŒ®7aO"¥ø*]xÀô¹h–5fnÃÞœCÀ¤ A)ÈDr+cîj=êMmT‡'·»XÏÓîÜ0ǵxmþ„JÄ™ 5o°ASÖÒáîãnû›.hãżªƒÆ05<þ}½h¶œñÝÛ,˜ÆÞâ™§cl²Ð<“• :iP„@»H;OÃalL 4ý¶Ñ{'R¥1†4+PÓTÝñOˆçI­®¶ h³”Í™ó´ìqØñŠòæÓ|…Ôþìúôõ¶‘ºCædÂñÎ3NÁm+<›Èaã'“Þ” «k‡(¨rsVӌЇ„ ü™àÐïÄ]O[ê^—ŠÂצ¯­¡·pí#¦8qíW+˜éËr8àûP]K¨ºËZ¿±†á­l#)`UWÀãœâ­±m%Í?š&ÂfÉ 4r~üXbô~´ÌeŽÑåÈ>b;š½7«†U†Õƒ²`ÆJ}ëpnH,1os⺫;I8Qß퟊¥tÞ‡Ô:εÀZÚ;pd•ÙJö>üQ8 {4Œ§Ç÷ýý•Û¦µèg`öc>S°å¿Ú‰'KõÉs™pÀy˜"öùÅ_úŽúæÊUh®¦J¨¥ êz…”ð¾ùÄp"Y‰]Ç¿·jllšL±¶I¥†=8šIš Á=þË9¥u2ø¸³›‘†6sÿ¯µ_´ýVë§ôÈ—ê$yŸ÷QH¤p€~R rG¹«&¹}sªMpe6Öû£Îå'h#²üçÞƒC¢jE¡%¦á,>&ÐÒˆä`œc€)‘D×;úîÚ?È¥G#|б²›oÒ¹g°É>Š$ß´uX ²NF]•·lö'Ü{U»^é -¥„—××w4ÃÅã¹Æ1÷¨Ö=5>ƒ.û¨ÄlWÊ6à|ÕËNú;Û[–º%Ͱ1º(bp{ÒKÚ$ß-úålÔjÜÆ7NÇçáIö7ÂÏ,:Zq ѽ¼%O–_.þÔÄèë’Ìì¤ÇŒ©_2ŸsŸJÕ.-tëÛ袳’Ìhæâ8®º‰/.Ðî\ΪJúäVgøëc6¹ªiqÚÛË46ð³<°Àx}ª‹ÒðDÝc§É‡&îø!g'!OÅ}X ˆ.Ï 6íÚF=*ÆG _hºôÚɶŠy@,FÎÏcÍ[—¢µˆDM.<,pÊO!Áö«Lz¡kªjZŽŸ¥—·{Ù6Ý£ö@pAÕ¥YÚ[ˆ4øÊáQ7ˆKÆxÀzQ¸€}9AV/÷û+ê.‹¾Ðdú›ø7e†flÔNœé­O^G—J³˜n\`¾€ë; ýV) § ½‰í™çÛ&ËŽk?ÒugðæÊWºÐÀ’ñÀÄÓpBú }ê­U v½ÔUäs]Ù²"¶ì°å‡¨Å[ç´¹yl&ŠÙ“2Ü?ôÕ—VÿÔp]ƺ}ÌWäK½#AþäûÖ‹ÓvöÍ¢iÿO7Œ#ñ eISßíšØ)ðHø]æ4{}ǶÍg¤Ë¨]i7˜U¤•ž`€É8ïš¡Kø±¥¬ì‡Ay¶®g¼äWŸÅ¡ºÓ,"Óí£‰ÖéÆ)$¯o.°ƒkü˺AÎìrhƒRÁ/íú›S–ê(bÒ%•U¹sß#4fËG‰¢ %ü„y•ÀàöíUþ‘ÑäÔï¶·&tmÉ##Õ­ôOE%£ßêvKûAÃEã '¡\„V·9Ï6â³»­i\…XÛg(Ì8? O¤ÝÚ_« v6²öÈÏjÚ¤èâÇ : >U°{zŒUK]Òtûº2nú«fÜVõûTµYTÙlš °$FE.~äoš•sf|'™Lá¶··Þ™½ëk»©ñúR®ãƒnpXcŒëJã¨-ím"¿ŸGºŠ'PŠåç#4¶Ä éê<_U3šC‹ht<ûžê.Ÿ}s ÷*ž-«$›#ðÊyåÅÝÔ×[q1k²¥QYŠ€GcÅ ‹Xµ›[¸¸¿…ƒ:†ÝY‚Û f¥ýxÔng–(äH”áC¦ œrqLòϧíÐý4²êu2·x»ÿud¾¡‘÷ù§ô˯Û0Ü.¥áˆí¤ ÊFâçŸZ! •Å숖öåcƨ®ì¬#‘žà‘ZÆ7IŽ2qëúÒÔ¯{£µÖ—<>< à„ƒÔÕê›ÇÒÝ­è:žäžÝ—“SâŽ{Üú…§g wRz¢ö?ÎiÌŒêDO¯çÏQŸZ ÔuŽ­‹ef²HŽbxcP¬„g%¶1Tý]µÔ#¾–;˜$oüȉHþõ¢Ôm^;®y¹¼H·sžNE?NöDÍŽeßÖþEo‹E2ùºYÂpA§4üøÇÐ×DSO´];P™¬oÒãR20àŽêÙã½Y­.oå½YndUw\ƒœœ÷ªÞ³ÖÑÜÃGim$172øKœƒÁô¥c}uue¶X@(G8'׌S?–‹Tjm=úb»Úi¡Ó»~¥€¹·˜É#ŽH8¯pqÂÔçÖ!²¸Lâtˆ¢:'> À¥UÏY–¤IciÝ!-#ž=†FiVMDf) ºçæ²µšf±¦MÀ‘}8éÞ¯š²°ºT©TXÒ¥J•E¥J•E¥‚iÔˆµ:°àÖ¨ô¯vJà «ÏáçLGªßÉutŠðB0U— “ÚªÖöÍ+…D$“€­Ç¤ô¸tm"Že>+1\@â¯[tÚ}Ç—`~¥;Lß2O`Œ‚?Jrb±Cpx•È';½OoЏÍ+7æy#ÓçF®›³…äb€¾â=êd+âFÀãæ¢^\$·EQÚ§#6 gJTîá#%:ê±Î¨©(šLà…ÏÕÜä›'š~Ö"p=?µ-ŒêQ¹ý‘ƒœ‚  äð)ËU7‰Ã(=¿š‚ê/-Þ¯o¤ÛÈȧ÷“27%S÷æ­6 mn ¡q€{â·1–àmܯ/‘b‡ Xçƒ]¼— ©¼Œsš%«I”<¸¡ovÌ™Æx‹Tú;Z¤m¼”DÁˆ‚Žxö¦…º©^0>jTgrä·oOzyãWa•äñŠd[HÂ… E•Ž{T[¢ËzäÿJ2,/µ½ý})¹£(pWË·8÷ù ”œ€©ƒ6…E4—SÅ >Ÿ4jäP98¨6ö¦¤Ÿ¿ùïDåýú…yy'Þ‚M=Ñ;( ô¡#\ç<“ïñ^à ‘r•‰ˆ ‚sR/íÑSÄeâ…±¹²Xæi™ >b ¤D2¯–Ò®ÔXø#¹&»¸˜ÈlûàÐÝ5£¼´I¡“paœ{|WSÇ.7 8Î+­æ\VEifIQ@l}é‹_ÊÜÍÜZ²¹Õ”IÇcÿ5JÒžÛY·Ô%xE»ZÊc–É俬·š-ô©b-aµÜ꯾I¼§=½ð{UŠ÷F¹»Ñg³ú;He`¬­nvîqêx¨–²ËëᢨQ¥x×r’r¸ªÿUk1CÓvé‘q$Ìd`¸(>29ÎsW)zrïIÔ¢mB%R¨Ò! §Æx ]WÒWî‚õ¥†=.â0bòNFrqíD ZÎs×÷ï…ÒÜ×–²&S¨W—ÍÏË'Hâ•¢…ôš­µäiq;}b“¹üÕõZ] ³xìÛÇš4ìíŽqŸ1ô¬G¥z'VN ³† bX )$£Å Á;äÞ·¦ÙÓZ4²Iâg.í–Á< Õ ãtn§,¿AW‘\[¼Š›n¤m¦O(»âŒ]ZÍ¢jq)¸Pã\Ï¿üUcC’>®»‰˜ÆÖ“²nÆæÜqý?½Yz—UºÔ´ùfˆ±H¬¨ ‚9ù4в™ä1ÓùQºÁ8<+\Z•®•¥.õ8Ìk!ýü‡99$¨ûv6ÿ«:Bò[vö×1"'•AœgœöÍWôBÞ_¢±Ôí~¶ “å†í¯Œ‚½]mºK§mœK‹hŒyæ1ý¨ÆRH ÑèªúΫok¥júeµœ1É£L)>¹Ç$wÅNÑ5{kx­%žý-íͤjQ±æ`6ò}*‹×/]E{*WÎG p==ªšoå´ÒïáYœ 0¾ £w˜ä öãýjQµv6s×…ôlz®—< f»´cƒ’HÇéšùçª`··ê‹ô±*m˜ö5HsôšóGS½@î9£Ý3}¡Gcoq}Ëp¢H"sÆôÎy>ãI-,$„·ø+à3hHà#ìïÖÁ¿˜S¿ Ò´Ž›kËÍ>;™$œ *í>‡ô¯5FÜ^áôØía•ŽØÉfVåø¿ÕV‘t¤vÉ ÊÏp…|»l`zûÆ/­SZÓ¢x"‰&Uñ<¬A?íFսŽPÄðÞW‚OC(Q§õûv§lcK}B$–v<žhãb³Àâ£40Øj’ì¸Bñ$¹î@äóúÿJZ>Ÿû_V1}CxìsÉçÒ­ÎÚ-hÑ1ï­ŒY=;÷[±›¦bÓç±"–0ñºÈ¹bO#4¨–¡§-ô±´bBË ý?›¿¿ÏšTÍdÊá#:ŒôÊÓà>%áîÓº-]ocœ=W`^ÓŒð¾j¥J•)sÒ¥J•E©V¶þ!äW6ð8£6öùjä×cô&C½ÉR>°£ rŸ” ýªL-'u'ô£ZLÓ°;N*ù¢t,ÓCâI¢ÝŽ ¯D4ñD7Hh,Ž•TúKI®A$±¶ÈòÜ3Ž+Sî…ÏJNy"BO#×4H.ÐxÖ7U«>_ÂÜî»Ú(Ë!òr™#ÂLçúÐç}»¶¶j|ìÔ*c¸Çé\ΉÎÉ]Aµ¦BHÉïOÝ]xX”Ûæ†É*Á–-€*ÌÆà î?4“i§Ò)y1éMó¹( P8›¹¸ÄèxíÅl` õ éH]ô­#°ì d1ÆìÒ‚wqPMÉiŠæ¾BçZÒÖФjÝÌ` dg<úÔ–œ¤lßÅéïPã“8*d€6pÓcŽ9 ¨‡.UÎæbrA5%b‘ûäŸAŒñ]íAàqÞBB–Þô«º¢PY301»œj‘.š!ƒ*Äã’{Ì¢eŠìõoZròdŠ/&6äVèžÍ§ NÐÈ|dd>§ûTÍ ¯ã‰³¡h³æò ö‘âíÜ#”&VpyéÙz ?‡H4N~Ë'ÛÕí]‡~§·U\:NŽa´BZð[€ ܶ2I­«Ké-C½k­>‚g‘üCšº¿H §¹‹N‚YS/ŒBä·¸Ï" uWÜjí¦‘î)yKs»=¸¨\Á²9“êH‰­ÚÖ÷Àúàg§t{ªz,lg·Ò]n5ÛLqåxçñëC:JV-}u Ô"BCï`>¼ÓÝ1Ò–Öz”·QêsµÒ¦É sßžjÉhg²¿ýžÅL.…♇˜œò¹¨ÝÇ%/Pý3"òa¿ý¸?— eÞŸ ô^í)OP®F~õ‘þ,ZAÓV2iq”{†“ÄfbÜ ÍiÝS<–½/©KæX+Žáb+çËמëMžKÉonâ¶;ËJÄíÏ{ Ñ|…ZM4¯i•Ž º±è½Iy \€Å5¸àG?#߃èkP辫n¨Ò§»žíÚ¼"²+:—¥vZ[ÌÒ´~4BEÎ??7CÕ›H¶útš;xå ã¡Bwà`2·¥ @ÐiÁù­~&í,ãÌÓtäûsC'Žƒ®Uƒ®µm6y`³[µ ÌÒFÀ”°ß>Ÿ4Ðè›E¶7×óøâK;îŽ.Ä8ÅP§·Ó ¾‚+i–Yž$ˆcÈ9ç9ôïúÕÑu\*³_ÊЕڠ7åãòÿjv£J# ;$‹Xtþ&øáNHÔQ°3Îs`:Ú°ZZé‘ÝÝO$÷·Eaiy,AäyGÛQN¡Ôõ &Â;7M“Pw”x‘©åWÔŠË®o|{‹y^ëÆž üA¹¸Û»$f´»~²Ò'ç`R§%½JSpHA;Ä‘¶BmÆïÚ¸¥Ž¼Ò~Ò¼ºÿyîÜ’Ç9õûUÇKÓ ›-.®¡ÀÁIWî1U´{^ÿÂC#›·uî ⎯Ik©¸†Õ›VóPY(gŽ61›Aë~üWÑDÖ5íò¤R ¡‘"Ëœ`||UªÓ®¯5+d†Õ‡ $~ü¦]êwË`úLÖˆ³$ÃyvËqìG4÷Mbs4€2!*ñ“†åNõàÕXuÐ|L›Df-ÚY]>+äßÛåß({Íwyq=Ãi#ÔŸsUÞ ²ŠîH¡RUù`TàäÕÞצõŸ HštÒ)ÎÞ‚êškÛ\l»µ‘$‰ÔIää ÓW€—ÝW,4iî•&¿—6Ã[DrÛu˜[iw±Ùìð#Û¼ _âÏ9«Žƒ¥é¾± ¶iã¶*$+d±lv'ÓµüeÒb°—C–Í| ðºM?ÿ1>§š¡w´òL{likH_4G_ÕV/’#tÅ:7‡pŸN"¸Y¼&Éñ£+É#ÐJºzgé$Œ hC?%#ðíXšYô„ì‘ÄâÅ}­|ËJ•*æ%%^¨É¼®e€¢h·¡El×j?a,0½è«š9g6À¾lš÷ÐÀ±HJкbÕ$e¤œŒcï[vvöžPX*BšÂ4]I ‘¹89àö­þ¨}WO‡OPÈPåÉÆqÛú×+øƒÍŠ3x icÊz¦Tîc#w'5ãMíÎ=+ÉÌ}½©†}½Í|ü^ž»&ämìyÿ½@˜á~jjÀœwô¨R«,yïÞ¬–áEÕ8€Iõ”Õ’´@…¼™À>[i$»¸57O±2JÄã=¾ÃÚ©´@ 8:ÊsG³î,¤.xÍXRösOÁHüë´‘Å:QJc9Åtc„å(»²zÖ»œœžßz¬&8¾ôf[„¶´ðÔ‘Á#‘U­BàI&1»Þ‡Tæ¶-¡\`—Z4„¡¸¯-½Â¨õ¦œæB@õ©ºVÅ» 'ŸjåbÖ¾ˆ‚YN×*ìWhíóRÈðøaŽ*RÍ””nÕŃ dßÐÊ8C»C¤¼1ùP÷üÜw¯ ¼‘Ÿ <¸À®êIûs]¤,£¶Ü8R“ ÖÉ7¹çí^ÜN×~PÃîEFðÉ9ïíR£ŒŽêÇÑD"Ú-Š`‚ç?­ѬaÆ*­e~4÷oˆ•b´¼[„Y²¦ººi´7ªAiR~š6Îä&ÿJEBaÈbsF|E¾kÍé( ÷ö­N v *¡shá›Ä_8é„ Ä†ÅZo"V £±ÍW59-t‹©¿™!OvõÅseˆR; Ÿ´µ2ÈSËžûU—öÔ1õ,$ˆÂImŒŽ6¶=ÑšÝn!;ãFÕEê n,/$šáïm%mƒ!FÒrrG5¦0Ð’ød˜²Šuáu¥Ž ú½ž¦ÐFìK@ëÄóŽÕ[¸Õe¶»ŠÑ™%´¶ÁÚprJ%qÔ׺•‡ìÛpB–2ÜöÅSN³ ޲¶S[I#–• îJ²EƒþOO¦òa-ÕœteY³ø‹ã•§ÍÔze扼áŠòþqŽØø•WÔ5'¾ kf¿™†y¦-únúçίÌÇr#yIöö­;”ö 1¤‹¨Ë(A’¬¤€ë@^c÷ú-:}&Šù­w« $zM^z㎴´-ÇCm&ËO(¾7‰ºMØÜsÉÇ#ØQ¾“Òîú†;À¯ÆeTQû cDè‹‹8®žþù é*˜Ê¶É« ¡¿¼»š?ÛR¤a˜*¼ ã¹ïMÚ8\-DÏdÏs$»ëÞÖø”Ú¶±ôv¶Q%‰ ÑœÐÞ§²×æú+]3T•#Ü~¢d âƒéV–¥ÝkV+o—¨ ÍÀ#é‚xÎÉþ`;U'®4»;fµ±‚ÙLÇ#'ãøïV.ÒM %–•yuy#©¹º_ÞH>>žÕJ껉õ{Ñô“Cu1;A]¤JÛZtú“ Á9oQЭ¨Ä'¢$’%GÁ@ãŽÞÕóÖ©¬ÝG¹Fcñ6 ä ã½iwWz¤}%ùaE@ÄœÉïŒúŠ­ÛÙ‹‰c€h«u1}ÞQµùò(ƒ…ÑAü¼†/9¹·#çÙ µ¸¾ÓžkQ‰-§\ouÝö­C¦f‡B’hn­¾¢)fU\ø}ùÚ}>j}ÒýGrxt‹ÁðÛéèh¤0õ=µÔÍ=µÂGû¦•A P}OjkKkk¸ïÛü{(é%˜44Àä÷`ž„t'¦ï®#³N”¹žÎÞÒËgD BäÿoëPºtë}âãRxükÛÉ"]ã `(ýæª £ÞßiðÅ.µ;F@##²; ðiŽ˜Šöîö( },;Ú2wnÁ#üŽ(õ9 ošâ šLÑk4~!´Ð8ÜvâH®Â¹ç·DwJè¸u¡u.“rmàK×@Ù'÷÷9ù¡ýIÕ’tK– »wæó.Œü¾¿5}ü;aû*ö# ‰¢»pcþLó·ôª/âNÏuo7UkyÇî!´“Üí$öíÍdk~£Y þ•Øiôžß^¸YòuÅÌ÷¨É’$ ÁѶ±p8íóW~“¸³Ò´˜.]â•®×rîˆ9çïœÖe+)Ø¥V7‹ ÇG÷ø©ºRO£=žý-ÝmHñv¸RØìG¯éOªnÀpsþR™«sÛ²bH±W\íf¾Ëu¸ê=RÚHVËJA¡ ³€[ŒqŽ~ÕCê I¼2ßËàÉ3Ã$ÙàJæË«µ]BÚæêÂÙšÖY£dv“àg‚sA[Q±ê«Ùm®BÃqeRóû÷öª|eŽ¢³Ävº9ì~G¨>ãüõGa¹»é¸âº²¹ÀºáU³œc8>‡«úýíÿR¶u;“¾ÛÛµE´¹Ô´ô•ÑâkuFóço¸ÊO?4C­úQ_¤í¦O!k….±÷ÀÏío–ÉÚïóæÇÓ §á“:M+!܈͂~ÜÕjÙ]îb™€I.-J€F<øíFôÄ;;B×Cm,YÅ…BåÀ {Z9ÚXç0ÝíÒ¿æ‡AM+Û[¬4÷ª7ô'òW—±¹k¤Ût¢r˜ÃçœÓz¶Ÿ¢‹inõ+ '†$,ï,JpéQå˜\ë6ÒØ]ûH‘¶ÙõÏn*±Ö-w7F]Xé+s~­!3Ë&w"ç>_~xø¥.ªÌãêu ûYt¸áÓ/\•–Øeàôo¯Í_ôÞŽ´X.t)Zæ2c —úÖ]ÓÚ4ZÍ¿ÖÜ‹{O K®r¶+è«mN ]–ÉnâÑT,SD7©ã8ª$M­AÚ˜¢‚x÷úööYލšâx=ýãH-Á*¨þW=ðO¯ëJ®—QÇÔ–Ú©éf ö÷ê€lä†"• pnùrêéäô|oJ•*bÌ•t‡ sJ‰¦ˆ*"P¶v‘ý(¼Œ§ŽäúPh$S€h©%N àתÑL ³8#Ñ^ø*>¾+Jéhd—K[ÇÈy}½dÖ±x÷1EÀ Á©­®Â?£Ó-à## G±Ås¿Šu'Èd?ò7öÿ+g‡D7—öýWsI·' Tbá»÷®.eÃ`~¦¸¸Îk¸®È C~UT>ë#k·Íp¯’ÍM…7ÊFÞ*šê§2ÔhGƒ6<ðj^›![§$=*w‚Y+œTD61Þšáµ „-É £±È~ð ÀmQñï÷®g”#ÜäŒcJ ¯tÕ‡TZ¤‚†H²W gþÕaa¶#Žp=k˜£""Ùå« cÍ$Ø#(]¾ËK[XJC  p•ó=Þ³«®¡;¶¡âívfÉšúveçnô¯–®Èúû…1îCÈ8Ç'œÐÅê¶‘„™Þèœ×°Ñ ‰µíY~ŽqíEúqgŸX¹±%ü+”' çiÁ{…Œ^~KN‹Äåd¥òºðjóžŸKíKG‹YÕ-ãŽíâh­Ó òmØqÛÕ¿¦à´Ôõ‹-@À'…’BÜ#z{Õ*mzïLƒÃxë ;'HìßoŠ%øÔϦM’Oü,ä<Ä ’{½jÔC "l›×ï²ÅÕêLÇUXZ†Ê¢.Ç$óЭ¨õ ©äÓ­ì£Gµ–ùa¸‘‰{cýêÍ$1pUÁ#«×:–vÀ6¡™'QÙ•þsÆ(OVõ ²{]6VšrpLgÊG±÷Œ¸”0éå™Á±¶íH·×nláxÄðÞ›f!ä ØÂŒúŠ™¬]¼Ñ™­·Y³o{†9 ÇcY½ŒQ›¹/'ŠHJ„Ø­ÜqÉãÜÕ’ã[ÕÖRÏÃi£ Wl)ϰ>Ù©›¥z˜™¶´æ³ìT ñX’ -ãÑî®­RB‚ÉÎIo~jÇÒ]HýC>)¶Žó‰ Œ©$/=ûQBé¶¿’u&Ÿ,Ù‘ˆìsŽÆ®–Z^›Óvñê3\øÌC4‡AãÊ¢¬àegk\çû;d³ñ#y¤;<Ÿoj§õµ®ûÁ#&á¿ÈÎÚ¯l‘ƒŽzCYTZô¿PkZWQ¼·/îMâ#ì=²þ•j;G…§kHn$,d*¯j·Þô”W(èÑ"€;<Ã}èDW9õý,×¼E]ØòÆ­[ –Æþ8/â•ds…±Áøª Ta-È*‹r5M&ááK»ˆ¡{©Ç·éUùõÍCQºoÌPƒ$ŠIû(¦µ}GL‡T³ á[ùÈ=ÏÍRõž’– «¹-b–Dp0Çœ}‡Å@Ð •¦=NÐw4ÐбïÅ­ªœž&®÷ZbDÐY"&˨ŸœðB€{v?Ò¦iÖ‚Æ÷ÇkÝO2…Ï”¨õÿ·Þ¡ÜQ¶h¢–HÕöI"pçÔj!.šu OJÁÅÜIìª;¾+©4æm&é¿¿æK£Ofžǰ—šÁ9>å¡Ý;+oBO )ªÃžMóí<’~õhÔlíµM>{9ãŽXäv¸ÈÎ*•Ñ—¶vº¶¶³Lc xáK?•³êjÇÔ÷²èº4š…µ©¹’7Ýá†#$öäzgÌ] ¾k×4™´ýFk'H‚Å!]ѦsØ‹6œÞ"—iäðjÁ¨$òK|³À‘I.é]®I8ùûЭ.í.¡k;˜•‚!ã°õûò3Ùu ÌhÝ—Iã äïßÙH±°ºÐtÈ¥½—e³É„@JžÙöæ‰0ª¯ÒÎ@.ó^õ-ý´Úmµ¬ž,öÛä¶0~ÔõÖ¹h–ÑÙ0Wž9À úŽrGuÕŽ=l¬hŒ›ooßìtOÏÓQ[xSè—W–Câ˜`)øï‘]kÒ^EÓZΟ.¥ H•&röÜß¶{Sí ¶¸KˆUƒ&˜àcëSõ;+]CG‘B ‹†$‚3ÜJÛ,¿Í³-Ç'ºÏ²h&c])vžKh'–<›òè{jÂÌžÊ9VEyn 6¼ožqüY¦`ÊÿÁšgšÜÄNóŸlŠÓ4¥$±”Þ­ÌwŽJœQ;®é(t1ÔÉp± Á[œç°Œ8RkšâÊÇV÷D–T·š …, ÀÇÔËx-ÀY¡ÛŒ ž ‡EÒõ«Û›‰tÿf>*1À„|Õ³Mü?´qy4É Ê)(>œúüÕoHÌ ÞHY£[l‹q"Æ@Gd|P ½%ZâÕ-ç Òl<ï_Hé?‡]=§ÕKi,.±ÕîI ßÖ¨=aÓ!uéôë=ý<•`¥·nÉÿZ+*©ev¶zÍì‘i«päpÌ©Æjë£/RGhbÕãV€ ¹°éò£dýC{mûÂÛt–ä!x“ Lû}êf©¢ÎÚÜ 4þ ±ˆ “»pn 憳Œ«O1cƒÞ} Éì_¿è…¸xí4ˆ´²`9w9'<œÿZjÂöÛLë5žñö»]Çv<¿ÞžÓ®R]@¼‹æÆ#~PoéQ::â :šóUÕ½šJHG¿eÊŸNÕµß÷PI¨iÿwåò¼ïðÃÚ5’Ç ô¹§çw¸WÚ–«{©®»f#Ñ]¥`ÈRPí÷¯zM×­'—êç‚+2wýásýj3uuƒêqË «Ipá\`m'ÿj•T´÷Qøvû–O ˆ8ÜÜœv®xÎmz=­.hm|ù—亗¥tÇꮾ†= Ê@ÞÁãô£“Ã(€­›¤/»pÊåOÆ*·ÔqNZZÜ_é·§‘‘c 20;š¯¿ã5¾åÓîÙ=J¸ öÍ%ºGNk©ÿhMÕÏí,vBΡ|¬¾¸õ4«­P»×z¨ëÚø¶èŸºŒä´+œç´ª5îh¦Pú]­¯Ô4í.Àk‹ÇZäžoè¾S¥J•Zç¥J•*Š'#lTØ%* à÷¡ààÓо tt“í pê®}%j×Ú¼.,n¿¨­jY¶ w5þ„Ž[©—vŒýêïsucçOë\ßÔuŸñžWGDÀØïºfGÜù4òÿ„DY£-Ä‹ßÞ§@Ñm‘9ÿ0¯¦Æÿ¨T¨ïíÜaæˆú…u!uŽw4(ŒÍ* †qÎoÖ¾cºV†þáB–™yû×ÔW7Vª¹I¢Ï¸q_,k25`åˆÌ†SÞ¤ ‡“k6¯!¤/mí&žT ¬¹üÈ8'âŠhº·NõQ¾¼ˆO_tSÊÿš˜µÔ%·Ó|,I>+AïŠ$òµÓHÄH"dì9Í8Y9á.VéÛ|²KºöËIn±Ðu¹ç‚ÒÒãÅ;€gP™æšÑt‰¤º™âu¶¿%ß¿oOûVj—'‰$l±•àùHÉûûU÷¥m®um<µÄæ5‰¸º…ley÷§éŸ²M„[]@Õ9²4èÜØÞc‘–àîGïò=Ñ2=~[«–…$ºº‰™f@—hõ;»Š ,šÎ±tòØÅ8ðLjÆf=xãµt\½5©¦œUõ=ä çOÏ‘å'Üw¨:¶©?NôdöšÒX~ѼpÛ SƒÁfÛK™ûžhP¼ßDO!_ûEžøžhöág–½W5–‰ks=´¬Ì¥i_;ŸûЛӳ^_Juˆô;íI0À¹”F ŽqÇz ¯ ä²³³h‚Ån xDÈÈäÖÅø[kkE$q#iÄ.âGÈ¥°‘4.†CùýQt¾±×õK0%éÃs¼m" £#õËqUc®µ ¾·F»³6ÍnÁeW äøÇǵk6N—¡Å+YZÃjæ‘”c·¹¬/©®¯Õï pñÜJ¥Xv (¹8¥ÑðhÚ¶ƒÓ?emÑ¿ôø,|+›k‰|>«)ãç&³WVý£5Õýä ©Ù¢u»üŠ«éRG=ýô7+µ„¾1åÝŸZÔt.‰¹×ú*ÚÛF¼·e‘¦Îà{ã™@€V6Êí<Æ€4H¢9ù…P»ê‹#¦Ú[ÁýGŒÞ(Åq­žÿ> Ó 2Gä¼ q/sžÇž1ÞŸ×?úŽÆÍ%»½‚â-Ù>$˜Èìp;Õ'þ”¾»Â‚ æ¸fÃJªÞf'ú|TÛžáhƒYA׳_A×›å[E÷P y-Féü1©3Ïn{ Ð?:‚îí5¨õW¹3DoÞ¾ü(8>ÿ‚gXé]BçI¸c&9"fÏé‘V®•ê¨ç±¸2ÜIk1!fðœ"¸9ÆsÞŠ!£çÉ“¦™¥Ñàö€I®¼œŸ—N‹GE’o ˜íY¥i Àe9#4{¥ ¼»¸Kák{XÂÌç‰g°ûU>ÊYàÒíä……ÌeÙUJãŽ@k¨4åh"¿{%FφрOä{zÓõZÀF+¾qXöû.†é õÙÀ ‡uÅIªæøÅR#.£&…ÔúÊ•Ý ‘ŒH#RL.1è>õ¢Íz·÷s]†2’ÝclSîEcšE„ºŸRE¦C¨N$¹“2K‘÷<}…Yµ.Ž)6¡½æ ¾r8vrwö¬Ä'…N–g¼¿ºWgšH¦uMë† Çò)´Ò.!–Iä·)6|éž?õŠ/Óý,Ó¢^Ûaâs8—Íã''µºü>†óZTÒõÅ€PòÝÉvÇÄÿäÇÒÚ=V½ šÆibŠ6íug]óóçû*DÚD¨°5´¤ÈÜ89àóñQ®´½E-üD¬ND±€JÕ“ð¦Æ=R±¸»Xã¹iÝŽìú'¦{æŒÃÛÿ©D‰“ÿÄmQžþ˜Å5®è¸Ó1¸{\-Ök²ÊÓ®VD6w–ëläYœîF8äèjvŸ¨˜®âÙ(’ÒCÈåSüßéTûý9Õ勯ÆÌv>2x$~´ é×öÑþR±êŠ03ê1La1¼=½›å>9 œ[^(×#¨#äVº‰nÏs%ŒÀÈÊN=3þSè~(v¡>°æK‹Û©-VxöÑÉÇðv×5XÓ:¤é`Ç;¬.Ø.ÎGï0;ÿíV©-õTs<¶€ç8o#{÷õª8bÔ8Hw5ý»¬š‰u>s˜'ˆPÜ c­š¦HšìwP»»¡*È1Èä*å\j‰¥K¨Ésc½d-áÈûJ c}G­Qz‹XÑç u²Ë?0Ø‹é|{+ƒuÆ‘{¦ª-µÔ“–c+[b$äç‚{ÿJ>³Ôì±irKon`yÈì;d“ÇcŽ+»}?éö$xwqÒ…ø=©éf¶YXOz\§xS€éX›§ÿ‘ãè>çô 9ñ˜^6htî‘ÝÝÇÿËW͹—GYd»Õd–öãËr°¶DÀõíP¯ï`™H1’üÇæ½º¹Ñ¤ž8ƒ´2ÉÆY‡¶y¦í¬æ{ñÏ20-ŸlÖ)„·²:!ر“òéúZäø¤úâÖ äA¸ùuîI mµ„Dm‹ºÜ²;FpcËïÍqq`gˆí× åvlocîií*îê]Vkˆ­âð‹ûù—·ßŠ™®j×ÜÚYÀ 0RZ¥ ØÏ…¸NOÎ×DÉt¶0v¸€ãîH¾{j¸Pa·fúy$xEØ$ ã‘ð)Í"ËW»Ön“I¼„Ml:›Ço(43¬:ÏV²‰'“J·‚G4Qó»#!¾qÚ¦é]]Ò÷ºp1ÉàݶUÉ"lw'ÔVw°“k±¥ñ­"Pz®þêG⎥sIi‹4†KÔ½(âCÈ㹬¿FïuSi4Pm–EmÑ»›>¹ïZ\­ÿCig꣚æÊ<ªá™‡¹Ç?Ö²¨æš=RÙ  )2»`œi€[Ví’ÓiÙú¢ú/¡ïãXo,/£úYÚB»ý3JªW×Ó›‰b#l­·Ì2Žçôþ”©qü9Zžô%àuT\á¯òŠéb pTë…´DýÑbÙì}Þ£Ç)‰÷(¨ïVc ayô2oUðùa‘ó^IfÈûvƒëÅw-ÌÓ2HÍ´ar{ ðJÀcŽùÍORž¤í®˜÷M„@]ʼnÀ™»´KiÌjé Ľ©Æ»˜îÃm Ü0I'$äÕ ×•=Wi­‹ü¢–ÅöÝ,Q¢\l_aS4¸Á¾Q´GéL$lùÀíÞ¥éH[Q@ ‘ö¨U"wM P¬sü@ûU«¤Zâ^ŸÔmxb[˜SiÈ#úÕZöÂY*ønãÂ~*ïøyôšV±¦ÌË(ŽXr¿Æ3ša„ý$¦)šñÓ¿ EéN Óô«»¸d—É`@ùÝxG¾0+ݪzRÒêYî´É§½™/í§{P¸…•·Sé—fÓýFÙ02)?c“úS‹úJ[j–Zœd“w¹@ìT “yÎÝßóC ~Š b³m«'«NÓù}ˆ\ô÷\èZ>•,WvSÝ §imVÛèAö­KBÔ´íSJ†m"H¾Ÿoä^éðG¡¯˜¼(ØÄ±$(<ïZáÃÅÕ2É4'p†#·ëC¶‚$|ŽÞþJØ5(ïq­ÄW³Ë$Š$WÏ7šŒº‡QjrN¡f, •\!ÀÇ­~'LltÛ[¥gA$ž»N.2÷æ¨= ¢C_½žëd¶Ä‡ˆ â2xlâ–Nit´ƤZ¾ã§ý ¢ÞiþÛYà³™Ô´ŽŠJ“òJ¹~õ<ý3ÔMÑÈÖw@ T•#±õ¨=_§jZv±=¦¥y¾S†+Ú¤ñTëèM­‹É`ñþñX±;>‡½MbÖê£PéZ*ú/©ô®¡Ýœ³ØÚ¾bŸÂt”í#žOôæ²_Å6žÓ« ±Ž’4Œí=û|ÿz¶ôŸ^¥æ‰o±’`$ÛŽ;=êµø…tQq¶–íÖù\8ó:ÕŽVsµË4…bºYÉ#0pÍ“œ÷¡pxϺUœ¾2ª2x£Rôίu,÷Ke:Ù,å ì‡h9«HéÖFëöuœR%ÉBÒM.ì{NõH$qÉ(l¯Ú;«JYKgÓ‘¥ÄÛJ¦@Ç€X°¨:­Ìú”ÁÙ‚â Äãqù«<Ìh'‡œ‡Úü³œóÛ*×Ñý? u'KE-Ο\¡++ ç9ÏúŒSA­ß÷ýþ©V$›U#Í Û´mÏcWöµBèëÕƒ©­f‰ïRMª³ñ€ ­ºÒòAfŽòØ%ÄKáÌ¥r0Þ™ö®¢Ñt«8ãh4Ëhü2ÛÈùûÓú”°ßEe‘Æì7I&ûc4²–*ß\éÚM—IÞ UhþŸf`·ÿˆŠ«t§ZÇ¥ÃÄ’´ÄFÇË’}qŠÐuÙå¹a§Áe“u˜Lòªøˆ×€k×tí?Q–4µ1MmWa‘ŽøãïDƵćbúöùû~+« k&ŒÇ ° ×Sx5î+ä´~“êk+[Iü–°ÈqqÉùàU—YѤմ»ûk­Jh£™YFРnjgýk"é=3um{¨NÂ(‹xÑ6rXlý+q•¢“Lßnû¡ð° †xýišˆƒZëv¹ïž)˜Ɩ–¸´ŽÕUõ®}×Ï6}/Ôq#í®ÞБ6Ì«ê>ø¥ tî·­ÞM"é7*ˆù@½Áµ[tþ¹Ö¬­­´w°Šê!)ŽÝx@GñQ×o­õ˜îì,!±‰£E<§Ïœz{ÒÙo4Ô2Ä Úƒ°{÷ì;ý3^è nki.n4wqAm˾ø÷ª=®‰®ØßÅn±ˆ $o.£gãíÅnòuƨï YÃ`ª¹õlçÐãŒPKF)n^êé„—n†O®7 =±NŽ'9û]¨ýqâ0éÈ|óÑ­²I®½‡~µÇµfߥ´í-¥¸ÔHº‘Øíˆ _·¸®'Öc¸»ZÈa»Uàíì ¯'Ô•&ñ®÷ƒ 8p¾R§Þ¼Skwn÷¦7!NGëƒEªÖK8!¦‡E»A¥ƒÃµ~¬ox°ãÈÎÖñŽ8ÎxQåê¹ü;ˆH”G¸™7æ>¿ÛµVg¸ý²D«=»ªD~Ÿ<Ôê›øåg Ìn%ŠNÁ³èjÁeckb2‡åLç>œ{Öjg”jd °Oaö ²¬öæ8¶D×Q«<Lúäæ´Í.i¥³±º–4Yü2²¢ÿp~øª K35Å´Þ 82S•#ÛÞ¯ºlQÃ/Õ dy.¢ÜæPy~>æµi@2UöûÞ#ÇÿãwÉÆïN:׫=1÷¡Ùé{µ{;ˆÖ,K5Ù‘P>Ü ±û‘Ræéói,«2Lù‘]Ëvö?Eê{RÚKKi{Ë"3vöý¸Ömu;?ª¹Ôü Oø3.ÝŸ#$w‘àLJáwõ>i Í*ó¤èz¯Oõ5«ßÃ-™l…$1ÇaFú…ßU±­í–Ibg&QŽÁ»÷ÍG:“ô æ¸ÒÓQÉk4ÖW³ÈÒHªºƒŽßëJŽtôÖ—2Y^OmpóZ“ã\/›$(©Pbý'k|¿3"þáÒý¯?¾ÎÉùí]W)ùí]ÔX—•í*UJ½¥J¢‰R¥^ÔQyK«ÚŠ%^ ö½ÅE˜¥^׸¨¢ó«µŒ¹À:ßI¸ž&“ÊŠ?˜â„¸UÊŠ÷iô^ÎÊÚIÒ]wœàš•¨YŤÝIF’veƒùh ¢éJ½‚;ŠéWsD.®m§–2–ë+c±#Ö£È$*¦3‘Å$ŽƒkÈí·ÈFx9®ÒÛsmUgoe4Îóïó^™Ÿvíä7¸©•fú)Ö÷[H¤D­Æ8Îièïm ã…–Žè•U÷&ž’íËÆÙgôa\£eU?‹>Õ ¬aX6”šmÄvë>ÌÆÇƒQJ`r?"‹Åi;B —4죓M},A‚Ë+wäâ€?º2æ…@Ki$ü¨O8àWij7í‘„C†aÞŠYM"¶3êj-Ô~ ¬%àðYªy„šFM«Pâ0;û×QÃ$Œ)&¥É †8¥ Ac݇¥IGŠ73ø®[!ßÖˆ¿Hs»( ‘Hcbžûªeœ2A|rU€ØxÙ5T±»–Æé."8d9ûÕæhQ±P‰q»óèkŸâZ?-þhà­Zw·nÊCtëÆŽâ6¸Ã•àoÅZ¥³’òÕo´[™,îâNå þ•M–ñ2¾”kCÕ䲘.F3Ís£¹¼§8b” ío]–¤Ô5kùÕÍpÌûMůêºt,Öš•ݹa‚b™—?|±õƒûJ!©Y÷ï" ¥_§ÃíŠïi Ìk+·6“§ªkŠÉ}¨]\¹ šVsÔÓÚû˜#ŒW#œõîƒoûÏŽBצñ.°jÚØ\ÑöH¼Zoªê6ƒ×÷0óŸÝÊËÏéN¡ÖË:½ñaØýCqþµŠç±ºx¿â>È Üy(œ}M¯ClÖÑë7é1vn)cÜã=ëÈuB×i{p— ÁHC÷¡ár@µ6åvB‹ñKšÀ ÑöVÒJñõífE(ú­ë&s´ÎÄz%¥u&¿cŽÓZÔ`Œœ•ŽåÔö€*ûÑ;hñibëáeaÄ]Q úתò@êM[±õ’Í@›ªº†gß.¹¨»2×.O÷¨“ ¹¨åiíÓÇ_û!.(»uŸT1Œ·Qj¤ÄsnßÊqŽ9ãŠáú³©fÝ¿^ÔŸyËnºs“ÛžhbÇêkÉì(]CGÙ@J”uÝ\nT¼Ž[÷ÍÏúÔ¨ú›¨sR1¯eú§ÀÿZ%Î{ uÈEÚ´³gGÙXq¸rQ:«^Pu›ñö¸où¨M­ê®rÚ•Ù'Þfÿš†G©¯1F4ÑU²ón¥þØÔÿþáuÿî·üײkz´Äu+· `n™Žõ¨x¯1Uü´C£ìF|³¹˜>ØRSÔ65íÃ.sƒ!Ås¡{aÜèóŒýéœRÛB`ŒpÑöD^çq²’O2«+¨ €ÔÝ.Ëë/R#ù{šÒcéRÂ9D@ƒÇ‘6¡‘|Eäks¸ )Å>m%U É€{fu”– bnG½D}]vKd‚ µ[eÞ˜„I¸Ì„7éð¹'úC€T³>3Û#4Ä®¥Ûam™;sí^ dÄ}¸£ÉED©2^ …P=€®úâHÄM!(BúTjU6…a¡;ã0œJžF#o5ì×2Ü6erÇÜÓ#½vÁÏéR‚º ZXþµî+´QëWj×! æ–ÞjtÍ,ecÚO]Á`%”,’$CØÐ€¥„8qR„’½ºÛ”S¸ S H-¸çËŠ§MiÄíᯫ¯-Bçbé^òÑ…×Fº¸ ±sùŸ]I`ör|¸ÿ)ïEnµÈ>ˆAâÍ6“v8籡÷ºä—âÐ"ã“ÜŸÖ”×Jã‘…òÝkjþ#•Óòþb¦…Mr¯pdXÀçŠ`’Mt¼µ±>Ôæ° ”!µ•*V⌈#ç¸Ú1JçTšä(dŒí„¹M=¼2ÎÁ[8Ûƒšr+h¡ËL¥ˆì‡ÑwJ‹°¢ýDËÅòƒÜ‚kˆá’f8ô$š)%Ä´Iù²@ñQ®.¡y™àˆªz9«=»Õtü$»_ˆÚtÎÈ©‡VgàTŠ&´5[f‚´ÿöƒ¨t–Q†{f,}üÕ[ÿhLFÇo¥lõVGoš@j÷^CHÃûåf“âNZÛ[üµjÑ51a0¶qºÞN{P« Nôüí_êç©iá=Õ‡SÓŒ24‘.bqh‰‘³Ûš9¢õ Kû>øþí†Ï¡§5] Ë§(yWœŸNí3éÜt[Zðð»Ð5–¶”#>ä<ÔïRôؼ´ln]Ò««†Þ´Q:†ãO²0ÛÈVIv¤ó·=ÍS$0»Ìb¶Å$·Ó,XM*$¤~Ryþ•U¹—Ç™œ0 ŸCV][¥'ŸI:¯ïÏyyË}êŒÅ­¤Ïoq]Ý.©îoœæú²½•éSqKêÃ"ºWlRγ‡Å¸QŠ‘¨®Ô¼/ŽÔÝûn”Öi¾“‚‹–Ym¸ûPØW2 - Û!\ƒ,k…‹ÔÔƒ$šfY=1Æ‚‰©Q\Åö➂ݥlúzÓó2»V•JÔyvŠŽrO4áÉ95æ)­e!´ÞÚXö®ñHŠ"\b¼Å9ŠX *Ó{sDômNp¨¤&yjëMÒÚíðÄC¹5i³½‚ÑÖÞÜéšçêõB!MÉOŠ"óì§‹4{ 7ã“U EËÌsWJ#û?Å'í¡ÛÞ¹²ð`»ÉŽ7Qé!¦eÔä‘  zT’sžõ\AÜ i¬£·:ÀŽŠÝDO¥÷¦,9ÎiºDQ5¼"¡ÛÜוèô6ÒLû#BÌ}¨‰ZdsÍz±Å´ÐCZµÅÄ›UG ½Í;okhr‰;Œœ |ÒLíèˆy4…G§ø”…çµ6öÒ¬k r›ILŒÒ¼´šS4‘˜. D“;Gj€Ñ:±E*p7†÷òRI]=ëÀP¨3ß5æv™²{zW³ÈX€ØSA kZQI¼žÕÎ*TV²NÛc]ÍíDtÝ ï7¼‡dQÎO ø÷¨éÑeG87”aÆpk£ €d¡Çډܛh^†W$pÅ×W‘j0ÂÒ·YÎÉÆ}êo$Xw°¿9úU‹¢bDêh|oÊb÷ÿ) ¨‹#`sÀ?z=ÒK7XÚ ck)Œ §&´iíÒ´ë>µåºw–š ;ñî{ë½.'¦X +ÿÌ£wb}j½bÝæ=êÝ×Ñ…Õ¡˜æ‹ ýj¯o‘·°òׯҒÝ;c=/ó)ZIݨ…³?’Öðnó¿š¼¼JW—Wd|P¼–95º¯%=Î¥îã»9æ¯'«­õ³i·ï?ÂséñT0(î›·¶2ö'µ®KkÐÆò×XV]GH{VbTö"ªú„2",¸Ï†Ù?j¹ôþ±¡Ñ_{$”Ö·£´ªŒ¡ìkÈÍà~Çý@ñ„×Nu´Zm¹…Ñ:í9ª‡VX[Þß}N“"\–‰pâ½¼ÑBJZ6d'ÐQ^Ÿ´úK+IŒ÷Ϩ£ó\ÑmÇtõ`ª|1´kµ”‚= 8­C¨:VÛV±úÝ1T\¨Ë¢ÿfòÁ$4R©WS‚¥z}­“Æ6ò:,R0´åÓ°°1Æ* ÑÝ)5>Û)n~Ô>_3šc²õº´2 'r›bɨ–IæœÔgòí¨!ÓKè+˜ i\{W‰‘Å ¶ñvæ¬E7+%¼{W½r]²iÙ»M7Nc+(I\cŠóæ)bŽ”\b¼Û]â½€«Mí¢šf’×MâH6Ä;“ëNéZIºo\¬CŸ½¾½XÓéà ãŠçêµ[= å>(÷dðš¾¼HSéíðqÅFÓ š{•+žõí­“ÜÉ’8õ4fÕ’ Ö(†Hö®`i “ÊÓu€‰j³<:XÏ8ª¥œf[¬ã#<Õ¶óAÕõ$SàøQ<¾QR¬ô=H@g™ï.1ʧ•û×]~›LNçg°ÊÝN¶¨ú°’âá`‰YÏ`dÑ¡µdº¾d±ˆr<_ÌßaW {›XÏom °ôe_1ýhV³x÷øˆò>Œ{Ö9ÿ‰ž[åé™^çû-‘x·nÔ=¿º“u…j4fîU?aB/ú†y‡†·c²F6A§’Yk>)¸ì§™‚ƤŸ|W î’crº×f8ôºQlWyK3n'õ¯c·šá‚¬GïV½+¢¯o ´‘§ÔŠ®Í¦ôu¨ ÝÝØ6OÍ6Ý+ƒ#V-GŠtb§tµÍà 6•rOaV‹-?L³²ižu¸ðUyûÖ]©u^¯ªnI.š8OþT^Uǵ]m!6=-k>g]ÍúÖýO…¿O’Wg°\Ïæ¼÷m&Âvçª&ñŒVQGvÈoëJ„[B%¸riVFÆÚáG¸4ÐYʆ¿a]×)þý…u]%ÉJ½«¸Ó{QRvw”€ªOÚÚ%¥ª¬RÛÈ׫`a½?JfÒþÚÒß, ä±ÉfôûT)%iKÜ4¯â±Èæëv ·àà%uy,϶RJ©á}©™¦Y‚m‰cÚ1åþ/½rW –νI†Üx$äì}h°€nx€t8 þ´íáŠFGqcË=i墷Ù2¢¦ìî=ÇÅsĘKáŒ&cCvmšºÓ7³4ÿ7Ê=ÇÚ¦O£=«,s2ø®7¸yF}kÝôÖ°4PMkCE©z×µèh—˜¯q^à×@SŠ¥k3O}4›”!}*n›cõM”1’å,?µŸcÀ°J¨;ØÛéÅ%òí4îÍ :}ˆ’UiÁüzÕ’ÚKH‡ªª·²KPßR´¶‰¡‚Û—Éì}qB¾¾r¸ G9Ò\&J7#%Úk†V}°1ܱãÕP ¬\B±sÂŽ@¡Ís4Ìy_aJ{Éf Í&Hãš±[Etòx<€2FEFH䘒 ±ÿj#oa Ô'ÕÂ$'=Ã&‰ÛÙÃh«äYOª‚FGÏÞ¬ÈÇ*‹ÇNPX4ï¸DÀ$—8{|Ó°[ÚØÿ½ŸGžæË{'…†>}¹4ö~뵃,9ˆÅPxuåP;¯*SIg o´¤Ûæ ØÜS£–ÁŽ á‚KÓWšH²;¥d]´?¥Gžûév¬ùqü9?ïUAßPíáÊ5™2HT– Ü×vúr˜KÈë¸ð©êk‘xщE"UÇ#·9Ȧcº’ m+ØÓýUI„:—PZ°¹ð˜ì.ظ«KøvýWAÃ.É;¤U^Id‘Ë»–brIïFº<úšvU\’Ç”øw‰áÏê³kX]§xö(–±¤=•ðµ7†å#Î ÈÙñBïnR$ð£ãíVÝf%›M¾¼„»06¸æ³ÇbÌY{m Æ¡¾aî4Ù v–¢Ä¿ üW„–9=ë´BÌwúw×-ïýÖÖ¸´Í…½¹Iw4qD?™¹?¥—U¶˜%­„ŠÙà*ŽOé\Í^µ±úrŸ{²xJþñ<0{T;+ o&\)95cÒz*îè E…¿|Éù›ì(÷ÖiAl`N½¥““ú òÚ¯ÓiÉîw`ºš}ÚŒDÜwè Úô•ÏÓ+NëeoüNãÌGÀ©1Í£ôþF™ šãÖy|Íú {®\ÝÎÍs#°=úÐiži]š5qÏojóºŸÕê­·µ½‡êWwOáZx=SÇðû#š†½q;ïy[ù¨Ú‹% 'ÔŠê6îñ€ÚÌMµé)"[ÖHbþi ç¶6…µúèÙé`BìîMìjŽÍå?” 1›q|B¤LF08©~7KèèY®ÖåÇðB3þµ]Ö. 5VÒ.ß»üßÖºZO žwz[C¹\}_ˆ¹ãÔiZ é+8‰¨ÜE9;ˆÏô¨º—Uhº,f.Ü\Î?ód\(ý*‘¢j—woį#0',rj6¢6ÎÙ®¸ðVC \×j|Á|£uN©¨Í™nWÑí›×TÜháÉÉ^ŠîneAš5%Ê]é,ˆÁý¶ó]˜¢”Xœ÷8äªægõº½´Èi~Õ¥k®±•†!åEƒt6’`yõˆ°MÕ2öS=áÉàšãxäáò¶!ÑmÑ2š^Òm¼i—#œÒ¢ÚzÇgl÷vQ‘šUËlnp·8±ÿ ~º®cÿ ~»­a^E¬¬å…–BÑÆHÈ2v¨VVë<Û]¶.2[¨ˆ`Ð=ºùòr§ÔRžz©Ñ4¡š9n[Â;xÚHŸaLeU|C’{‘M6QŠŸC^`ž;çÒ®•†£¶ðÍ},á ?ó¹©ÖZ5äÑ´R¸ä Ç÷ïUÔk؈1Ï„þ•*ÇX¿Šò1Ã=ǬÏd”vRcË M «L#µKº¶ÑÉ-ØUw^ðmî"‚, ݂޴+}Râm„ƒoë,ץݩ„[9=ë&òÉ!è³ižd·<ätNÞ]´¨‹â+mÔb ““ÏzðŽÕèæºm ZM^~ÖÒ[·+óE­úfyq¹ÀûP òÇÌNTüSñjºŒ8óî/ÿj¬«ŸCø€1VqýiýOB·Ñ¬™Œ`ÉŽ>*OCõ Ù ²(*O ó^uåð— Ø÷Ås ÓyÞ[ÊÙ¥œ[‰.®dØ¥¼Äà{TÃm(FPï>•/E‚{xŒ±7€ òŸQñJmV mÉj»ßø$Ö÷Hnšsˆ4›M0 u(Aü¹ÅÓúzÆæAR!9ýMQd¸½ºrÌäíS´íBÿN™d ]óIš9œÜ:Š…®#%_¯:+Æ2>j™ªC.Ÿv"™äxÿ(ÜyªtßS‹û!o ÞXpO¥SzÞÊMÌÍ{⹚MDÂo*d êy¾“<ú{^¦ß 6ÜnóÒ¢xl. ‹¿òO½L·–â{U\EkwgäT[Qmwi “ûÂ3ººÎ²CŠ—o¥¾I¹›Â~U8£Ún§Îè©"oJ«ÚZ]^Aõ3ÏùŽÐœ‚>jq„é(—ú•€Ë!¤Kæ; vUU¯Pè˜â€¾ÁÛ‚=ê·Üš]ò[Þ°x³ŽWã5{龦‚úËéîX1a€[µLëxã]ÅÍ`ÒÍ)”Ã2/&RwZ÷lžî¯›BãÔ&¨ õnÐuÛ½%Õ£rÑçŒö"ªQ ÷CâŽF0‚£…Žkì`•NqRÔcO×mÅ“®ò2ÑçhÍœÐÈP!zb«:uÝÅ…ÒÜA!VSýjÿa­XkàE!Xo1†5ÊÖø{ ;ãË{vZcø•“•­n´yU\ƒÇ¾kØ.Ïã8isÏ¥$Ý’“FÉ\I.Lœ>yzh†WS‚=«±3¼ÅÛÌ3’ O¹eÚʬªGóRë”VG)Û[Qªî‘¶ö§–ß…µ±‹d©’àéþõÅ³Ç ¬Óê3´/|Z™£?íeç qÀäÒMäôC×Ù[¯1i¡Ùˆö¬’òOU•»àãŠÔz¢cœv¯cYL'ÄžG>¬i>ÚÊ âÔŒüéTšvy%ÎÅ'“S"…a›Ÿ\VÒà…;grš(š7…KrJ¢à’>iKð#;€å˜úÔIn§¸HÅX.x¥’÷{!6xW.‹³Übc€½ëK­6$F”–hÁÎq†5ÏNĶšSËØ…àÖyÕwu¨ˆ¼BÀ±8ÍrD>~¨’xBÆí“x9PoµI¯Û·8zÒµ´ÚÁˆÜ~y©VvE!N-ÇaSç6ÁÕm #n·½ul4mj;Bðv0 1‘ž*vãàx*TEüGn ¨ê€Kn`pOº|“Ï?…'eo$Ð8Žªêˆt‹?Š»r0Üb®SªX8 „S0\1Ï­V:-BD$aØfõ­ÛË)`ŠäË›Y]–,.Ðkûùu&¶¸HŽ8ÍL·I>žyç- øjy žx¨ö6ø¶È@=ÉBCÊŠ l÷À®©¦Š¶°p¥Á30úp†3Ï}ª]–’²7ïˆ*ËG?Öˆ¥Aë‚;ÿÞœ’oÙ~,¤¹2¤ `ŠÀù¯ åv4ÚÚ•çÓÕR´²íp>6±~µÎ³%Ã>$vðs€ž*ÅÓT7nNS2c=Ï~h'S]·íXöãoòã½1¯ÔÂ\šÖ»N!hD¬#"Â&µ,²m*Äã5`´ÑÖÓM7p*x¤ed‘‡—ßþj¿§}uÄQ­µº(QÜŒf¤ÜE¨\BÛî@Y$ÉEü¹¨ö’j×.W8RŠÅ$ %›Ãr|ÍžšgPM6ÒHñt$;2vzÔ(ô–— Hîó`p)É4Ë{yÌW$ÈHá”Õ€ÐyQä’}1?‡|ëLk!ÙžøÏÇY†A9ÉôÖˆ¿E¬Iž3‘Íë6ÀÍŽëiº GUànÐëTK$q¹G>ÀPÝ|}$·’D™]|Ê8&˜Ó¯'Û6°AÜÆžêYtûnK&Áž~k ÀæH(õETQÏÃrðé÷~,Ï#‰†ÖcÈ⯽A¨K¢µ;wá¼þRÿù¬ãðÒÍçÒ/¤U%Vp ÇùjÅÔZéßGóÝ~ïù‹ý8ýh'Ó 'ó+¤ÝAm*•sz4ž2,¨@òº‚?¡©½ÐÚT\Þê—.m’' …–îÙݿ֫ú´‚ÎÂ+Pø®êjõв˥ØGÒPzûŸSJt“À äU–5ãÔŽëq$+û:u™”~Gò“öªŽ©£jmƒ¤öÏ ç+ÅjkK• ‘QSã¿KÓáLHÏ0­ºOâ ^œÔ£xû—éšì‚¾RÕò±cùŸ0ùc5³þ'èz2õ&™gkcDÂÒÌÑœÜÀÞÛOõª¾¹Ñ}®œ—÷#ÉS†é þ"Ò¹þd¶ÒáCù,nÃ…@±Bó“óŠ=9ïÚè†Ew¥Á©ÚÚ¬öÓ‚ë‰ldŽÇíŸÖ˜Ô4KN‘¡¹±ž'ÃFk±áþ#¦|A±¼óJ{ å •ÕÕ¥erŒ„‚A•ìVÍ#y椛ˆ¬ci0£5¿p¢J’+ªõeÊÙ®“+n.‰'ñ*{~´ÍÔ¶6ú>û9_2úŠ©I+Ì^y]Îâj-­Ì©})ÈVÝ´ò pdÒïkpçe¡²Ñ¢Œéúd²É⺜““ñV›Iä³@"‹h—Zf§j©*-½Éû]ÝôýÉŸd1´›—`Îk±:L‚“šAÈR´¾¢k|f?­@ëË7Z³±·ŠÜ-Û˽¤P3°9ýHþ†¦Í¢iý?fo5Û­¼y-¢>w>ÕK¸»k»É/dTÄ;"úŸ½qeÕÄÂL'û-‘i䜆WݾéÛM>$×ÂLò#yýI«/Gj±i::‹DŽ+‰™œ/Ÿà û`­Tn¦:…è„6Ôû µØi Æ­ Ú6ð¬ºßÔê+¾ØÇeÔÒètÚw—‘`wïþÍ^âëË$¥½O5«ÜmUˆ#§ôååä¡R2äüV‡£ôe–œ‹5ûàg`5‚-+œi¡3SâѰS-Ó!½¾1¹Û‡ çïF/´x,:‹M‰€Øo" ~7Šö;±cÖ¤6Ab‰odT«¸â¹ê‡‘]'*º¸|úç5× þ«Êó²käx^Nªê©5¹þ’Ëtt'hUã~=M²;®¨àw4âç(zÝÁfƒœUeÈšëâ8¹'æŠjfO°‘œ“éPF—!Û3m’s–>ÃÔ×=ò5‚œšëv=ßÔ±DäzQFq5ÌJ®÷ ù5j°Ó¬lµÙP€Ñ¡w; ÷ªobñ‚À F01ŠÙ/‰ºm8øz¥ˆ(îqG´n’ÓàµI¯$¿òúQ³wkiËHÕ1ÇiRO=²1£i§vù˜"úäÖIÓ껑FÏ€eD’þævÆZ£ßéךeÐØIð˜òGúÑ_¯Ñì§™ßâ¡u©8Ҝž3~ébÙïÒ–ö²Ý+þ£ù*¿ [FÖR\Ü>#UíïQ-$:†³$ê˜DBíýë›Û†·°KXG™¸Ú=jÍÒº!‰ºçÔŸs\Iõj½= dq¶QåÒ,Û Ugñ[M.0£/вu6·Oéåb#ê¤Uö¬~êyn§y¥bÎÇ$šëøf‚ˆði¥'žT6¥]ì$àdšUèpDÔá¯ØT«dÝ íQ£ÿ ~§Ĉc   ׉qLqÂöT@ü6yäW‘HT°ÆU½)ÉÞÙŒ~ l¾\9fÎãïJ(šI¶ªóAxÊÆWB 9# Q›k È`/0C&Ü j‡…ŠPbè0KóÏÅ;î”Îð%î%¬¡7-…1£ço©>•eè›]Ä>;œñU ¹Nâ<í'ŒÖÒ6þ –þx_J AÛ Dü1 ë›Í±Ê ò*…a}ª,jÉ×%¥hùó>jOÚH\ AO½M7¢ VßKh’B›lkpœ…O†ˆ€ÍÓí§ õ+­ùˆà#¤ÃokŽárï½Nïnk¢ÍÞp*†M”sð—Wm>Úþ´¤ŽØ*f¡«&¯­K©4B+hWd(AÇsúŸôÅR:zícÑ®-b$\Í0Ã*cŸø¢ÓÎo­£²¶B0®ú?eÖ¥5Ë$•ŸŸbsQzºSqªE ¹ËÊZaÓÆ÷ 9 ~k›ÈZ÷F\ý.cg&†ŒëV9M­Àa4a¸Ç#5™hW÷6𢖚­'\lÈ™÷Ÿþ”E…©*>§ÐÝ9­Êp¯k1þ8H\þ«*ëïÃñ ]ÙYèøÍu—ÚÉ‚ª=ÿZ×ÿhC!WóF}Ç ÖqÔ·gWëò¦BëkD¦HÝþâ¶i¦Öé˜Xvö9Tç1æÕWéOM°IÊ,±7¬}ÇéAtm2{«ÅR¢=íÒ°E|ž+zÕ¯¬,´%†t ØÏµ«¬²Ñâ0ËæF’e\C‚kfŸøŠj•£ÓÇ@ÐŽR,ôþ”ÑcÝ«k©u0X¶ñöÜ2)ÛßĦ‚ÐÙtöš¶ñד÷ƹ©V„ApÉ6™h3†gaúƒýh—ÿÁˆá9¼Ôæ¹þTb5ýFIÿZåë¼Yú£ýg’;?Ô­Zv1‡=ÿÙdº†£$÷-ur×7ÕŽ@û{T’êõ€ ʇⴻÏôӦ/9AïÉ¥§ôô>01qJaÜÖ­ÿ̵€Ê£¢ôä³H¾F÷íÉ­c§z5ÄK5ãx0œ·«/Mè¶ÀI(Ë*ç§n¥’òäî8xU€­ú}¥6óK™¨ñ Ãx]ÛÍoeŠÆ‹ÛÄnXÔ{›·’2‡ žæ¹fðÎŽ+ݦE,@®ÔpÇô…Ê|®+¼ˆÁ×:œyÙ›üû0 þõßS0 b—S—‹ñÿn1‘ÿí¨ÿjo¨a•­7· æ‚@ n¾è§…nÕú í:’u‡?Jͽ †§I¤XÛB«)ÜGqWÛh¦×ú>ÊXåWºð÷6TVcÕW—-¥Ã\ÆRUò¢‘Ýj¦Ï,íØMm[#s7ª­Ôº…«êKm …¶´ó>?‰ý¿J ¦™5ö¹œ(ø¨"õ ”³BL’¶ù[ãÔÕûK´Ó4ka%Ô©8QOÓé½NÊ·LïöªŽ­Á¯2( ˜ÔñPuˆ¶Ò8ô$TŽ«Öâº×Löiµ|0 ûâ«W·Ïæ‘É­¬Ó»ÊqE(œ‹+E¶ê‹ >ÅVÙƒO{{3·éóV~­êÀYÙ€²Íû¸•„zŸÐU,ÚY¡Ò­ï™\s´z×ÕkeñÝSGõ]ÆØ”÷OéRjÚ‘¹t&4;cçÔÖ–Ëo£Ye±âmájdt‹DKK7šlmEQÀûš™mÓRIpnu‹ åÆ|ÏoŒÐ‡iôíÝ+€‰@Cäv•ë³ÝjÚÌŒCÈå°ª£4oEü5Ô/BO©8²·npyr>ÞŸ­jÖúu•‚·ÐÚà =Ü.Xþµì‡vw·Í#SüNâß/FÊ÷?Ùh@/tÎúJéAÜÖ–¢yHÁ–ã Ãì; TýüŠ2 OUÈ1ku'Ì‘æÊÒ%ÓÇékBùò3„O°¢K|T#Œœc;hdá¯ØSãòãýk´à á¸Êè1ßÛ4NÏ y ðG½D¶Y#ÅÀ¬mëR¬î£Ie, çÛ·ñ…\•!…IØ'Ær}©Ö»6QϘ“´w¤%ê$»)†áWoošxÚY\*x¤ƒ'æ`rGéYË¿än¾B­ 3ݨÀó7aZ¶”>“Fwöã³»k¶! ½Tä7¸­"í¾—@wL|RuÏZÑÕ\™–u<Þ6¦¾ 4öš TÝ´PËù<}^Cè(Ƙ¨°É)å—€=¾k]mˆgLRDoq—Ç8¨¾G(, /ô4à/,‡Ì=«©£TòÌÌ<ñÚ” a¶}*mšòÚi >d@p¬}Í{bhk·7)|*¯ À¨6š“[[ó;a2BžGÅéw•üfRK1vþõ—PKçŽV ¦úºaE Ç ÂÜÚ£É$HP§>‡Þ¦õ•ËÇ6ð@`ÀúÐÅÔn®íׯ¶jô¬pˆ)nk@D.µ{†‰aŽFXÕvð{ŠÌ[$óNÇÍ’;Ô¦°e„‡ŽIÏ¥iY…¨Õd;õd~Qýè¶‹¢%Ôçb‘¸žÜW:di6»rc_(“bý‡íI–`êèº@/Ùê c³Ó"†G`ì¤U¾‚ÞHÌÒn. !F}OsE:Æa%YòBûö¨;óiîÎí º(ÆóæmA»¹B P¤zdú€-íVVR|¸ò¯ÜÓ—*c²cwpKœŸ Æ}*rÜAi2«;n9b>ÿR’HÖ#ÂŽÀSDeÎÂ3Á²{é¦ c=¸¨ÚTm>¨Ç“· )è#‘Éœ¨Ø¼’hIÛ™]®O%ÏÇ­:GˆãqZc­À(]Y3F‚,à€çNôôvÉãÜ‘!íŠÕS‡ÕÕ¤$żQ܌ՇLÕ­ÚÕù=|R‘°47¯+Ñh†™Ï.–¬pž¸±³šUÛìÙ88¨š‚þÎP2Há¿’Ž,ñÊD©žÙõ¡ZåË}+¬¨ríØ¥Ä÷†•¯Q¥‰°¹ø³Ö 59VQ l¸µuw®=â2 àm ëŠ)Ž;S,}…umæ—’{©qÜ»€žá¿õýªóu*¿Oœ)Û4mžÌ*û4š(ô¬ºÖ´û¦C\M¬é›f¡2ŽÙíJñ$¸µ Ë;€)]f-YþyæŽh¶©ëû |4åF;×E¤zOÉg"” Ý&m:ÚÊ hÙîeÂŽI«—JtìkÔè±nÿHÚ¬Zë3j¤ÓÄIÛåFöa]Véa $n;ŒÖÇj§ òã`ù•¢(b#sÜUÊã§àŽQ$7ЯÀ¢V7 a‚oÕ±ÜYìw“È¿¿­8f˜!ó’+0n°ŠÝø'iÇu¢\êz}ÌÂQ#,£ø‡­ ꦊ ìÃq*L°²«#wb08ûš¦Ç$Îp &†ëR?…LHñ$øæ˜ØõuN~°@é 7ñSú~÷è¬ËIÂ÷Î*.ŸÜŽ8ý«CÕº¿C°o x‰aÝ£9¬Õ5=.N²¾’f¶–Pê\s’ ŸõÍHõ‘Ë’ÉáóD29SºçP/ §h\dš»ô†· Òmƒ’U`@9öQTþ°°·šÔËïF@@Ï®(ïGÛIq ÚÈŠpc··íZòÒ è±–ÊÎV‡m­FTo\æ‰Ç©Ã'ÈôªdVS¬À3mö5*bc9BTvàÒΖ';kB½îÊ?kÊ3¢†ÏµWΛ.ˆO$T˜¯ä@Ü{s]µßˆžaÍ1šg3„·Ih®•áªü@AÚ¢^iÓDÅãlÔ¾ŠÌòÕFY› 'è–5uut#‚¥=¥ì).ð°“Å;”×qJIÙÎM•£2oq\Æ-äpØÃSüÜd ¬k¯­ãƒ®ò½ä·ÛääìBׯs`‘ÙÞ~&Ø,}ee*– 5°>¸cÿ4 ©tÉ-´È&_0dæ©®cØAM²Õ´~^ÓÖ+ÆÑmÿê+?üN×à×z„Ù€¦ÓL;qæ”÷øí÷Í{ õch¿‡q̸ú“†ê\çÓý*«ÓúA×µØl%f1!ñ®ßÕ¹Î3îOûÖg³ÔœÇP$©V¿‡R4˜µk /ëFý¨À±c&ÝFÒæ&ÿó×Ó:{MmnˆŽv ì*\òÅ:m¹¶Že?Ì Û§ñI4£nÐáö*ïxæ—ÆÚ’¸LŒyj,ªY@“ñ[Çâ¶£C{¢Ëk§ÁJÒ¬›W†n8ýMÕtK(tHæ¶·Š'ÚrQ&£üy€>ã6ï’cb&²¹ü<踢°·Õµþ¡¤]ñA· Bjë¨5ÄVÒ\]*ÛZD 9ìì*áÎ.:.ÁÎ EhøÊĵTúû^V¾:M¤l­Nn¤‰v_°þÿjó^¯Y/õ>øÒÑBßG*—u¨›‹¹oÚ6ie;-£öŸ­hýÒçL´Ü@}/žW6ßej­ôf„uU5 •ÄkŸ¦Lyqêßñ[µ¢øAGniƒ¨y a¡Ö¿$-š&Ûˆ²†wb®§#ÛŠñ­Èb®p>Ež8¢M¬NáèMAhno¬+±@Áf Ã[ñ<ªv¹Ç CåhíÜ£LžÁ‡ Ëosw"É ,pFíïSîb²Ó²ò8¹ŸÐ¹ò¯ØUkSÖ'“rï!}”Õ?Q 'lÏ~‹Ti&¤4Û««M8–D³þ#ÿ°¥T™®d‘˜1cŸSJ³¹’Èw<›[ƒ´ñú@Y<#*ƒ>‚‰\E 6ª‚Mòg#€42/ÈŸaRœeWöäסw+Íœ†Cà:x›A íÇzQ ç—ãŠà®Ð¤s^Žø¡P/Äq™Î¥Ó^K¼ÛÄ‹½ˆóÎ~(;ʆ!iÜ“ß4þŸ#%Ê÷äã½%í¶©·ŽÛ[˜º€C!ËD¡^OûÕ«ªI‡MDøj±§+C®È³rà©$ý…hzžˆuMY]L›{ äj¥ ‘›¸KîÚV™{ɘÿ1¢¶%LÁ¶†õ§5-ëN¾,„çJŠ–ó“å‰ÉûWh9¯m‚œB+/‹ñ á›Ò¹šVº&BTEí^,÷V–ÍâG¶6À`Oqö©?³ÒxD¶ó/¾Æ4›”;€å `ß“ÜZM@ ÓOd¬í-%ŽúÞ9P®ã¸dwõ¥ÆßMÓ̓‚ßÚ°ø‹ý£ª²E,Ó«çñoBœµ7gðÔcŸcQuB÷ZÎ-j7c§ÌÅi8ÏÍlm2 Þý1o¨Œ¸?Â*\–w9k #”®*OÒÁkt›ÙËó·ø‹{ • ^Il±Î±A$ƒ!Üî~}«¤ÎàI&Â(Mêþ)P±á@«Îµ.D¼ ’Ù4ÇQBl¡t€«°ûüQž„ÛéŒGp”­C¿íÉQJÂÀZîUk©åú‹õˆC?›>Þ´jÖÐ €•ìù‡½Tº’bú¢"ã;½(íË%¸‰ç2¾3Ááx¦ˆˆ‰´®1åÕ©·òÅgh°ÇqâO •{(ûÐ[«ya*d^}ê|6]—ºðÏ„ ÞÔFâÖÖáTÅ$ÒÀ‹€¾ ÿïV×cîÓr«S¼íc&Ðv*àã·ÜUò>—UybQî\VgÒ×·h:”1JèŒÁˆSŽqP ÄÍù¥s÷c^³Aᮞ ýÔ³9ío6µñ¢éÐñ&£j¤œT¥Ð,^(½‡ÃþlñXÌA¤<’Z±èºûiÎ-å%íÛ‚=«l¾XÛk³òBÇ?¤Å¡iÅã Õe÷Aš¦ucéi©ØEÃ2€Í&W9½¶¿}4‹˜?{i/,†«]]7úôÃÉl0?̲?µqÞÂÓµÇ å­«L¾¾Ñ“MAŽÏƒÁS:H°»µSE,$¬ÁŸµW,ô[Sÿ ghË9à(÷4O§:°tC]X´o,R¶eä©õãÚ§‰ô„d¸Öçü+ÓÄf&›Žù¥©]ØèZU šâ&2c>=¾õK׺ÈÉ·±QQU]O«Ž§) $¬ þCMÃ~¶‘Ξd g36~ýy’ÙµÝ'—\>zrîê}ž}¯L),{æ¥ê½97Kê¶2ÜGˆîS×ù‡§úŠÒmfÓ´ÄÛc÷xØ}¨'WC.¿£¼;¿ñŸ>Œ=>Äq]ˆ4 ôŠ\é¦|¦ÞS7Öë«ha„@ì\p{S?‡âiÒÜèwR”!üKpݘãî?¯ÅT4^¢žÐ=¬ùR¤«¡÷¨úº™¥K»I%C¹YN šÙÿNóY¸e-Òµo}iœ²þ¾ôɸÓd92oó+±ü@¹‰:¼ŽTcŇ?pqDÛ­´¯w‰pÌ€Dsþ¼­Fèá¾’œæŸö­Gé’WÝÉ"ÿ”Ô=Zî×E´k«Ù|û ÝÉöÔÖOuו+§Û˜üÙÛ‘ÿéóU»Þ£’k¡s{{-õÈáw¶à¿zUžôÝcä–caéJÃÕ]A¬[ÊÈm`xXÿŠO–ÿŠÓt‰¤M"Ù‰Áð×ôàV5¥õKE¨%ÕíŠ]ªãdLØUùù5¦é?ˆÝ=t¡.íæ³N¯úS¥¶ç0”€8Ò²;–1î>½Á®á1µÌz–‘w6ú•±ÝÙLMvú|¡w&ÆÙóþÔ¯5ƒãóJvã¢Ï?&f×4‰ ÊønqMëøÞžˆDK\Š“ø‘dbý“#¸Èëœz`SVŠm´7‘Ðàð8¨ÁɲáÍRšösgkªV;4)ã–ry?>•¦tf•6‘`¬è¦æÞLHäÙsð?Þ©½?¤K®ëmrÃÿ jÜFOéßúV³ij`³ à (˜ÖüESÉøB!o©: ¬2KMI$\H}Šš-¥c¸°®¾šA"VÎiO‰ŽV׸*¯âˆ-m¤\R;–MþÛ—8ÿüÒ†]<·8SÄÝÅüQ‚XºrÌão“ÿèqþõçIí:s›­¦2˜ZFÆæÓ÷Uí«¦Ò:94»˨Ë$ˆÿ†¥‰Ýþ¼|ý¨v‹¤þÛÔ–Á ý'}Ô˜åÏòçÜÓúª_kâÃI…~¦å¶ïf õb}­[§tM#§ôèíẊC.û.Þ¤Ör#4yާiV±ìEDPT à Ÿ{s •¹b@r8æƒ]õ++5½ŒÌN·aCÖ)%”Üêolp¾‚˜È˜ç`!ppÇTfà™ÀeoÊ;Q5MVh£(bvÀ8 ·ÚÓ.R*«w:œìÇ2ðOzÁ¨†IÎ8Z {"˹OjwæRr1úÕzRâMÙ-S7¼§ÏÚ¥Ziï,À ܸ ‹DØÆSäÖ9Ø ¾6Î~iUÆ-.(ùŠEŽXð)SÚÆÂÌLŽ6ÍñŸ"ý…K‚b»¹ÆWooJ‡ä_°§àÓÈ´$Zx®Šv<’zrÄÆÓ,R¸HØù›ÅHžÚ;yöÆáÔàƒî)eÙ¥mø©;˜¸UŠÞ#rIíŠ~ëIžÆ5•™Hø«±SаzcÒŸ’®!(üŒwö®kµNö^žÇDsêè€Ä÷?Nº¤Cqˆør Ã?NÛ®Þ(¶<›HcA§´6’2;•Èù9-ôï£ów>møíñDøã~\-y©âtN§r7½cÞg çßnh-ÇSÈùðùÆ(ȸ³’¦6°´C€Jù¿­6šN˜Ìå™âáF;ý鑈ÙËRƒˆä*ijß^·ïd!O £ZeÒ@ª’ƒ‘ü]è«tÊJµ¸G%wmÏjhtÅÜr •£E`NwLt±¸U¡óº–k‹ÝR9-Õ®|8ü¹`Û“^¶©©OâÇà¶ÈÇœ3¨ ?SOCÓSÌÍ*ø þen¥K‡¥¢!Úâä*dã°>¦²¼Äy<%;k°ª¶Nºƒ°\÷ŸëV¸,/¯ÐM†‚7súQ;œµ±°È’\ºî‰™x⹞h¡WŽêíÀ¨läúâ…ÓŸB'<ƒ\'líŒLÈ\ðga’¿=ª>¯,:Lb1pe¹+œãïPnº‘–¶±]‘1üØóZ#<ŒY·Ÿ½FBâmÈš ö^]M,®“8gUmÇš’:žæ(ð±ºÆ`8ÅwklÌ×ÈÊP˜ÕF?ñSÙî %He =; S^h8+s¬å±‡öƬÌÊ#Ê­ëö«Ú,Ú|ñ [yÚUH÷¨¯§µ¬Ñì£u1 1LzÁ ¯)cɦ+÷Ðn–=›-5ÙµÜuÐ’2­(lúsÔ‰# “붆›xóÚ½"öqébá Þcˆ¥ëêW×'ìSè*Û¤j¶ñhë§ÏKÅóÎ@Àj©‚jèJTä9"kÅ%=¡Ü«`šÒÚ9û¸òÉÿµ@Åst-­¥4œ‚< nh “’Nk¨æ1¸aÜPˆHÈ*ƒ+ª™u]‘pŒœŠr÷©L¶_KõÇ`¢›¸¼7ƒ'†Æ[&‡… e"ˆ08 ã…tKh¨±ÆÌæI ,O$×7¿ü1ûŠšîXùª%û³Z•'€F)ã•}.šÿîÛññþÕ FæÅLé>ÿíþÔÌHjöþêÓ5ee;¸B˜Í=g‘·¿å¦ ˆÜK“ùEIšq ìJÝeÅ ²i½A™úK<þZ-yÓ—öÃS°xÖAt26û¨ª¿LtôAxí,ž œ#tÓc°ö4\ê$ŠÔiZy+kíSžõæ?ˆ5QÀqfCÈì;•ÕðÝ#õ.Î:þй}ÕW±fÛÃ0(ઌdþèJ\\_ÈÄò’}4wKÑäÖ§ b,IàŠÑt½'FéÑ7I»q•Vþó^Y2:êܺrLtãˈã÷ʤØtÖ¥ºÜNÙGï) Çì£þÕdѺZÂôî¼ynŸÑ$;Súÿ­HÕ ¹34ÌÛöö¢Xê¯i(~kµ¦ÓG²îÊäJ÷n²­—:®•¤®ËÀcob(wýkÓm&ÆœW·pé½Gká]ù°8e8e¬ã]é Ý.G’ÝâÓÑÔdó]$p?ÒòAI|„f•ƒ«¿é­A~ºÆç¼–QÃÿó÷ª/íùm²ìzŽÕÒ£sÇ¥At ØÅkþA€ú\RŒ—Ñ;/R4‡"Ý3.­s);F>ÂŒÙtÞ£zGƒa3Øì U‚ÓðâêE^\Cj¿Êyj"Š,Ë šç; ?-s9ó;sóE´ýiyŽ $oò®MhvÝ?Ó:2†™òaë!ÂÿADT[Û/‡ek ;lZÊïŸè´¼÷éûú&4‡/4©ö®Ü¨u²1!þ)HZ²é߇±D¡õJ5>©&œ—©/'÷‡mB7“ÌùÞÔÍkeø¨[ y$£ÿôÿMYctMpÞîÕ:fð¬#§ùMV »c’k¨Y%Àô :9eÖŸÉó-gÀÚMõާªjH¡^xàf|ï·­Vgê rXØÀv‘€ Uæ=*y¤Ûá±ý*Zt¬Q-ÛG Irý?L߈¥ÿ1#ÎÑZôÚ~¡ÓmÝ’Ç!™rjïmÔ‘Í(§=ƒf©ç_é=##êŒÎ¿ÃÎh%ÿâˆ@Ë¥éèž‚IOô£þA²b6¹ Æï÷PZ»k~i^Ö(a^KJõ\½üZÑ,ÉDOÁÇî×ëX¶¥Ô:ž­!{»¹?Âô¡™5®/Ž®E~kGÖ±Õ=Q'Yh¦ßNtvYQ¾Aùø&¨7š¾»h¾눀ÚüTÎéMgQš+˜‘ímÏ"áü£õ¤ :ÂÝV_üdê9–P;ý«‰âMÓhŸép'·+~›tœ ÷Y^ƒÓZæ¯v.¤i-ánWm¹ÜÖ£§XYé0ÒFvõg<šƒq|ÛÈÜôµF[¢Îw’ùý«ŠíL³à ¯ ˆseXÿhA|2àTiuÆ+P-Å\í9'Ðw4BÏI’èïœ4iò0Mi.lm¹ çSžïH]!{Ù6¼ú“Š”45îå\û#qSít…OðÓjÿ9ïFÒ {ûü]Ífv¨»ý<ÆÁÿ.P(zyŸiTŠ—-Õ¦”¡biýBÓ’ë\ùmFÈóƒÇ&„j÷Ö: ±º½l±åPI¢ˆ™Êa‹nz¨º·‡­ÂÍ{pöРìÜ(¥YwSõeƵ1÷6ãòƧ¿Þ•u›áö,¸e<ÊÁUHÿÃ_°®Å6Ÿá¯ØWb±¤)–p›™„jʬyË ¸ñlÞ|ñíC•°sRãòí™åNIö>”· ºiÎíjÁ€Ì|sR Uö–ŠJ¯Ù_ܼ­0 ùuÏæý(¥®¡ r¬|&õ k“,$8š^³Ãõñ¾&Æ]N »2µÒ¯¦Þô>ÓcÎäG½?¬]Ã<£ÃÊO>¦„äžFkd,þ˜ …âλ’Ø<‹œü…;æ-NF’UÜ{ŒP}Äô1=©¾Xª+Ÿ· ß§ê6y‘‘Š[=¾*BÉm·™n÷Iuoz¥#Ö3» ôój1Å"›‡UWªàzU"9<ÜÑ [›DŽV¸G‘ñäÁÆ ´áPnÇnÅßP¸wXÂòžø S]Ë;ìIù¨¥ËZp!@¥‡šÈšÁ„ç»s‹%I€aɶqE×džÏb:xYåÔPØ.¶Û|šž'ÄqpÂ;}¹Øƒ’}¨i&ת×wq™ä‡„ y9ôCèîä…VG‰[oe#*½U¤Ôœf4È9 }*BkRAl `øªtOè¡aè´=+éM¢ ÙZl‘ÁÉ8 úÞ¯¼n».Ö#Ã\Ÿ©f ,¢Æ=è,÷rLÅËsÉ¥G¤;·9 PíÅ;-Û™ÃO±¨Ï!4Ùc\–­á -vº-\–®s^fŠ”]f¼ÍsšY«Q{šY®sK5^æ–kœÒÍZŠE«¢Ü£H›ÐW8Í¿±˜Cû#¯•cîÍÊ8aÜQXu¹®IþaíJxuÛUysFÃ;¸Ç¡¨W¿ü9ûг]ÚEs KlU€Ø“‚8ä}½ª¹¨múRæŠ7îP8O¥ë[Å÷íLI–”F=êWG&øo®ßö¦ d#ú^ÏÃôŸf[h0?1§´-ï^¿ÅTƒ,˜á¡Å úüvÐ)i$`ªhSIkѺi¶òx·2ó<ª}}‡Å_Šx›tXËÏõú'èôÕJÞ:žÊ6»¬Zé.•¥Æ#·A† òçÜÐ7K›P¿P«¹\×6¬Þ…!‹ßÞ®·÷–}£**+j2¯îÔ÷O“^ 6K©›þOw+Òê%M•D]3£ Ž)¤_­œy@þîj¯­G;Ìn̆@çplç5H¼¿¸¿¹{‹™žIX䳚;¢uðÖÆô–ˆð¬†½Œtñ‡4Ûº¯:í@s©X4ž¡ýÈ´½$ÇØ?ªÓ÷vžQ:2¼g³- ºÓ$Y‰wåvŽõjéÝ&h­õ,ÇnÄnæ±j„Q4Ët˜ËqÛÊ®G{5œ™q#¸kÑ/¯5‘ F‡»H0¦œhöRo21æ¢^j“?äl)öâ¹ñBì1™îV¡£.4úž‰Ó²Ü .œþuˆí™]7§-­ŒlþòÆ„<í(;ÀÅ60WJdRk%ÞkÙƒNÎ÷F¥ê _É ì´>{¹$l±b§ØÓVÖ“JØŠ&9£  J¨$º–8—lVˆô¦Ü³¿TNø*ÅÔM9Â’q]Yh×8MŸZé ì3©G¤CëCî¼,:Ê8Gó?&ºðéÞE5«+Üâri¶éYŠWîMJ:•Š»»†0;˜VsÖÅù!ïd ì§%çPœ#Jï“É,MnfŽZõ:’Hg\­fúk·ûöÿ"ÐûÞ¶ÑtÜ¥•“Í(þ'8R£Ó,„Käs@¢V¹¸ÜÖWF èBÐØØÖÙW¨zÛV¿v ¤wÂ÷ª§Pë·z…ÁI.ÔwËS׳.b#CûÆÕp–Nf>€d×GIAÝIoy¥æMtZtoÃýcTf‘c´€ÿçý…]ìzsBéÄRÖ©}r;Ë6 ƒð½©zïÑèðç[» Ÿð¤:YføF;ôYÞ‹Òz¶¶U­íÙ '™äAúúÖƒ¦tvƒ¡…šw7·CœÈP~üÔ«î¥!FQT N 7£Ý> Oµyoñ¯Wé„loã÷þ˧†(³)³ø+£­îM¨p£€ 5ÓMÊ“úšf1$™F þ´B (˜ò…_SÁ®8õHQ>g»ÓQ’³vÇz/e¤<›d¹Ýzç?aR-,bFÛicêç֨連KpÙUä’pëBíCÝé€}Pˆ3)ú(ö°F¤%¥²OŒš#ob|mÓîm¼“œ(§“P°‚Ðɤ€p3÷ª®©«^jbŽsyü£Y^CýC¹ËdgÊ=#kQýCZo¶Î+v.{°¦Ív›åÉy;üPÝ"Ò@Ãsçßu;Ôz÷ì+M° {–íŸOš¸Ä“<1Ž!Mû®ï5+.Œ™¥S)%gÚð‡©$iã½eŸøQÏ–«Z¾§u}v÷r–v9¨ê^™ÛÚ»ñÄø©Ì9YaT-NÂòÆb—1²ûCJ­Ö½EmsÓ]Û,‘žîqJ¶·ÄKE=™HvŒ“m8Ttü‹ö®©R¬K"èSÑiR¡<+El8\ú溾$Ý·>ƒûR¥YÏÆ£>4ÄÀx`àWÿ†ÿ¥*Tc…nLšî/ÍJ•BWlÑÇñCÒ•*¥K£ùÞ¹4©U(±öz)z€œë©RÝñø‚ƒçQ麹¾'ÇÆM*UĈr¡Ëù«‘Ú•*pF¼É®Iæ•*Š/+ÃJ•ZµÍxM*UjÒÉ÷¯2qÞ•*Š%“ŽõÎN{Ò¥QD²}ëÌŸzTªÔK'ÜÒÉ÷4©TT¥ÛÈâ)ÀvÁŒúÔ –o¤q“‚G¥J¼”=J°ô7ÿÕÿòÿµ3{Æü{Ò¥^¿ÂÿÒ­?†ˆ¦úùʂ땱ÈûPÝy™¯¦ÜÄù½M*Uç?‰?óÛÿ¯ê½€§'ÍY¿ÕMÈ%F~ÕLêÉd—©/ ’3äÇ #include #include #include class tmpmsg { public: void setMessage(char *msg) { MessageOutput->value(msg); MessageOutput->redraw(); } void show() {outputWindow->show();} void hide() {outputWindow->hide();} friend Fl_Window *tmpmsg_panel(tmpmsg &tm); private: Fl_Window *outputWindow; Fl_Output *MessageOutput; }; #endif // TMPMSG_H imview-1.1.9c/TODO0000644000076500007650000001023710065765563014503 0ustar talbottalbot00000000000000# # $Id: TODO,v 4.9 2004/06/22 08:18:59 hut66au Exp $ # # Things to do. Improvements: ============= For PSL: -------- - follow-up re. running out of resources - spacebar problem (see pointfiles) From Richard: ------------- What we'd like to be able to do is access the fltk drawing routines through the socket. The objects that get drawn should have the same behaviour under zoom and translation as the pointfiles. The primitives we'd like to have access to are lines, disks and text with colour. Positions should be defined in image coordinates. I'm not sure what else fltk provides, but it might be nice to leave room for expansion to include splines or whatever else is available. The simple things are all that is needed now though. - Also he thinks that the toolbar should start with one of the buttons depressed, because people are getting confused about how to get out of it From Mark/Changming: -------------------- - Prettier/more colourful 1-D profile print/save as .PS. - Various issues with multispectral images I forgot to write down. * do a fit-to-mean +/- 2.5 sigma rather than char (ignore outliers) From Hugues: ------------ - Expand on the idea above to draw bounding boxes, ellipses, etc, from the segmented object description. - Keep this TODO list up to date, it's infuriating. - add the aspect ratio as one of a set of characteristic the image should keep track off, just like gamma at present. Add the ability to specify the aspect ratio on the command line and/or with a simple dialog. - Add a `save overlay' option. Useful after manual bivariate histogram segmentation. - Write output header for raw images. - Save rotation and flip status. - EXIF 2.2 (library for that). - Lossless JPEG transf. - Dynamic run-time load of libraries, esp. ImageMagick. - Save to more known formats. - bicubic interpolation, both zoom out and in. Known bugs: =========== CRASHES: ------- - 3D rotations with non-8-bit data and overlay crashes: #0 0x0807d54d in imageIO::rotate3Dgeneric(long (*)(int, int, int), long) (this=0x8191080, myrotf=0x807d68a , nbplanepix=35840) at /home/talbot/projects/sourceforge/imview/imtransform.cxx:641 641 q[myrotf(x,y,z)] = *p++; (gdb) p p $1 = (unsigned char *) 0x4087f008 "" (gdb) p myrotf $2 = (rot3dtransf *) 0x807d68a - Z images with large number of samples crashes SHOWSTOPPERS: ------------- - Under cygwin the server doesn't work, Imview craps out with "Bad system call" - Incorrect behaviour for Z-IMAGE DOUBLE images under WinXP (content is incorrect). - Imview compiles under mingw32 for Linux (cross-compiler) but doesn't run 8-( INCONVENIENCES AND INCONSISTENCIES: ----------------------------------- - resize still a problem sometimes. Imview gets itself into a weird state with incorrect limits. Specifying a complete redraw should clear everything but doesn't. - There is also a bug in the 1D profile when there is an overlay - the overlay information is displayed in the profile. - last line and last column of image often missing when scrollbar are present. - The profile box is one pixel too short at the end. - Printing of non-image items (text, points, etc) missing. - Points and rotations: normally defined points follow rotations (if you define a few points then rotate the image the points also rotate), but then if you re-open the image the points stay stuck where they were last! - Related to the above is still the lack of rotation grammar. A rotated image which was rotated should still be rotated when reopened! - Move to the middle of the screen. Sometimes for no apparent reason Imview moves to the middle of the screen. This seems to be happening if the main window resises and this is infurating on dual-screen setups. Update: this may be an FLTK artifact. - Too many menu items remain accessible when no image is displayed. - Documentation and man page do not match software version. - 3D rotations with `image fits window' works but changing plane resets the window! - Under cygwin, problems with Imagemagick (dependence on X11). Last changes: Hugues Talbot 23 May 2004 -- version 1.1.4 imview-1.1.9c/toolbar.cxx0000644000076500007650000001422210066460735016171 0ustar talbottalbot00000000000000/* * $Id: toolbar.cxx,v 4.5 2004/06/24 05:08:45 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Most of imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A simple toolbar, for now. * * Hugues Talbot 29 Jan 2001 * *-----------------------------------------------------------------------*/ #include "imview.hxx" #include "toolbar.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "menubar.hxx" // rotations, etc extern imageIO *IOBlackBox; extern imageViewer *mainViewer; tipButton::tipButton(int x, int y, int w, int h, const char *label) : Fl_Button(x,y,w,h,label) { dbgprintf("TipButton constructed\n"); message_ = 0; parentToolbar_ = 0; return; } tipButton::~tipButton() { } int tipButton::handle(int event) { int retval = 0; switch (event) { case FL_ENTER: chg_cursor(FL_CURSOR_CROSS); dbgprintf("My message is: %s\n", message_); //if (parentToolbar_) // parentToolbar_->setMessage(message_); retval = 1; break; // just relying on FL_ENTER is not quite good enough // when buttons are close together it may be that // events are not delivered in the desired order case FL_MOVE: chg_cursor(FL_CURSOR_CROSS); retval = 1; break; case FL_LEAVE: chg_cursor(FL_CURSOR_DEFAULT); retval = 1; break; // call the parent class method. default: retval = Fl_Button::handle(event); break; } return retval; } void tipButton::chg_cursor(Fl_Cursor c) { Fl_Window *w = window(); w->make_current(); fl_cursor(c); } toolbar::toolbar() { dbgprintf("Toolbar created\n"); toolbarWindow = 0; return; } toolbar::~toolbar() { dbgprintf("Toolbar destroyed\n"); return; } void toolbar::setDefaults() { return; } /* -- All the callbacks -- */ void setpointmode_cb(Fl_Choice *b, toolbar *tb) { dbgprintf("Choice value: %d\n", b->value()); if (mainViewer) { switch (b->value()) { case 0: dbgprintf("Add point mode\n"); mainViewer->setpointermode(IMV_POINTER_ADDPT_MODE); break; case 1: dbgprintf("Select point mode\n"); mainViewer->setpointermode(IMV_POINTER_SELECT_MODE); break; case 2: dbgprintf("Draw points mode\n"); mainViewer->setpointermode(IMV_POINTER_DRAWPT_MODE); break; case 3: dbgprintf("Delete single point mode\n"); mainViewer->setpointermode(IMV_POINTER_DELPT_MODE); break; case 4: dbgprintf("Delete point group mode"); mainViewer->setpointermode(IMV_POINTER_DELGRP_MODE); break; } } return; } void setzoommode_cb(tipButton *, toolbar *tb) { dbgprintf("Set Zoom Mode callback\n"); if (mainViewer) mainViewer->setpointermode(IMV_POINTER_ZOOM_MODE); } void setmeasuremode_cb(tipButton *, toolbar *tb) { dbgprintf("Set Measure Mode callback\n"); if (mainViewer) mainViewer->setpointermode(IMV_POINTER_MEASURE_MODE); } void setselectmode_cb(tipButton *, toolbar *) { dbgprintf("Set Select Mode callback\n"); if (mainViewer) mainViewer->setpointermode(IMV_POINTER_SELECT_MODE); } void addpointmode_cb(Fl_Widget *, void *) { dbgprintf("Add Point Mode callback\n"); if (mainViewer) mainViewer->setpointermode(IMV_POINTER_ADDPT_MODE); } void addpointmode_cb(tipButton *, toolbar *tb) { dbgprintf("Add Point Mode callback\n"); if (mainViewer) mainViewer->setpointermode(IMV_POINTER_ADDPT_MODE); } void drawpointmode_cb(tipButton *, toolbar *tb) { dbgprintf("Draw Point Mode callback\n"); if (mainViewer) mainViewer->setpointermode(IMV_POINTER_DRAWPT_MODE); } void deletepointmode_cb(tipButton *, toolbar *tb) { dbgprintf("Delete Point Mode callback\n"); if (mainViewer) mainViewer->setpointermode(IMV_POINTER_DELPT_MODE); } void editpointmode_cb(tipButton *, toolbar *tb) { dbgprintf("Edit Point Mode callback\n"); if (mainViewer) mainViewer->setpointermode(IMV_POINTER_EDITPT_MODE); } void hidetoolbar_cb(tipButton *, toolbar *tb) { dbgprintf("Hide Toolbar callback\n"); tb->hide(); } // relay the callback void local_rotate90right_cb(tipButton *b, void *) { if(IOBlackBox->imageData() != 0) ((Fl_Callback *)rotate90right_cb)(0,0); } void local_rotate90left_cb(tipButton *b, void *) { if(IOBlackBox->imageData() != 0) ((Fl_Callback *)rotate90left_cb)(0,0); } void local_flipv_cb(tipButton *b, void *) { if(IOBlackBox->imageData() != 0) ((Fl_Callback *)flipv_cb)(0,0); } void local_fliph_cb(tipButton *b, void *) { if(IOBlackBox->imageData() != 0) ((Fl_Callback *)fliph_cb)(0,0); } imview-1.1.9c/toolbar.hxx0000644000076500007650000000574410066324231016175 0ustar talbottalbot00000000000000/* * $Id: toolbar.hxx,v 4.3 2004/06/23 15:58:17 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Most of imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * Simple toolbar, originally. Is sure to become complicated as hell... * * Hugues Talbot 29 Jan 2001 * *-----------------------------------------------------------------------*/ #ifndef TOOLBAR_H #define TOOLBAR_H #include "imview.hxx" #include "imnmspc.hxx" // namespace def. if required #include #include #include #include #include #include #include #include #include class tipButton: public Fl_Button { public: tipButton(int x, int y, int w, int h, const char *label=0); ~tipButton(); int handle(int event); // so we can handle ENTER and LEAVE events void chg_cursor(Fl_Cursor c); void message(const char *m) {message_ = m;} void parentToolbar(class toolbar *t) {parentToolbar_ = t;} private: const char *message_; class toolbar *parentToolbar_; }; class toolbar { public: toolbar(); ~toolbar(); void setDefaults(); void show() {toolbarWindow->show();} void hide() {toolbarWindow->hide();} friend Fl_Window *toolbar_panel(toolbar &tb); private: void setMessage(const char *m) {} Fl_Window *toolbarWindow; }; #endif // TOOLBAR_H imview-1.1.9c/transferBox.cxx0000644000076500007650000001752407653236507017042 0ustar talbottalbot00000000000000/* * $Id: transferBox.cxx,v 4.0 2003/04/28 14:40:07 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A subclass of Box for drawing transfer functions * * Hugues Talbot 3 May 1998 * *-----------------------------------------------------------------------*/ #include #include "imview.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "menubar.hxx" #include "transferFunction.hxx" #include "transferRGBFunction.hxx" #include "transferBox.hxx" extern imageIO *IOBlackBox; extern imageViewer *mainViewer; extern imViewMenuBar *mainMenuBar; extern transfer *transferEditorPanel; extern transferRGB *transferRGBEditorPanel; myTransferBox::~myTransferBox() { dbgprintf("Transfer Box destroyed"); return; } void myTransferBox::draw() { draw_box(); draw_label(); // the superclass actually does no further drawing return; } void myTransferBox::computeEndPoints(double &x0, double &y0, double &x1, double &y1) { double dx, dy; // OK, draw the transfer function now! if (currContrast >= -0.5 && currContrast <= 0.5) { dy = tan(currContrast*M_PI/2); if (dy != 0) { x0 = currBrightness - 0.5/dy; x1 = 0.5/dy + currBrightness; } else { x0 = 0; x1 = 1; } y0 = 0.5 - dy*currBrightness; y1 = 0.5 + dy*(1-currBrightness); } else { dx = 1/tan(currContrast*M_PI/2); dbgprintf("Contrast=%g, dx= %g\n", currContrast, dx); if (fabs(dx) >= 1e-7) { y0 = 0.5 - currBrightness/dx; y1 = (1-currBrightness)/dx +0.5; } else { if (dx >= 0) { y0 = -2; y1 = 2; } else { y0 = 200; y1 = -200; } } x0 = currBrightness - 0.5*dx; x1 = currBrightness + 0.5*dx; } } void myTransferBox::findExtremes(double x0, double y0, double x1, double y1, double *startX, double *startY, double *endX, double *endY) { // the values that will end up in the input widgets double swapd; // see if the contrast is positive or negative: if (x0 > x1 || y0 > y1) { // negative swapd = x0; x0 = x1; x1 = swapd; if (y0 > 1) { *startX = x0; *startY = 1.0; } else { *startX = 0.0; *startY = y0; } if (y1 > 0) { *endX = 1.0; *endY = y1; } else { *endX = x1; *endY = 0.0; } } else { // positive if (y0 < 0) { *startX = x0; *startY = 0.0; } else { *startX = 0.0; *startY = y0; } if (y1 <= 1) { *endX = 1.0; *endY = y1; } else { *endX = x1; *endY = 1.0; } } return; } void myTransferBox::buildFunction(double x0, double y0, double x1, double y1) { // the values that will end up in the input widgets int startX, startY, endX, endY; double swapd; const int mininval = 0, maxinval = 255; const int minoutval = 0, maxoutval = 255; int i; // see if the contrast is positive or negative: if (x0 > x1 || y0 > y1) { // negative swapd = x0; x0 = x1; x1 = swapd; if (y0 > 1) { startX = (int)(x0*maxinval); startY = maxoutval; } else { startX = mininval; startY = (int)(y0*maxoutval); } if (y1 > 0) { endX = maxinval; endY = (int)(y1*maxoutval); } else { endX = (int)(x1*maxinval); endY = 0; } for (i = mininval ; i < startX; i++) map[i] = maxoutval; int h0 = endY - startY; int w0 = endX - startX; for (i = startX ; i < endX ; i++) { map[i] = (unsigned char)(startY + h0*pow(((double)i-startX)/w0,1/currGamma)); } for (i = endX ; i <= maxinval ; i++) { map[i] = minoutval; } } else { // positive if (y0 < 0) { startX = (int)(x0*maxinval); startY = 0; } else { startX = mininval; startY = (int)(y0*maxoutval); } if (y1 <= 1) { endX = maxinval; endY = (int)(y1*maxoutval); } else { endX = (int)(x1*maxinval); endY = maxoutval; } for (i = mininval ; i < startX; i++) map[i] = minoutval; int h0 = endY - startY; int w0 = endX - startX; for (i = startX ; i < endX ; i++) { map[i] = (unsigned char)(startY + h0*pow(((double)i-startX)/w0,1/currGamma)); } for (i = endX ; i <= maxinval ; i++) { map[i] = maxoutval; } } if (hasReleaseOccured) { causeMainWindowRedraw(); hasReleaseOccured = false; } if (transferEditorPanel) { transferEditorPanel->setTopValue(endX); transferEditorPanel->setBottomValue(startX); transferEditorPanel->setLeftValue(startY); transferEditorPanel->setRightValue(endY); } return; } // this is a very slow call, so we don't want to do it // all the time... void myTransferBox::causeMainWindowRedraw() { // this might be very slow... dbgprintf("Really redrawing the image\n"); // a million parameters there... IOBlackBox->saveGammaParameters(leftX, leftY, rightX, rightY, gammas, map, 0, 0); // get the current image IMAGEPARM *p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if ((p != 0) && (transferEditorPanel != 0)) { // save the gamma, etc dbgprintf("Attempting to save the transfer functions parameters\n"); transferEditorPanel->getParameters(p->gamma, p->contrast, p->brightness); dbgprintf("%s got: gamma=%g, contrast=%g, brightness=%g\n", p->itempath, p->gamma, p->contrast, p->brightness); } // this re-reads all the parameters, etc. IOBlackBox->applyImageParameters(p, 0, 0, true); mainViewer->displayCurrentImage(); // this can be quite slow as well... trueRedrawHook(); // and don't forget myself... redraw(); } void myTransferBox::setParms(float c, float b, float g) { double x0, y0, x1, y1; double startX, startY, endX, endY; currContrast = (c < -1.0) ? -1.0:c; currBrightness = b; currGamma = g; computeEndPoints(x0, y0, x1, y1); findExtremes(x0, y0, x1, y1, &startX, &startY, &endX, &endY); // This is temporary until we find the time of implementing // separate transfer function controls for R, G and B gammas[0] = gammas[1] = gammas[2] = g; leftX[0] = leftX[1] = leftX[2] = startX; leftY[0] = leftY[1] = leftY[2] = startY; rightX[0] = rightX[1] = rightX[2] = endX; rightY[0] = rightY[1] = rightY[2] = endY; // this will update the image if need be, // and will put the right numbers in the input widget fields buildFunction(x0, y0, x1, y1); redraw(); return; } imview-1.1.9c/transferBox.hxx0000644000076500007650000000777407653236510017047 0ustar talbottalbot00000000000000/* * $Id: transferBox.hxx,v 4.0 2003/04/28 14:40:08 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A subclass of Box which is used for brightness/contrast/etc. * This is a superclass for the actually interesting ones. * * * Hugues Talbot 3 May 1998 * *-----------------------------------------------------------------------*/ #ifndef TRANSFERBOX_H #define TRANSFERBOX_H #include #include #include class myTransferBox : public Fl_Box { private: bool hasReleaseOccured; unsigned char map[256]; virtual void trueRedrawHook() { } // called when the main window is also redrawn void findExtremes(double x0, double y0, double x1, double y1, double *startX, double *startY, double *endX, double *endY); double currContrast, currBrightness, currGamma; double gammas[3], leftX[3], leftY[3], rightX[3], rightY[3]; double currRGBContrast[3], currRGBBrightness[3], currRGBGamma[3]; protected: void draw(); // I'm expecting to have to subclass this void computeEndPoints(double &x0, double &y0, double &x1, double &y1); void buildFunction(double x0, double y0, double x1, double y1); public: myTransferBox(int x, int y, int w, int h, const char *l=0) : Fl_Box(x,y,w,h,l) { hasReleaseOccured = false; } myTransferBox(uchar b, int x, int y, int w, int h, const char *l) : Fl_Box(x,y,w,h,l) { hasReleaseOccured = false; } ~myTransferBox(); void setParms(float contrast, float brightness, float gamma); void setRGBParms(double contrast[3], double brighntess[3], double gamma[3]); void getParms(float &contrast, float &brightness, float &gamma) { contrast = (float)currContrast; brightness = (float)currBrightness ; gamma = (float)currGamma;} virtual void getRGBParms(float &Rcontrast, float &Rbrightness, float &Rgamma, float &Gcontrast, float &Gbrightness, float &Ggamma, float &Bcontrast, float &Bbrightness, float &Bgamma) {} void causeMainWindowRedraw(); void forceBuildMap() { double x0, y0, x1, y1; x0 = y0 = x1 = y1 = 0.0; computeEndPoints(x0, y0, x1, y1); buildFunction(x0, y0, x1, y1); } void setRelease(bool s) { hasReleaseOccured = s;} double getCurrGamma(void ) {return currGamma;} double getCurrBrightness(void) {return currBrightness;} double getCurrContrast(void) {return currContrast;} }; #endif // TRANSFERBOX_H imview-1.1.9c/transferFunction.cxx0000644000076500007650000003364107653236511020070 0ustar talbottalbot00000000000000/* * $Id: transferFunction.cxx,v 4.0 2003/04/28 14:40:09 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The long-awaited contrast/brightness/gamma control panel * * Hugues Talbot 3 May 1998 * *-----------------------------------------------------------------------*/ #include #include #include #include "imview.hxx" #include "imageIO.hxx" #include "transferFunction.hxx" extern imageIO *IOBlackBox; extern transfer *transferEditorPanel; extern int applyTransferToAll; extern double persistentGamma; transfer::transfer() { dbgprintf("Transfer function dialog created\n"); transferWindow = 0; // fluid depends on that. transferBox = 0; transferHistoBox = 0; transferFunctionBox = 0; return; } transfer::~transfer() { if (transferHistoBox != 0) delete transferHistoBox; return; } void transfer::setDefaults() { static char buff[100]; static const Fl_Menu_Item displayMenu[] = { {"Transfer function", 0, (Fl_Callback *)chosendisplay_cb, (void *)TRANSFER_DSP}, {"Histogram", 0, (Fl_Callback *)chosendisplay_cb, (void *)HISTOGRAM_DSP}, {0} }; dbgprintf("Setting up defaults for transfer panel\n"); displayChoice->menu(displayMenu); // set range, etc, for sliders... contrastSlider->minimum(1.0); contrastSlider->maximum(-1.05); contrastSlider->value(0.5); contrastSlider->step(0.005); brightnessSlider->minimum(0.0); brightnessSlider->maximum(1.0); brightnessSlider->value(0.5); brightnessSlider->step(0.005); gammaSlider->minimum(1.0); gammaSlider->maximum(-1.0); gammaSlider->value(log(persistentGamma)); // this is what I mean by persistent gammaSlider->step(0.01); sprintf(buff, "%g", persistentGamma); gammaInput->value(buff); sprintf(buff, "255"); topInput->value(buff); rightInput->value(buff); sprintf(buff, "0"); bottomInput->value(buff); leftInput->value(buff); // allocate and set the parameters of the histobox; if (transferHistoBox == 0) { int x,y,w,h; x = transferBox->x(); y = transferBox->y(); w = transferBox->w(); h = transferBox->h(); // same dimensions transferHistoBox = new myTransferHistoBox(x,y,w,h); // same box transferHistoBox->box(transferBox->box()); // same colour transferHistoBox->color(transferBox->color()); // same user data transferHistoBox->user_data((void *)this); } if (transferFunctionBox == 0) { int x,y,w,h; x = transferBox->x(); y = transferBox->y(); w = transferBox->w(); h = transferBox->h(); // same dimensions transferFunctionBox = new myTransferFunctionBox(x,y,w,h); // same box transferFunctionBox->box(transferBox->box()); // same colour transferFunctionBox->color(transferBox->color()); // same user data transferFunctionBox->user_data((void *)this); } // replace the generic transferBox by the one we want transferWindow->remove(transferBox); transferWindow->add(transferFunctionBox); memoryBox = transferBox; // the one allocated by fluid, we don't want it. // but we can't delete it... transferBox = transferFunctionBox; setDrawingParms(); if (persistentGamma != 1.0) { dbgprintf("Forcing the recalculation of the transfer map \n"); transferBox->forceBuildMap(); dbgprintf("Forcing redisplay of the main image \n"); transferBox->causeMainWindowRedraw(); // force the recalculation of the map LUT } return; } void transfer::setTransfer() { if (transferBox == transferHistoBox) { transferWindow->remove(transferHistoBox); transferWindow->add(transferFunctionBox); transferBox = transferFunctionBox; } // copy the changes in parameters that may have // occured with the other type of display... setDrawingParms(); transferWindow->redraw(); } void transfer::setHisto() { if (transferBox == transferFunctionBox) { transferWindow->remove(transferFunctionBox); transferWindow->add(transferHistoBox); transferBox = transferHistoBox; } // copy the changes in parameters that may have // occured with the other type of display... setDrawingParms(); transferHistoBox->makeHisto(); transferWindow->redraw(); } // compute the drawing parms from the Input (top,bottom, etc) values. void transfer::computeDrawingParms() { int topv, bottomv, rightv, leftv; double newbrightness = 0.5, newcontrast = 0.5; topv = atoi(topInput->value()); bottomv = atoi(bottomInput->value()); rightv = atoi(rightInput->value()); leftv = atoi(leftInput->value()); if (topv < 0) { topv = 0; topInput->value("0"); } if (topv > 255) { topv = 255; topInput->value("255"); } if (bottomv < 0) { bottomv = 0; bottomInput->value("0"); } if (bottomv > 255) { bottomv = 255; bottomInput->value("255"); } if (leftv < 0) { leftv = 0; leftInput->value("0"); } if (leftv > 255) { leftv = 255; leftInput->value("255"); } if (rightv < 0) { rightv = 0; rightInput->value("0"); } if (rightv > 255) { rightv = 255; rightInput->value("255"); } if ((leftv == 0) && (rightv == 255)) { if (topv > bottomv) { newcontrast = atan(255.0/((double)topv-bottomv))*2.0/M_PI; newbrightness = ((double)topv+bottomv)/(2*255.0); } } else if ((leftv == 255) && (rightv == 0)) { if ( topv > bottomv) { newcontrast = atan(-255.0/((double)topv-bottomv))*2.0/M_PI; newbrightness = ((double)topv+bottomv)/(2*255.0); } } else { newcontrast = atan((double)(rightv-leftv)/(255.0))*2.0/M_PI; if (rightv > leftv) newbrightness = (255.0 - 2*leftv)/(2*((double)rightv - leftv)); else if (leftv > rightv) newbrightness = (255.0 - 2*leftv)/(2*((double)leftv -rightv)); else newbrightness = 0.5; // doesnt' matter. } //newcontrast = floor(newcontrast*200.0)/200.0; // to get the expected precision //newbrightness = floor(newbrightness*200.0)/200.0; dbgprintf("Brightness: %g, Contrast: %g\n", newbrightness, newcontrast); contrastSlider->value(newcontrast); brightnessSlider->value(newbrightness); setDrawingParms(); transferWindow->redraw(); // this doesn't seem to work. Why? // ensureImageRedraw(true); return; } void transfer::setDrawingParms() { // redo this ASAP transferBox->setParms(contrastSlider->value(), brightnessSlider->value(), atof(gammaInput->value())); return; } void transfer::redrawWindowIfNeeded() { if (transferWindow->visible()) { dbgprintf("Forcing the recalculation of the map LUT\n"); transferBox->forceBuildMap(); transferWindow->redraw(); // force the recalculation of the map LUT } return; } void transfer::show() { transferWindow->show(); } void transfer::hide() { transferWindow->hide(); } void transfer::setTopValue(int t) { char cval[10]; dbgprintf("Top value being set to %d\n", t); sprintf(cval, "%d", t); topInput->value(cval); return; } void transfer::setBottomValue(int t) { char cval[10]; dbgprintf("Bottom value being set to %d\n", t); sprintf(cval, "%d", t); bottomInput->value(cval); return; } void transfer::setLeftValue(int t) { char cval[10]; sprintf(cval, "%d", t); dbgprintf("Left value being set to %d\n", t); leftInput->value(cval); return; } void transfer::setRightValue(int t) { char cval[10]; sprintf(cval, "%d", t); dbgprintf("Right value being set to %d\n", t); rightInput->value(cval); // This ugly bit of code is now thankfully useless. // // if (transferWindow && transferWindow->shown()) { // transferWindow->make_current(); // rightInput->draw(); // } return; } // callbacks associated with objects on the dialog void chosendisplay_cb(Fl_Menu_ *, void *value) { long val = (long)value; switch (val) { case TRANSFER_DSP: transferEditorPanel->setTransfer(); break; case HISTOGRAM_DSP: transferEditorPanel->setHisto(); break; default: errprintf("Unknown value from choice menu: %d\n", val); break; } return; } // callbacks associated with this dialog void brightnessslider_cb(Fl_Slider*, transfer *panel) { dbgprintf("Brightness slider callback\n"); if (Fl::pushed() == 0) { dbgprintf("Button Released!\n"); panel->ensureImageRedraw(true); } panel->setDrawingParms(); return; } void contrastslider_cb(Fl_Slider *, transfer *panel) { dbgprintf("Contrast slider callback\n"); if (Fl::pushed() == 0) { dbgprintf("Button Released!\n"); panel->ensureImageRedraw(true); } panel->setDrawingParms(); return; } void displaychoice_cb(Fl_Choice*, transfer*) { dbgprintf("Display choice callback\n"); } void gammainput_cb(Fl_Float_Input *theInput, transfer *panel) { double eval, val; const char *cval; dbgprintf("Gamma input callback\n"); cval = theInput->value(); eval = atof(cval); if (eval > 0) { val = log(eval); } else { char cval[10]; val = -1; sprintf(cval,"%1.4g", exp(-1)); panel->setGammaInputValue((const char *)cval); } panel->setGammaSliderValue((float)val); panel->ensureImageRedraw(true); panel->setDrawingParms(); return; } void gammaslider_cb(Fl_Slider *theSlider, transfer *panel) { double val, eval; char cval[20]; dbgprintf("Gamma slider callback\n"); if (Fl::pushed() == 0) { dbgprintf("Button Released!\n"); panel->ensureImageRedraw(true); } val = (double)theSlider->value(); eval = exp(val); sprintf(cval, "%1.4g", eval); panel->setGammaInputValue(cval); panel->setDrawingParms(); return; } void bottominput_cb(Fl_Int_Input *theInput, transfer *panel) { panel->ensureImageRedraw(true); panel->computeDrawingParms(); return; } void topinput_cb(Fl_Int_Input *theInput, transfer *panel) { dbgprintf("Top input callback\n"); panel->ensureImageRedraw(true); panel->computeDrawingParms(); return; } void leftinput_cb(Fl_Int_Input *theInput, transfer *panel) { panel->ensureImageRedraw(true); panel->computeDrawingParms(); return; } void rightinput_cb(Fl_Int_Input *theInput, transfer *panel) { panel->ensureImageRedraw(true); panel->computeDrawingParms(); return; } void resetbutton_cb(Fl_Button*, transfer *panel) { char buf[100]; // this is very simple... dbgprintf("Reset button pressed\n"); sprintf(buf, "%g", persistentGamma); panel->setGammaInputValue(buf); panel->setGammaSliderValue(0); panel->setContrastSliderValue(0.5); panel->setBrightnessSliderValue(0.5); panel->computeDrawingParms(); panel->setDrawingParms(); // panel->ensureImageRedraw(true); // we want the result to be shown on the image return; } void normalisebutton_cb(Fl_Button*, transfer *panel) { int spp, val, minval, maxval; long nbpix; unsigned char *p, *end; double slope, startp; nbpix = IOBlackBox->imageWidth() * IOBlackBox->imageHeight(); spp = IOBlackBox->imageDepth(); maxval = 0; minval = 255; if (spp == 1) { p = IOBlackBox->imageData(); end = p + nbpix; while (p != end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } else if (spp == 3) { p = IOBlackBox->imageData(); end = p + spp * nbpix; // colour is a bit more conservative: // we take the min and max of all 3 component together // otherwise overflow occurs while (p != end) { val = *p++; if (val > maxval) maxval = val; if (val < maxval) minval = val; } } dbgprintf("Min val:%d, max val: %d\n", minval, maxval); // now compute the slope parameters, etc if (maxval != minval) slope = 2*atan(255.0/(maxval-minval))/M_PI; else slope = 1; startp = ((double)maxval+minval)/(512); // this is now pretty simple... panel->setContrastSliderValue(slope); panel->setBrightnessSliderValue(startp); panel->ensureImageRedraw(true); // we want the result to be shown on the image panel->setDrawingParms(); return; } void applytoallbutton_cb(Fl_Check_Button *b, transfer *panel) { applyTransferToAll = b->value(); switch (applyTransferToAll) { case 0: dbgprintf("Will apply tranfer function only to currently displayed image\n"); break; default: dbgprintf("Will apply transfer function to all image/components, etc\n"); break; } return; } void okbutton_cb(Fl_Return_Button*, transfer *panel) { // this is very simple... panel->hide(); } imview-1.1.9c/transferFunction.hxx0000644000076500007650000000774007727302474020102 0ustar talbottalbot00000000000000/* * $Id: transferFunction.hxx,v 4.1 2003/09/09 07:46:04 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The long-awaited contrast/brightness/gamma panel * * Hugues Talbot 3 May 1998 * * *-----------------------------------------------------------------------*/ #ifndef TRANSFERFUNCTION_H #define TRANSFERFUNCTION_H #include #include #include #include #include #include #include #include #include #include #include #include "transferBox.hxx" #include "transferHistoBox.hxx" #include "transferFunctionBox.hxx" enum { TRANSFER_DSP = 0, HISTOGRAM_DSP = 1 }; void chosendisplay_cb(Fl_Menu_ *, void *); class transfer { public: transfer(); ~transfer(); void setDefaults(); void computeDrawingParms(); void setDrawingParms(); void redrawWindowIfNeeded(); void show(); void hide(); void setGammaSliderValue(float val) {gammaSlider->value(val);} void setGammaInputValue(const char *c) {gammaInput->value(c);} void setContrastSliderValue(float val) {contrastSlider->value(val);} void setBrightnessSliderValue(float val) {brightnessSlider->value(val);} void setTopValue(int t); void setBottomValue(int t); void setLeftValue(int t); void setRightValue(int t); void setTransfer(); void setHisto(); void getParameters(float &theGamma, float &theContrast, float &theBrightness) { transferBox->getParms(theContrast, theBrightness, theGamma); } void ensureImageRedraw(bool s) {transferBox->setRelease(s);} friend Fl_Double_Window *transfer_panel(transfer &s); private: Fl_Double_Window *transferWindow; Fl_Choice *displayChoice; Fl_Float_Input *gammaInput; Fl_Int_Input *topInput, *bottomInput, *leftInput, *rightInput; myTransferBox *transferBox, *memoryBox; myTransferHistoBox *transferHistoBox; myTransferFunctionBox *transferFunctionBox; Fl_Slider *contrastSlider, *brightnessSlider; Fl_Slider *gammaSlider; Fl_Button *resetButton, *normaliseButton; Fl_Check_Button *applyToAllButton; Fl_Return_Button *OKButton; }; #endif // TRANSFERFUNCTION_H imview-1.1.9c/transferFunctionBox.cxx0000644000076500007650000001070407653236515020540 0ustar talbottalbot00000000000000/* * $Id: transferFunctionBox.cxx,v 4.0 2003/04/28 14:40:13 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A subclass of Box for drawing transfer functions * * Hugues Talbot 3 May 1998 * *-----------------------------------------------------------------------*/ #include #include "imview.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "transferFunction.hxx" #include "transferBox.hxx" #include "transferFunctionBox.hxx" extern imageIO *IOBlackBox; extern imageViewer *mainViewer; extern transfer *transferEditorPanel; void myTransferFunctionBox::draw() { int startX, startY, endX, endY, inc; double x0, y0, x1, y1, swapd; // these are normally between 0 and 1 int w0, h0; int xa, ya, xb, yb; // call the superclass' draw routine. myTransferBox::draw(); computeEndPoints(x0, y0, x1, y1); // this returns the End points. //fl_clip(x(),y(),w(),h()); fl_push_no_clip(); fl_color(FL_RED); inc = 1; if (x0 > x1 || y0 > y1) { // negative contrast swapd = x1; x1 = x0; x0 = swapd; if (y0 > 1) { startX = (int)(x0*(w()-1)); startY = 0; } else { startX = 0; startY = (int)((h()-1)*(1-y0)); } if (y1 > 0) { endX = w()-1; endY = (int)((h()-1)*(1-y1)); } else { endX = (int)(x1*(w()-1)); endY = h()-1; } dbgprintf("Start: (%d, %d) ; end: (%d, %d)\n", startX, startY, endX, endY); w0 = endX - startX; h0 = startY - endY; // h is inverted... xa = 0; ya = 0; if (w0 != 0) { for (xb = startX; xb <= endX ; xb += inc) { //yb = startY - (xb-startX)*h0/w0; yb = (int)(startY - h0*pow(((double)xb-startX)/w0,1/getCurrGamma())); fl_line(xa+x(), ya+y(), xb+x(),yb+y()); xa = xb; ya = yb; } } else { fl_line(x(), y()+h()-1, startX+x(), y()+h()-1); fl_line(startX+x(), startY+y(), endX+x(), endY+y()); xa = endX; ya = endY; } // finish the path fl_line(xa+x(), ya+y(), w()-1+x(), y()+h()-1); } else { if (y0 < 0) { startX = (int)(x0*(w()-1)); startY = h()-1; } else { startX = 0; startY = (int)((h()-1)*(1-y0)); } if (y1 <= 1) { endX = w()-1; endY = (int)((h()-1)*(1-y1)); } else { endX = (int)(x1*(w()-1)); endY = 0; } dbgprintf("Start: (%d, %d) ; end: (%d, %d)\n", startX, startY, endX, endY); w0 = endX - startX; h0 = startY - endY; // h is inverted... xa = 0; ya = h()-1; if (w0 != 0) { for (xb = startX; xb <= endX ; xb += inc) { //yb = startY - (xb-startX)*h0/w0; yb = (int)(startY - h0*pow(((double)xb-startX)/w0,1/getCurrGamma())); fl_line(xa+x(), ya+y(), xb+x(),yb+y()); xa = xb; ya = yb; } } else { fl_line(x(), y()+h()-1, startX+x(), y()+h()-1); fl_line(startX+x(), startY+y(), endX+x(), endY+y()); xa = endX; ya = endY; } // finish the path fl_line(xa+x(), ya+y(), w()-1+x(), y()); } fl_pop_clip(); return; } imview-1.1.9c/transferFunctionBox.hxx0000644000076500007650000000456407653236516020555 0ustar talbottalbot00000000000000/* * $Id: transferFunctionBox.hxx,v 4.0 2003/04/28 14:40:14 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A subclass of Box where drawing can occur * * Hugues Talbot 3 May 1998 * *-----------------------------------------------------------------------*/ #ifndef TRANSFERFUNCTIONBOX_H #define TRANSFERFUNCTIONBOX_H #include #include #include class myTransferFunctionBox : public myTransferBox { protected: void draw(); // I'm expecting to have to subclass this public: myTransferFunctionBox(int x, int y, int w, int h, const char *l=0) : myTransferBox(x,y,w,h,l) { } myTransferFunctionBox(uchar b, int x, int y, int w, int h, const char *l) : myTransferBox(b,x,y,w,h,l) { } }; #endif // TRANSFERFUNCTIONBOX_H imview-1.1.9c/transferHistoBox.cxx0000644000076500007650000000657307653236516020053 0ustar talbottalbot00000000000000/* * $Id: transferHistoBox.cxx,v 4.0 2003/04/28 14:40:14 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A subclass of Box for drawing transfer functions * * Hugues Talbot 3 May 1998 * *-----------------------------------------------------------------------*/ #include #include "imview.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "transferFunction.hxx" #include "transferBox.hxx" #include "transferHistoBox.hxx" extern imageIO *IOBlackBox; extern imageViewer *mainViewer; extern transfer *transferEditorPanel; void myTransferHistoBox::makeHisto() { int i, spp, val; long nbpix; unsigned char *p, *end; for (i = 0 ; i < 256 ; i++) theHisto[i] = 0; nbpix = IOBlackBox->imageWidth() * IOBlackBox->imageHeight(); spp = IOBlackBox->imageDepth(); if (spp == 1) { p = IOBlackBox->imageData(); end = p + nbpix; while (p != end) { theHisto[*p++]++; // simple. } } else if (spp == 3) { // we need to be a bit more conservative with colour p = IOBlackBox->imageData(); end = p + spp * nbpix; while (p != end) { val = *p++; val += *p++; val += *p++; theHisto[val/3]++; // simple as well. } } maxval = 0; for (i = 0 ; i < 256 ; i++) if (theHisto[i] > maxval) maxval= theHisto[i]; return; } void myTransferHistoBox::draw() { double x0, y0, x1, y1; int xx; // call the superclass' draw routine myTransferBox::draw(); x0 = y0 = x1 = y1 = 0.0; computeEndPoints(x0, y0, x1, y1); // this fills the x?,y? fl_clip(x(),y(),w(),h()); fl_color(FL_BLACK); for (int i = 0 ; i < w() ; i++) { xx = (int)((double)i * 256 / w()); fl_line(x()+i, y()+h()-1, x()+i, y()+h()-(int)((double)theHisto[xx]*h()/maxval)); } fl_pop_clip(); return; } imview-1.1.9c/transferHistoBox.hxx0000644000076500007650000000502207653236516020044 0ustar talbottalbot00000000000000/* * $Id: transferHistoBox.hxx,v 4.0 2003/04/28 14:40:14 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A subclass of Box where drawing can occur * * Hugues Talbot 3 May 1998 * *-----------------------------------------------------------------------*/ #ifndef TRANSFERHISTOBOX_H #define TRANSFERHISTOBOX_H #include #include #include #include "transferRGBBox.hxx" class myTransferHistoBox : public myTransferBox { private: long theHisto[256], maxval; void trueRedrawHook() {makeHisto();} // supercede the superclass' definition protected: void draw(); // I'm expecting to have to subclass this public: myTransferHistoBox(int x, int y, int w, int h, const char *l=0) : myTransferBox(x,y,w,h,l) { } myTransferHistoBox(uchar b, int x, int y, int w, int h, const char *l) : myTransferBox(b,x,y,w,h,l) { } void makeHisto(); }; #endif // TRANSFERHISTOBOX_H imview-1.1.9c/transferRGBBox.cxx0000644000076500007650000002113507653236517017367 0ustar talbottalbot00000000000000/* * $Id: transferRGBBox.cxx,v 4.0 2003/04/28 14:40:15 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ #include #include "imview.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "menubar.hxx" #include "transferFunction.hxx" #include "transferRGBFunction.hxx" #include "transferBox.hxx" extern imageIO *IOBlackBox; extern imageViewer *mainViewer; extern imViewMenuBar *mainMenuBar; extern transfer *transferEditorPanel; extern transferRGB *transferRGBEditorPanel; myTransferRGBBox::~myTransferRGBBox() { dbgprintf("Transfer Box destroyed"); return; } void myTransferRGBBox::draw() { draw_box(); draw_label(); // the superclass actually does no further drawing return; } void myTransferRGBBox::computeRGBEndPoints(double x0[3], double y0[3], double x1[3], double y1[3]) { double dx, dy; for (int i = 0 ; i < 3 ; ++i) { // OK, draw the transfer function now! if (currContrast[i] >= -0.5 && currContrast[i] <= 0.5) { dy = tan(currContrast[i]*M_PI/2); if (dy != 0) { x0[i] = currBrightness[i] - 0.5/dy; x1[i] = 0.5/dy + currBrightness[i]; } else { x0[i] = 0; x1[i] = 1; } y0[i] = 0.5 - dy*currBrightness[i]; y1[i] = 0.5 + dy*(1-currBrightness[i]); } else { dx = 1/tan(currContrast[i]*M_PI/2); dbgprintf("Contrast[%d]=%g, dx= %g\n", i, currContrast[i], dx); if (fabs(dx) >= 1e-7) { y0[i] = 0.5 - currBrightness[i]/dx; y1[i] = (1-currBrightness[i])/dx +0.5; } else { if (dx >= 0) { y0[i] = -2; y1[i] = 2; } else { y0[i] = 200; y1[i] = -200; } } x0[i] = currBrightness[i] - 0.5*dx; x1[i] = currBrightness[i] + 0.5*dx; } } } // distinct lack of comments there. // I'm guessing this computes the cryptic `left,right,top,bottom' values // found in the dialog void myTransferRGBBox::findRGBExtremes(double x0[3], double y0[3], double x1[3], double y1[3], double startX[3], double startY[3], double endX[3], double endY[3]) { // the values that will end up in the input widgets double swapd; for (int i = 0 ; i < 3 ; ++i) { // see if the contrast is positive or negative: if (x0[i] > x1[i] || y0[i] > y1[i]) { // negative swapd = x0[i]; x0[i] = x1[i]; x1[i] = swapd; if (y0[i] > 1) { startX[i] = x0[i]; startY[i] = 1.0; } else { startX[i] = 0.0; startY[i] = y0[i]; } if (y1 > 0) { endX[i] = 1.0; endY[i] = y1[i]; } else { endX[i] = x1[i]; endY[i] = 0.0; } } else { // positive if (y0[i] < 0) { startX[i] = x0[i]; startY[i] = 0.0; } else { startX[i] = 0.0; startY[i] = y0[i]; } if (y1[i] <= 1) { endX[i] = 1.0; endY[i] = y1[i]; } else { endX[i] = x1[i]; endY[i] = 1.0; } } } return; } // fills up the RGBmap with the transfer function based on the given // parameters void myTransferRGBBox::buildRGBFunction(double x0[3], double y0[3], double x1[3], double y1[3]) { // the values that will end up in the input widgets int startX[3], startY[3], endX[3], endY[3]; double swapd; const int mininval = 0, maxinval = 255; const int minoutval = 0, maxoutval = 255; int j; for (int i = 0 ; i < 3 ; ++i) { // see if the contrast is positive or negative: if (x0[i] > x1[i] || y0[i] > y1[i]) { // negative swapd = x0[i]; x0[i] = x1[i]; x1[i] = swapd; if (y0[i] > 1) { startX[i] = (int)(x0[i] * maxinval); startY[i] = maxoutval; } else { startX[i] = mininval; startY[i] = (int)(y0[i] * maxoutval); } if (y1 > 0) { endX[i] = maxinval; endY[i] = (int)(y1[i] * maxoutval); } else { endX[i] = (int)(x1[i] * maxinval); endY[i] = 0; } for (j = mininval ; j < startX[i]; ++j) RGBmap[i][j] = maxoutval; int h0 = endY[i] - startY[i]; int w0 = endX[i] - startX[i]; for (j = startX[i] ; j < endX[i] ; ++j) { RGBmap[i][j] = (unsigned char)(startY[i] + h0*pow(((double)j-startX[i])/w0,1/currGamma[i])); } for (j = endX[i] ; j <= maxinval ; ++j) { RGBmap[i][j] = minoutval; } } else { // contrast is positive if (y0[i] < 0) { startX[i] = (int)(x0[i] * maxinval); startY[i] = 0; } else { startX[i] = mininval; startY[i] = (int)(y0[i] * maxoutval); } if (y1[i] <= 1) { endX[i] = maxinval; endY[i] = (int)(y1[i] * maxoutval); } else { endX[i] = (int)(x1[i] * maxinval); endY[i] = maxoutval; } for (j = mininval ; j < startX[i]; ++j) RGBmap[i][j] = minoutval; int h0 = endY[i] - startY[i]; int w0 = endX[i] - startX[i]; for (j = startX[i] ; j < endX[i] ; ++j) { RGBmap[i][j] = (unsigned char)(startY[i] + h0*pow(((double)j-startX[i])/w0,1/currGamma[i])); } for (j = endX[i] ; j <= maxinval ; ++j) { RGBmap[i][j] = maxoutval; } } } if (hasReleaseOccured) { causeMainWindowRedraw(); hasReleaseOccured = false; } if (transferRGBEditorPanel) { // NOTE : these need to accept 3-vectors transferRGBEditorPanel->setTopValue(endX); transferRGBEditorPanel->setBottomValue(startX); transferRGBEditorPanel->setLeftValue(startY); transferRGBEditorPanel->setRightValue(endY); } return; } // this is a very slow call, so we don't want to do it // all the time... void myTransferRGBBox::causeMainWindowRedraw() { // this might be very slow... dbgprintf("Really redrawing the image\n"); // a million parameters there... IOBlackBox->saveGammaParameters(leftX, leftY, rightX, rightY, gammas, RGBmap[0], RGBmap[1], RGBmap[2]); // get the current image IMAGEPARM *p = (IMAGEPARM *)mainMenuBar->getSelectedItemArgument(IMAGE_LIST_ID); if ((p != 0) && (transferRGBEditorPanel != 0)) { // save the gamma, etc dbgprintf("Attempting to save the transfer functions parameters\n"); transferRGBEditorPanel->getParameters(p->Rgamma, p->Ggamma, p->Bgamma, p->Rcontrast, p->Gcontrast, p->Bcontrast, p->Rbrightness, p->Gbrightness, p->Bbrightness); dbgprintf("%s got: Rgamma=%g, Rcontrast=%g, Rbrightness=%g\n", p->itempath, p->Rgamma, p->Rcontrast, p->Rbrightness); } // this re-reads all the parameters, etc. IOBlackBox->applyImageParameters(p, 0, 0, true); mainViewer->displayCurrentImage(); // this can be quite slow as well... trueRedrawHook(); // and don't forget myself... redraw(); } void myTransferRGBBox::setRGBParms(double c[3], double b[3], double g[3]) { double x0[3], y0[3], x1[3], y1[3]; double startX[3], startY[3], endX[3], endY[3]; int i; for (i = 0 ; i < 3 ; ++i) { currContrast[i] = (c[i] < -1.0) ? -1.0:c[i]; currBrightness[i] = b[i]; currGamma[i] = g[i]; } computeRGBEndPoints(x0, y0, x1, y1); findRGBExtremes(x0, y0, x1, y1, startX, startY, endX, endY); for (i = 0 ; i < 3 ; ++i) { gammas[i] = g[i]; leftX[i] = startX[i]; leftY[i] = startY[i]; rightX[i] = endX[i]; rightY[i] = endY[i]; } // this will update the image if need be, // and will put the right numbers in the input widget fields buildRGBFunction(x0, y0, x1, y1); redraw(); return; } imview-1.1.9c/transferRGBBox.hxx0000644000076500007650000001050607653236517017374 0ustar talbottalbot00000000000000/* * $Id: transferRGBBox.hxx,v 4.0 2003/04/28 14:40:15 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A subclass of Box which is used for brightness/contrast/etc. * This is a superclass for the actually interesting ones. * * * Hugues Talbot 3 May 1998 * *-----------------------------------------------------------------------*/ #ifndef RGBTRANSFERBOX_H #define RGBTRANSFERBOX_H #include #include #include #include "imview.hxx" class myTransferRGBBox : public Fl_Box { private: bool hasReleaseOccured; unsigned char RGBmap[3][256]; virtual void trueRedrawHook() { } // called when the main window is also redrawn void findRGBExtremes(double x0[3], double y0[3], double x1[3], double y1[3], double startX[3], double startY[3], double endX[3], double endY[3]); double currContrast[3]; double currBrightness[3]; double currGamma[3]; double gammas[3], leftX[3], leftY[3], rightX[3], rightY[3]; protected: void draw(); // I'm expecting to have to subclass this void computeRGBEndPoints(double x0[3], double y0[3], double x1[3], double y1[3]); void buildRGBFunction(double x0[3], double y0[3], double x1[3], double y13[3]); public: myTransferRGBBox(int x, int y, int w, int h, const char *l=0) : Fl_Box(x,y,w,h,l) { hasReleaseOccured = false; } myTransferRGBBox(uchar b, int x, int y, int w, int h, const char *l) : Fl_Box(x,y,w,h,l) { hasReleaseOccured = false; } ~myTransferRGBBox(); // standard resize virtual void resize(int x,int y,int w, int h) { dbgprintf("TransferRGBBox %p: resized to (%dx%d+%d+%d)\n", this,w,h,x,y); Fl_Box::resize(x,y,w,h); } void setRGBParms(double contrast[3], double bright[3], double gamma[3]); void getRGBParms(double &RC, double &RB, double &RG, double &GC, double &GB, double &GG, double &BC, double &BB, double &BG) { RC = currContrast[0]; RB = currBrightness[0] ; RG = currGamma[0]; GC = currContrast[1]; GB = currBrightness[1] ; GG = currGamma[1]; BC = currContrast[2]; BB = currBrightness[2] ; BG = currGamma[2]; } void causeMainWindowRedraw(); void forceBuildMap() { double x0[3], y0[3], x1[3], y1[3]; x0[0] = y0[0] = x1[0] = y1[0] = 0.0; x0[1] = y0[1] = x1[1] = y1[1] = 0.0; x0[2] = y0[2] = x1[2] = y1[2] = 0.0; computeRGBEndPoints(x0, y0, x1, y1); buildRGBFunction(x0, y0, x1, y1); } void setRelease(bool s) { hasReleaseOccured = s;} // gammas double getCurrGamma(int i) {return currGamma[i];} // double getCurrBrightness(int i) {return currBrightness[i];} // double getCurrRContrast(int i) {return currContrast[i];} }; #endif // RGBTRANSFERBOX_H imview-1.1.9c/transferRGBFunction.cxx0000644000076500007650000005301607653236517020427 0ustar talbottalbot00000000000000/* * $Id: transferRGBFunction.cxx,v 4.0 2003/04/28 14:40:15 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The long-awaited RGB contrast/brightness/gamma control panel * * Hugues Talbot 30 Oct 2001 * *-----------------------------------------------------------------------*/ #include #include #include #include #include "imview.hxx" #include "imageIO.hxx" #include "transferFunction.hxx" #include "transferRGBFunction.hxx" extern imageIO *IOBlackBox; extern transferRGB *transferRGBEditorPanel; extern int applyTransferToAll; extern double persistentGamma; transferRGB::transferRGB() { dbgprintf("RGB Transfer function dialog created\n"); RGBtransferWindow = 0; // fluid depends on that. RGBtransferBox = 0; transferRGBHistoBox = 0; transferRGBFunctionBox = 0; return; } transferRGB::~transferRGB() { if (transferRGBHistoBox != 0) { delete transferRGBHistoBox; transferRGBHistoBox = 0; } return; } void transferRGB::setDefaults() { static char buff[100]; static const Fl_Menu_Item displayMenu[] = { {"RGB Transfer function", 0, (Fl_Callback *)RGBchosendisplay_cb, (void *)TRANSFER_DSP}, {"RGB Histogram", 0, (Fl_Callback *)RGBchosendisplay_cb, (void *)HISTOGRAM_DSP}, {0} }; dbgprintf("Setting up defaults for RGB transfer panel\n"); displayChoice->menu(displayMenu); // set up sliders array (they've been allocated by now) contrastSliders[0] = RcontrastSlider; contrastSliders[1] = GcontrastSlider; contrastSliders[2] = BcontrastSlider; brightnessSliders[0] = RbrightnessSlider; brightnessSliders[1] = GbrightnessSlider; brightnessSliders[2] = BbrightnessSlider; gammaSliders[0] = RgammaSlider; gammaSliders[1] = GgammaSlider; gammaSliders[2] = BgammaSlider; // button array linkButtons[0] = linkRButton; linkButtons[1] = linkGButton; linkButtons[2] = linkBButton; // inputs topInputs[0] = RtopInput; topInputs[1] = GtopInput; topInputs[2] = BtopInput; bottomInputs[0] = RbottomInput; bottomInputs[1] = GbottomInput; bottomInputs[2] = BbottomInput; leftInputs[0] = RleftInput; leftInputs[1] = GleftInput; leftInputs[2] = BleftInput; rightInputs[0] = RrightInput; rightInputs[1] = GrightInput; rightInputs[2] = BrightInput; gammaInputs[0] = RgammaInput; gammaInputs[1] = GgammaInput; gammaInputs[2] = BgammaInput; // set range, etc, for sliders... RcontrastSlider->minimum(-1.05); RcontrastSlider->maximum(1.0); RcontrastSlider->value(0.5); RcontrastSlider->step(0.005); GcontrastSlider->minimum(-1.05); GcontrastSlider->maximum(1.0); GcontrastSlider->value(0.5); GcontrastSlider->step(0.005); BcontrastSlider->minimum(-1.05); BcontrastSlider->maximum(1.0); BcontrastSlider->value(0.5); BcontrastSlider->step(0.005); // RbrightnessSlider->minimum(1.0); RbrightnessSlider->maximum(0); RbrightnessSlider->value(0.5); RbrightnessSlider->step(0.005); GbrightnessSlider->minimum(1.0); GbrightnessSlider->maximum(0); GbrightnessSlider->value(0.5); GbrightnessSlider->step(0.005); BbrightnessSlider->minimum(1.0); BbrightnessSlider->maximum(0); BbrightnessSlider->value(0.5); BbrightnessSlider->step(0.005); // RgammaSlider->minimum(1.0); RgammaSlider->maximum(-1.0); RgammaSlider->value(log(persistentGamma)); // this is what I mean by persistent RgammaSlider->step(0.01); GgammaSlider->minimum(1.0); GgammaSlider->maximum(-1.0); GgammaSlider->value(log(persistentGamma)); // this is what I mean by persistent GgammaSlider->step(0.01); BgammaSlider->minimum(1.0); BgammaSlider->maximum(-1.0); BgammaSlider->value(log(persistentGamma)); // this is what I mean by persistent BgammaSlider->step(0.01); // writing default gamma sprintf(buff, "%g", persistentGamma); RgammaInput->value(buff); GgammaInput->value(buff); BgammaInput->value(buff); // writing default parameters sprintf(buff, "255"); // top RtopInput->value(buff); GtopInput->value(buff); BtopInput->value(buff); // right RrightInput->value(buff); GrightInput->value(buff); BrightInput->value(buff); sprintf(buff, "0"); // bottom RbottomInput->value(buff); GbottomInput->value(buff); BbottomInput->value(buff); // left RleftInput->value(buff); GleftInput->value(buff); BleftInput->value(buff); // link all sliders by default linkRButton->set(); linkGButton->set(); linkBButton->set(); // allocate and set the parameters of the histobox; if (transferRGBHistoBox == 0) { int x,y,w,h; x = RGBtransferBox->x(); y = RGBtransferBox->y(); w = RGBtransferBox->w(); h = RGBtransferBox->h(); // same dimensions transferRGBHistoBox = new myTransferRGBHistoBox(x,y,w,h); // same box transferRGBHistoBox->box(RGBtransferBox->box()); // same colour transferRGBHistoBox->color(RGBtransferBox->color()); // same user data transferRGBHistoBox->user_data((void *)this); } if (transferRGBFunctionBox == 0) { int x,y,w,h; x = RGBtransferBox->x(); y = RGBtransferBox->y(); w = RGBtransferBox->w(); h = RGBtransferBox->h(); // same dimensions transferRGBFunctionBox = new myTransferRGBFunctionBox(x,y,w,h); // same box transferRGBFunctionBox->box(RGBtransferBox->box()); // same colour transferRGBFunctionBox->color(RGBtransferBox->color()); // same user data transferRGBFunctionBox->user_data((void *)this); } // replace the generic transferBox by the one we want displayBoxGroup->remove(RGBtransferBox); displayBoxGroup->add(transferRGBFunctionBox); RGBmemoryBox = RGBtransferBox; // the one allocated by fluid, we don't want it. // but we can't delete it... RGBtransferBox = transferRGBFunctionBox; setDrawingParms(); if (persistentGamma != 1.0) { dbgprintf("Forcing the recalculation of the transfer map \n"); RGBtransferBox->forceBuildMap(); dbgprintf("Forcing redisplay of the main image \n"); RGBtransferBox->causeMainWindowRedraw(); // force the recalculation of the map LUT } return; } void transferRGB::setTransfer() { if (RGBtransferBox == transferRGBHistoBox) { displayBoxGroup->remove(transferRGBHistoBox); displayBoxGroup->add(transferRGBFunctionBox); RGBtransferBox = transferRGBFunctionBox; } // copy the changes in parameters that may have // occured with the other type of display... setDrawingParms(); RGBtransferWindow->redraw(); } void transferRGB::setHisto() { if (RGBtransferBox == transferRGBFunctionBox) { displayBoxGroup->remove(transferRGBFunctionBox); displayBoxGroup->add(transferRGBHistoBox); RGBtransferBox = transferRGBHistoBox; } // copy the changes in parameters that may have // occured with the other type of display... setDrawingParms(); transferRGBHistoBox->makeHisto(); RGBtransferWindow->redraw(); } // compute the drawing parms from the Input (top,bottom, etc) values. void transferRGB::computeDrawingParms() { int topv, bottomv, rightv, leftv; double newbrightness = 0.5, newcontrast = 0.5; for (int i = 0 ; i < 3 ; ++i) { topv = atoi(topInputs[i]->value()); bottomv = atoi(bottomInputs[i]->value()); rightv = atoi(rightInputs[i]->value()); leftv = atoi(leftInputs[i]->value()); if (topv < 0) { topv = 0; topInputs[i]->value("0"); } if (topv > 255) { topv = 255; topInputs[i]->value("255"); } if (bottomv < 0) { bottomv = 0; bottomInputs[i]->value("0"); } if (bottomv > 255) { bottomv = 255; bottomInputs[i]->value("255"); } if (leftv < 0) { leftv = 0; leftInputs[i]->value("0"); } if (leftv > 255) { leftv = 255; leftInputs[i]->value("255"); } if (rightv < 0) { rightv = 0; rightInputs[i]->value("0"); } if (rightv > 255) { rightv = 255; rightInputs[i]->value("255"); } if ((leftv == 0) && (rightv == 255)) { if (topv > bottomv) { newcontrast = atan(255.0/((double)topv-bottomv))*2.0/M_PI; newbrightness = ((double)topv+bottomv)/(2*255.0); } } else if ((leftv == 255) && (rightv == 0)) { if ( topv > bottomv) { newcontrast = atan(-255.0/((double)topv-bottomv))*2.0/M_PI; newbrightness = ((double)topv+bottomv)/(2*255.0); } } else { newcontrast = atan((double)(rightv-leftv)/(255.0))*2.0/M_PI; if (rightv > leftv) newbrightness = (255.0 - 2*leftv)/(2*((double)rightv - leftv)); else if (leftv > rightv) newbrightness = (255.0 - 2*leftv)/(2*((double)leftv -rightv)); else newbrightness = 0.5; // doesnt' matter. } //newcontrast = floor(newcontrast*200.0)/200.0; // to get the expected precision //newbrightness = floor(newbrightness*200.0)/200.0; dbgprintf("%d: Brightness: %g, Contrast: %g\n", i, newbrightness, newcontrast); contrastSliders[i]->value(newcontrast); brightnessSliders[i]->value(newbrightness); } setDrawingParms(); RGBtransferWindow->redraw(); // this doesn't seem to work. Why? // ensureImageRedraw(true); return; } void transferRGB::setDrawingParms() { double c[3], b[3], g[3]; c[0] = RcontrastSlider->value(); c[1] = GcontrastSlider->value(); c[2] = BcontrastSlider->value(); b[0] = RbrightnessSlider->value(); b[1] = GbrightnessSlider->value(); b[2] = BbrightnessSlider->value(); g[0] = atof(RgammaInput->value()); g[1] = atof(GgammaInput->value()); g[2] = atof(BgammaInput->value()); RGBtransferBox->setRGBParms(c,b,g); return; } void transferRGB::redrawWindowIfNeeded() { if (RGBtransferWindow->visible()) { dbgprintf("Forcing the recalculation of the map LUT\n"); RGBtransferBox->forceBuildMap(); RGBtransferWindow->redraw(); // force the recalculation of the map LUT } return; } void transferRGB::show() { RGBtransferWindow->show(); } void transferRGB::hide() { RGBtransferWindow->hide(); } void transferRGB::setTopValue(int t[3]) { char cval[10]; dbgprintf("Top values being set to %d,%d,%d\n", t[0],t[1],t[2]); sprintf(cval, "%d", t[0]); RtopInput->value(cval); sprintf(cval, "%d", t[1]); GtopInput->value(cval); sprintf(cval, "%d", t[2]); BtopInput->value(cval); return; } void transferRGB::setBottomValue(int t[3]) { char cval[10]; dbgprintf("Bottom values being set to %d,%d,%d\n", t[0],t[1],t[2]); sprintf(cval, "%d", t[0]); RbottomInput->value(cval); sprintf(cval, "%d", t[1]); GbottomInput->value(cval); sprintf(cval, "%d", t[2]); BbottomInput->value(cval); return; } void transferRGB::setLeftValue(int t[3]) { char cval[10]; dbgprintf("Left values being set to %d,%d,%d\n", t[0],t[1],t[2]); sprintf(cval, "%d", t[0]); RleftInput->value(cval); sprintf(cval, "%d", t[1]); GleftInput->value(cval); sprintf(cval, "%d", t[2]); BleftInput->value(cval); return; } void transferRGB::setRightValue(int t[3]) { char cval[10]; dbgprintf("Right values being set to %d,%d,%d\n", t[0],t[1],t[2]); sprintf(cval, "%d", t[0]); RrightInput->value(cval); sprintf(cval, "%d", t[1]); GrightInput->value(cval); sprintf(cval, "%d", t[2]); BrightInput->value(cval); return; } // returns the index of the slider argument (0 for Red, 1 for green, etc) int transferRGB::identifySlider(Fl_Slider *aSlider) { int i; for (i = 0 ; i < 3 ; ++i) { if ((aSlider == contrastSliders[i]) || (aSlider == brightnessSliders[i]) || (aSlider == gammaSliders[i])) break; } assert(i < 3); return i; } // same thing for inputs int transferRGB::identifyInput(Fl_Input *anInput) { int i; for (i = 0 ; i < 3 ; ++i) { if ((anInput == gammaInputs[i]) || (anInput == topInputs[i]) || (anInput == bottomInputs[i]) || (anInput == leftInputs[i]) || (anInput == rightInputs[i])) break; } assert(i < 3); return i; } // link generic sliders void transferRGB::linkSliders(Fl_Slider *sliderKind[3], int withId, double v) { if (linkButtons[withId]->value()) { for (int i = 1 ; i <= 2 ; ++i) { int nextId = (withId + i) % 3; if (linkButtons[nextId]->value()) sliderKind[nextId]->value(v); // adjust value } } } // link generic inputs void transferRGB::linkInputs(Fl_Input *inputKind[3], int withId, char *v) { if (linkButtons[withId]->value()) { for (int i = 1 ; i <= 2 ; ++i) { int nextId = (withId + i) % 3; if (linkButtons[nextId]->value()) inputKind[nextId]->value(v); // adjust value } } } // callbacks associated with objects on the dialog void RGBchosendisplay_cb(Fl_Menu_ *, void *value) { long val = (long)value; switch (val) { case TRANSFER_DSP: transferRGBEditorPanel->setTransfer(); break; case HISTOGRAM_DSP: transferRGBEditorPanel->setHisto(); break; default: errprintf("Unknown value from choice menu: %d\n", val); break; } return; } // callbacks associated with this dialog void brightnessslider_cb(Fl_Slider *theSlider, transferRGB *panel) { dbgprintf("Brightness slider callback\n"); // link sliders double v = theSlider->value(); int sliderId = panel->identifySlider(theSlider); panel->linkBrightnessSliders(sliderId, v); if (Fl::pushed() == 0) { dbgprintf("Button Released!\n"); panel->ensureImageRedraw(true); } panel->setDrawingParms(); return; } void contrastslider_cb(Fl_Slider *theSlider, transferRGB *panel) { dbgprintf("Contrast slider callback\n"); // link sliders double v = theSlider->value(); int sliderId = panel->identifySlider(theSlider); panel->linkContrastSliders(sliderId, v); if (Fl::pushed() == 0) { dbgprintf("Button Released!\n"); panel->ensureImageRedraw(true); } panel->setDrawingParms(); return; } void displaychoice_cb(Fl_Choice*, transferRGB*) { dbgprintf("Display choice callback\n"); } void gammainput_cb(Fl_Float_Input *theInput, transferRGB *panel) { double eval, val; const char *cval; dbgprintf("Gamma input callback\n"); int inputId = panel->identifyInput(theInput); cval = theInput->value(); eval = atof(cval); if (eval > 0) { val = log(eval); } else { char cval[10]; val = -1; sprintf(cval,"%1.4g", exp(-1)); switch(inputId) { case 0: panel->setRGammaInputValue((const char *)cval); break; case 1: panel->setGGammaInputValue((const char *)cval); break; case 3: panel->setRGammaInputValue((const char *)cval); break; } } switch (inputId) { case 0: panel->setRGammaSliderValue((float)val); break; case 1: panel->setGGammaSliderValue((float)val); break; case 2: panel->setBGammaSliderValue((float)val); break; } panel->ensureImageRedraw(true); panel->setDrawingParms(); return; } void gammaslider_cb(Fl_Slider *theSlider, transferRGB *panel) { double val, eval; char cval[20]; dbgprintf("Gamma slider callback\n"); if (Fl::pushed() == 0) { dbgprintf("Button Released!\n"); panel->ensureImageRedraw(true); } // link sliders val = theSlider->value(); int sliderId = panel->identifySlider(theSlider); eval = exp(val); sprintf(cval, "%1.4g", eval); // link the sliders panel->linkGammaSliders(sliderId, val); // the slider ID and the input ID should be the same panel->setGammaInputValue(sliderId, cval); panel->linkGammaInputs(sliderId, cval); panel->setDrawingParms(); return; } void bottominput_cb(Fl_Int_Input *theInput, transferRGB *panel) { panel->ensureImageRedraw(true); panel->computeDrawingParms(); return; } void topinput_cb(Fl_Int_Input *theInput, transferRGB *panel) { dbgprintf("Top input callback\n"); panel->ensureImageRedraw(true); panel->computeDrawingParms(); return; } void leftinput_cb(Fl_Int_Input *theInput, transferRGB *panel) { panel->ensureImageRedraw(true); panel->computeDrawingParms(); return; } void rightinput_cb(Fl_Int_Input *theInput, transferRGB *panel) { panel->ensureImageRedraw(true); panel->computeDrawingParms(); return; } void selectchannel_cb(Fl_Button *, transferRGB *panel) { panel->redrawBox(); return; } void resetbutton_cb(Fl_Button*, transferRGB *panel) { char buf[100]; int resetR, resetG, resetB; // this is very simple... dbgprintf("Reset button pressed\n"); // asks which channels to affect panel->affectChannels(resetR, resetG, resetB); panel->ensureImageRedraw(true); // ensures a redraw sprintf(buf, "%g", persistentGamma); if (resetR) { panel->setRGammaInputValue(buf); panel->setRGammaSliderValue(0); panel->setRContrastSliderValue(0.5); panel->setRBrightnessSliderValue(0.5); } if (resetG) { panel->setGGammaInputValue(buf); panel->setGGammaSliderValue(0); panel->setGContrastSliderValue(0.5); panel->setGBrightnessSliderValue(0.5); } if (resetB) { panel->setBGammaInputValue(buf); panel->setBGammaSliderValue(0); panel->setBContrastSliderValue(0.5); panel->setBBrightnessSliderValue(0.5); } panel->setDrawingParms(); // compute input values from slider values panel->computeDrawingParms(); return; } void normalisebutton_cb(Fl_Button*, transferRGB *panel) { int spp, val, minval, maxval; long nbpix; unsigned char *p, *end; double slope, startp; int normR, normG, normB; char buf[100]; // asks which channels to affect panel->affectChannels(normR, normG, normB); panel->ensureImageRedraw(true); // we want the result to be shown on the image nbpix = IOBlackBox->imageWidth() * IOBlackBox->imageHeight(); spp = IOBlackBox->imageDepth(); maxval = 0; minval = 255; if (spp == 1) { p = IOBlackBox->imageData(); end = p + nbpix; while (p != end) { if (*p > maxval) maxval = *p; if (*p < minval) minval = *p; p++; } } else if (spp == 3) { p = IOBlackBox->imageData(); end = p + spp * nbpix; // we only include in the calculation the channels // to be normalized while (p != end) { if (normR) { val = *p++; if (val > maxval) maxval = val; if (val < maxval) minval = val; } else { p++; // red pixels ignored in calculation } if (normG) { val = *p++; if (val > maxval) maxval = val; if (val < maxval) minval = val; } else { p++; // green pixels ignored } if (normB) { val = *p++; if (val > maxval) maxval = val; if (val < maxval) minval = val; } else { p++; // blue pixels ignored } } } dbgprintf("Min val:%d, max val: %d\n", minval, maxval); // now compute the slope parameters, etc if (maxval != minval) slope = 2*atan(255.0/(maxval-minval))/M_PI; else slope = 1; startp = ((double)maxval+minval)/(512); // this is now pretty simple... sprintf(buf, "%g", persistentGamma); if (normR) { panel->setRGammaInputValue(buf); panel->setRGammaSliderValue(0); panel->setRContrastSliderValue(slope); panel->setRBrightnessSliderValue(startp); } if (normG) { panel->setGGammaInputValue(buf); panel->setGGammaSliderValue(0); panel->setGContrastSliderValue(slope); panel->setGBrightnessSliderValue(startp); } if (normB) { panel->setBGammaInputValue(buf); panel->setBGammaSliderValue(0); panel->setBContrastSliderValue(slope); panel->setBBrightnessSliderValue(startp); } panel->setDrawingParms(); panel->computeDrawingParms(); return; } void applytoallbutton_cb(Fl_Check_Button *b, transferRGB *panel) { applyTransferToAll = b->value(); switch (applyTransferToAll) { case 0: dbgprintf("Will apply transfer function only to currently displayed image\n"); break; default: dbgprintf("Will apply transfer function to all image/components, etc\n"); break; } return; } void okbutton_cb(Fl_Return_Button*, transferRGB *panel) { // this is very simple... panel->hide(); } imview-1.1.9c/transferRGBFunction.hxx0000644000076500007650000001561107653236520020425 0ustar talbottalbot00000000000000/* * $Id: transferRGBFunction.hxx,v 4.0 2003/04/28 14:40:16 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * The long-awaited RGB contrast/brightness/gamma panel for RGB data * * Hugues Talbot 27 Oct 2001 * * *-----------------------------------------------------------------------*/ #ifndef RGBTRANSFERFUNCTION_H #define RGBTRANSFERFUNCTION_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "transferRGBFunctionBox.hxx" #include "transferRGBHistoBox.hxx" #include "transferRGBBox.hxx" //#include "transferHistoBox.hxx" void RGBchosendisplay_cb(Fl_Menu_ *, void *); class transferRGB { public: transferRGB(); ~transferRGB(); void setDefaults(); void computeDrawingParms(); void setDrawingParms(); void redrawWindowIfNeeded(); void show(); void hide(); // void setRGammaSliderValue(float val) {RgammaSlider->value(val);} void setGGammaSliderValue(float val) {GgammaSlider->value(val);} void setBGammaSliderValue(float val) {BgammaSlider->value(val);} // void setRGammaInputValue(const char *c) {RgammaInput->value(c);} void setGGammaInputValue(const char *c) {GgammaInput->value(c);} void setBGammaInputValue(const char *c) {BgammaInput->value(c);} void setGammaInputValue(int i, const char *c) {assert((i>=0) && (i < 3)); gammaInputs[i]->value(c);} // void setRContrastSliderValue(float val) {RcontrastSlider->value(val);} void setGContrastSliderValue(float val) {GcontrastSlider->value(val);} void setBContrastSliderValue(float val) {BcontrastSlider->value(val);} // void setRBrightnessSliderValue(float val) {RbrightnessSlider->value(val);} void setGBrightnessSliderValue(float val) {GbrightnessSlider->value(val);} void setBBrightnessSliderValue(float val) {BbrightnessSlider->value(val);} // returns which R G & B buttons have been toggled void affectChannels(int &R, int &G, int &B) { R = Rselect->value(); G = Gselect->value(); B = Bselect->value(); } void redrawBox(void) { RGBtransferBox->redraw();// redraw the current transfer function or histogram } // help identify which slider is being modified int identifySlider(Fl_Slider *aSlider); int identifyInput(Fl_Input *anInput); void linkBrightnessSliders(int withId, double v) {linkSliders(brightnessSliders,withId,v);} void linkContrastSliders(int withId, double v) {linkSliders(contrastSliders,withId,v);} void linkGammaSliders(int withId, double v) {linkSliders(gammaSliders,withId,v);} void linkGammaInputs(int withId, char *v) {linkInputs((Fl_Input**)gammaInputs,withId,v);} // void setTopValue(int t[3]); void setBottomValue(int t[3]); void setLeftValue(int t[3]); void setRightValue(int t[3]); void setTransfer(); void setHisto(); void getParameters(double &theRGamma, double &theGGamma, double &theBGamma, double &theRContrast, double &theGContrast, double &theBContrast, double &theRBrightness, double &theGBrightness, double &theBBrightness) { RGBtransferBox->getRGBParms(theRContrast, theRBrightness, theRGamma, theGContrast, theGBrightness, theGGamma, theBContrast, theBBrightness, theBGamma); } void ensureImageRedraw(bool s) { RGBtransferBox->setRelease(s); } friend Fl_Double_Window *RGB_transfer_panel(transferRGB &s); private: // Fluid-defined Fl_Double_Window *RGBtransferWindow; Fl_Group *displayBoxGroup; Fl_Choice *displayChoice; Fl_Float_Input *RgammaInput, *GgammaInput, *BgammaInput; Fl_Int_Input *RtopInput, *RbottomInput, *RleftInput, *RrightInput; Fl_Int_Input *GtopInput, *GbottomInput, *GleftInput, *GrightInput; Fl_Int_Input *BtopInput, *BbottomInput, *BleftInput, *BrightInput; myTransferRGBBox *RGBtransferBox, *RGBmemoryBox; myTransferRGBHistoBox *transferRGBHistoBox; myTransferRGBFunctionBox *transferRGBFunctionBox; Fl_Slider *RcontrastSlider, *GcontrastSlider, *BcontrastSlider; Fl_Slider *RbrightnessSlider, *GbrightnessSlider, *BbrightnessSlider; Fl_Slider *RgammaSlider, *GgammaSlider, *BgammaSlider; Fl_Button *resetButton, *normaliseButton; Fl_Button *Rselect, *Gselect, *Bselect; Fl_Round_Button *linkRButton, *linkGButton, *linkBButton; Fl_Check_Button *applyToAllButton; Fl_Return_Button *OKButton; // management Fl_Slider *contrastSliders[3], *brightnessSliders[3], *gammaSliders[3]; Fl_Round_Button *linkButtons[3]; Fl_Int_Input *topInputs[3], *bottomInputs[3], *leftInputs[3], *rightInputs[3]; Fl_Float_Input *gammaInputs[3]; void linkSliders(Fl_Slider *sliderKind[3], int withId, double v); void linkInputs(Fl_Input *inputKind[3], int withId, char *value); }; #endif // RGBTRANSFERFUNCTION_H imview-1.1.9c/transferRGBFunctionBox.cxx0000644000076500007650000001151007653236521021064 0ustar talbottalbot00000000000000/* * $Id: transferRGBFunctionBox.cxx,v 4.0 2003/04/28 14:40:17 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A subclass of Box for drawing transfer functions * * Hugues Talbot 3 May 1998 * *-----------------------------------------------------------------------*/ #include #include "imview.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "transferBox.hxx" #include "transferRGBFunction.hxx" #include "transferRGBFunctionBox.hxx" extern imageIO *IOBlackBox; extern imageViewer *mainViewer; extern transferRGB *transferRGBEditorPanel; void myTransferRGBFunctionBox::draw() { int startX, startY, endX, endY, inc; double x0[3], y0[3], x1[3], y1[3], swapd; // these are normally between 0 and 1 int w0, h0; int xa, ya, xb, yb; // call the superclass' draw routine. myTransferRGBBox::draw(); computeRGBEndPoints(x0, y0, x1, y1); // this returns the End points. fl_push_no_clip(); //fl_clip(x(),y(),w(),h()); for (int i = 0 ; i < 3 ; ++i) { //fl_clip(x(),y(),w(),h()); switch (i) { case 0: fl_color(FL_RED); break; case 1: fl_color(FL_GREEN); break; case 2: fl_color(FL_BLUE); break; } inc = 1; if (x0[i] > x1[i] || y0[i] > y1[i]) { // negative contrast swapd = x1[i]; x1[i] = x0[i]; x0[i] = swapd; if (y0[i] > 1) { startX = (int)(x0[i]*(w()-1)); startY = 0; } else { startX = 0; startY = (int)((h()-1)*(1-y0[i])); } if (y1[i] > 0) { endX = w()-1; endY = (int)((h()-1)*(1-y1[i])); } else { endX = (int)(x1[i]*(w()-1)); endY = h()-1; } dbgprintf("Start: (%d, %d) ; end: (%d, %d)\n", startX, startY, endX, endY); w0 = endX - startX; h0 = startY - endY; // h is inverted... xa = 0; ya = 0; if (w0 != 0) { for (xb = startX; xb <= endX ; xb += inc) { //yb = startY - (xb-startX)*h0/w0; yb = (int)(startY - h0*pow(((double)xb-startX)/w0,1/getCurrGamma(i))); fl_line(xa+x(), ya+y(), xb+x(),yb+y()); xa = xb; ya = yb; } } else { fl_line(x(), y()+h()-1, startX+x(), y()+h()-1); fl_line(startX+x(), startY+y(), endX+x(), endY+y()); xa = endX; ya = endY; } // finish the path fl_line(xa+x(), ya+y(), w()-1+x(), y()+h()-1); } else { if (y0[i] < 0) { startX = (int)(x0[i]*(w()-1)); startY = h()-1; } else { startX = 0; startY = (int)((h()-1)*(1-y0[i])); } if (y1[i] <= 1) { endX = w()-1; endY = (int)((h()-1)*(1-y1[i])); } else { endX = (int)(x1[i]*(w()-1)); endY = 0; } dbgprintf("Start: (%d, %d) ; end: (%d, %d)\n", startX, startY, endX, endY); w0 = endX - startX; h0 = startY - endY; // h is inverted... xa = 0; ya = h()-1; if (w0 != 0) { for (xb = startX; xb <= endX ; xb += inc) { //yb = startY - (xb-startX)*h0/w0; yb = (int)(startY - h0*pow(((double)xb-startX)/w0,1/getCurrGamma(i))); fl_line(xa+x(), ya+y(), xb+x(),yb+y()); xa = xb; ya = yb; } } else { fl_line(x(), y()+h()-1, startX+x(), y()+h()-1); fl_line(startX+x(), startY+y(), endX+x(), endY+y()); xa = endX; ya = endY; } // finish the path fl_line(xa+x(), ya+y(), w()-1+x(), y()); } } fl_pop_clip(); return; } imview-1.1.9c/transferRGBFunctionBox.hxx0000644000076500007650000000772607653236522021110 0ustar talbottalbot00000000000000/* * $Id: transferRGBFunctionBox.hxx,v 4.0 2003/04/28 14:40:18 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A subclass of Box which is used for brightness/contrast/etc. * This is a superclass for the actually interesting ones. * * * Hugues Talbot 3 May 1998 * *-----------------------------------------------------------------------*/ #ifndef TRANSFER_RGB_FUNCTIONBOX_H #define TRANSFER_RGB_FUNCTIONBOX_H #include #include #include #include "transferRGBBox.hxx" class myTransferRGBFunctionBox : public myTransferRGBBox { private: unsigned char Rmap[256], Gmap[256], Bmap[256]; double currRContrast, currGContrast, currBContrast; double currRBrightness, currGBrightness, currBBrightness; double currRGamma, currGGamma, currBGamma; protected: void draw(); // I'm expecting to have to subclass this public: myTransferRGBFunctionBox(int x, int y, int w, int h, const char *l=0) : myTransferRGBBox(x,y,w,h,l) { } myTransferRGBFunctionBox(uchar b, int x, int y, int w, int h, const char *l) : myTransferRGBBox(x,y,w,h,l) { } void setRGBParms(float Rcontrast, float Rbrightness, float Rgamma, float Gcontrast, float Gbrightness, float Ggamma, float Bcontrast, float Bbrightness, float Bgamma); void getRGBParms(float &Rcontrast, float &Rbrightness, float &Rgamma, float &Gcontrast, float &Gbrightness, float &Ggamma, float &Bcontrast, float &Bbrightness, float &Bgamma) { Rcontrast = (float)currRContrast; Rbrightness = (float)currRBrightness ; Rgamma = (float)currRGamma; Gcontrast = (float)currGContrast; Gbrightness = (float)currGBrightness ; Rgamma = (float)currGGamma; Bcontrast = (float)currBContrast; Bbrightness = (float)currBBrightness ; Rgamma = (float)currBGamma; } // gammas double getCurrRGamma(void ) {return currRGamma;} double getCurrGGamma(void ) {return currGGamma;} double getCurrBGamma(void ) {return currBGamma;} // double getCurrRBrightness(void) {return currRBrightness;} double getCurrGBrightness(void) {return currGBrightness;} double getCurrBBrightness(void) {return currBBrightness;} // double getCurrRContrast(void) {return currRContrast;} double getCurrGContrast(void) {return currGContrast;} double getCurrBContrast(void) {return currBContrast;} }; #endif // TRANSFER_RGB_FUNCTIONBOX_H imview-1.1.9c/transferRGBHistoBox.cxx0000644000076500007650000001024307653236524020372 0ustar talbottalbot00000000000000/* * $Id: transferRGBHistoBox.cxx,v 4.0 2003/04/28 14:40:20 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A subclass of Box for drawing transfer functions * * Hugues Talbot 3 May 1998 * *-----------------------------------------------------------------------*/ #include #include "imview.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "transferRGBFunction.hxx" #include "transferRGBFunctionBox.hxx" #include "transferRGBHistoBox.hxx" extern imageIO *IOBlackBox; extern imageViewer *mainViewer; extern transferRGB *transferRGBEditorPanel; void myTransferRGBHistoBox::makeHisto() { int i, spp, val; long nbpix; unsigned char *p, *end; for (i = 0 ; i < 256 ; i++) { theRGBHisto[i][0] = 0; theRGBHisto[i][1] = 0; theRGBHisto[i][2] = 0; } nbpix = IOBlackBox->imageWidth() * IOBlackBox->imageHeight(); spp = IOBlackBox->imageDepth(); if (spp == 1) { p = IOBlackBox->imageData(); end = p + nbpix; while (p != end) { val = *p++; theRGBHisto[val][0]++; // simple. theRGBHisto[val][1]++; theRGBHisto[val][2]++; } } else if (spp == 3) { // we need to be a bit more conservative with colour p = IOBlackBox->imageData(); end = p + spp * nbpix; while (p != end) { theRGBHisto[*p++][0]++; // simple as well. theRGBHisto[*p++][1]++; theRGBHisto[*p++][2]++; } } maxval = 0; for (i = 0 ; i < 256 ; i++) { for (int j = 0 ; j < 3 ; ++j) { if (theRGBHisto[i][0] > maxval) maxval= theRGBHisto[i][0]; if (theRGBHisto[i][1] > maxval) maxval= theRGBHisto[i][1]; if (theRGBHisto[i][2] > maxval) maxval= theRGBHisto[i][2]; } } dbgprintf("Max val in histo: %d\n", maxval); return; } void myTransferRGBHistoBox::draw() { double x0[3], y0[3], x1[3], y1[3]; int xx; int drawChannel[3]; // call the superclass' draw routine myTransferRGBBox::draw(); computeRGBEndPoints(x0, y0, x1, y1); // this fills the x?,y? // find out which channels should be drawn transferRGBEditorPanel->affectChannels(drawChannel[0], drawChannel[1], drawChannel[2]); fl_clip(x(),y(),w(),h()); for (int j = 0 ; j < 3 ; ++j) { if (!drawChannel[j]) continue; // skip that channel switch(j) { case 0: fl_color(FL_RED); break; case 1: fl_color(FL_GREEN); break; case 2: fl_color(FL_BLUE); break; } for (int i = 0 ; i < w() ; i++) { xx = (int)((double)i * 256 / w()); fl_line(x()+i, y()+h()-1, x()+i, y()+h()-(int)((double)theRGBHisto[xx][j]*h()/maxval)); } } fl_pop_clip(); return; } imview-1.1.9c/transferRGBHistoBox.hxx0000644000076500007650000000522107653236525020400 0ustar talbottalbot00000000000000/* * $Id: transferRGBHistoBox.hxx,v 4.0 2003/04/28 14:40:21 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A subclass of Box which is used for brightness/contrast/etc. * This is a superclass for the actually interesting ones. * * * Hugues Talbot 3 May 1998 * *-----------------------------------------------------------------------*/ #ifndef TRANSFER_RGB_HISTOBOX_H #define TRANSFER_RGB_HISTOBOX_H #include #include #include #include "transferBox.hxx" class myTransferRGBHistoBox : public myTransferRGBBox { private: long theRGBHisto[256][3], maxval; void trueRedrawHook() {makeHisto();} // supercede the superclass' definition protected: void draw(); // I'm expecting to have to subclass this public: myTransferRGBHistoBox(int x, int y, int w, int h, const char *l=0) : myTransferRGBBox(x,y,w,h,l) { } myTransferRGBHistoBox(uchar b, int x, int y, int w, int h, const char *l) : myTransferRGBBox(x,y,w,h,l) { } void makeHisto(); }; #endif // TRANSFER_RGB_HISTOBOX_H imview-1.1.9c/userPrefs.cxx0000644000076500007650000002714010065604376016510 0ustar talbottalbot00000000000000/* * $Id: userPrefs.cxx,v 4.5 2004/06/21 16:12:46 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A user preference panel using fluid. * * Hugues Talbot 18 Oct 1998 * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" #include #include #include #include #include #include #include "imview.hxx" #include "imageIO.hxx" #include "imageViewer.hxx" #include "nocase.hxx" #include "userPrefs.hxx" #include "io/newprefio.hxx" // some extern defs extern imprefs *fileprefs; extern imageViewer *mainViewer; extern imageIO *IOBlackBox; extern int debugIsOn; extern int stopDebug; extern char currentprefspath[]; using std::string; using std::ostringstream; // user preferences panel methods userprefs::userprefs() { dbgprintf("User preferences panel constructed\n"); userprefsWindow = 0; // fluid depends on that return; } void userprefs::setDefaults() { char dblval[20]; if (fileprefs != 0) { // general stuff pathToPrefsInput->value(fileprefs->prefspath()); if (fileprefs->smoothZoomout()) smoothWhenZoomoutButton->set(); else smoothWhenZoomoutButton->clear(); if (fileprefs->keepPoints()) keepPointsButton->set(); else keepPointsButton->clear(); if (fileprefs->mouseZoomType() == ZOOM_UNCONSTRAINED) { constrainZoomCheck->clear(); unconstrainZoomCheck->set(); } else { constrainZoomCheck->set(); unconstrainZoomCheck->clear(); } transparencyValueSlider->value(fileprefs->overlayTransparency()); // PS stuff pathToGsInput->value(fileprefs->gspath()); sprintf(dblval, "%d", (int)(fileprefs->psRenderRes())); renderInput->value(dblval); sprintf(dblval, "%d", (int)(fileprefs->psDisplayRes())); displayInput->value(dblval); // clear everything greyCheck->clear(); colourCheck->clear(); bwCheck->clear(); switch (fileprefs->psRenderDepth()) { case PSREND_GREY: greyCheck->set(); break; case PSREND_COLOUR: colourCheck->set(); break; default: bwCheck->set(); break; } if (fileprefs->psRenderSmooth()) smoothButton->set(); else smoothButton->clear(); if (fileprefs->psAntialiasRender()) antialiasButton->set(); else antialiasButton->clear(); boundingChoice->value(fileprefs->psBoundingBox()); // Server stuff sprintf(dblval, "%g", fileprefs->pollFrequency()); pollFrequencyInput->value(dblval); pollFrequencySlider->value(log(fileprefs->pollFrequency())/(2*log(10.0)) - 0.5); if (fileprefs->requirePassword()) securityPasswordButton->set(); else securityPasswordButton->clear(); if (fileprefs->localhostOnly()) securityLocalhostButton->set(); else securityLocalhostButton->clear(); // expert stuff if (fileprefs->hideMenu()) hideMenuButton->set(); else hideMenuButton->clear(); // Hack stuff xorValueBreakLineInput->value(fileprefs->xorBreakLines()); xorValueProfileLineInput->value(fileprefs->xorProfileLines()); } return; } // revert to saved void userprefs::revertPrefs() { fileprefs->readprefs(currentprefspath); } // save current. void userprefs::savePrefs() { fileprefs->writeprefs(pathToPrefsInput->value()); } void userprefs::show() { userprefsWindow->show(); return; } void userprefs::hide() { userprefsWindow->hide(); return; } // a hash string to find out if things have changed between PS renderings string userprefs::getPsPrefsHash() { ostringstream osm; if (userprefsWindow != NULL) { // a CSV string osm << pathToGsInput->value() << ',' << renderInput->value() << ',' << renderInput->value() << ',' << renderInput->value() << ',' << greyCheck->value() << ',' << bwCheck->value() << ',' << smoothButton->value() << ',' << antialiasButton->value() << ',' << boundingChoice->value(); } else osm << "Unknown"; return osm.str(); } // the callbacks // General tab void prefbrowse_cb(Fl_Button *, userprefs *panel) { dbgprintf("Preference file browse button callback\n"); return; } void smoothzoomout_cb(Fl_Round_Button *b, userprefs *panel) { dbgprintf("Smooth zoomout button callback\n"); if (b->value()) fileprefs->smoothZoomout(true); else fileprefs->smoothZoomout(false); return; } void keeppoints_cb(Fl_Round_Button *b, userprefs *panel) { dbgprintf("Keep points button callback\n"); if (b->value()) fileprefs->keepPoints(true); else fileprefs->keepPoints(false); return; } void constrainedzoom_cb(Fl_Check_Button *, userprefs *panel) { dbgprintf("Constrained check button callback\n"); fileprefs->mouseZoomType(ZOOM_CONSTRAINED); return; } void unconstrainedzoom_cb(Fl_Check_Button *, userprefs *panel) { dbgprintf("Unconstrained check button callback\n"); fileprefs->mouseZoomType(ZOOM_UNCONSTRAINED); return; } void transparency_cb(Fl_Value_Slider *s, userprefs *panel) { dbgprintf("Transparency value slider callback\n"); fileprefs->overlayTransparency(s->value()); //IOBlackBox->applyOverlayToCurrentImage(); IOBlackBox->applyImageParameters(0, 0, 0, true); mainViewer->displayCurrentImage(); // this should take the new transparency into account } // PS tab void pathtogsinput_cb(Fl_Input *s, userprefs *) { dbgprintf("Path to GS input callback\n"); fileprefs->gspath(s->value()); return; } void pathtogvinput_cb(Fl_Input *s, userprefs *) { dbgprintf("Path to Previewer input callback\n"); fileprefs->gvpath(s->value()); return; } void gsbrowse_cb(Fl_Button *, userprefs *panel) { dbgprintf("GS path browse button callback\n"); return; } void renderinput_cb(Fl_Int_Input *s, userprefs *) { dbgprintf("Rendering resolution input callback\n"); fileprefs->psRenderRes((double)(atof(s->value()))); return; } void displayinput_cb(Fl_Int_Input *s, userprefs *) { dbgprintf("Display resolution input callback\n"); fileprefs->psDisplayRes((double)(atof(s->value()))); return; } void colourcheck_cb(Fl_Check_Button *, userprefs *) { dbgprintf("Colour check button callback\n"); fileprefs->psRenderDepth(PSREND_COLOUR); return; } void greycheck_cb(Fl_Check_Button *, userprefs *) { dbgprintf("Grey check button callback\n"); fileprefs->psRenderDepth(PSREND_GREY); return; } void bwcheck_cb(Fl_Check_Button *, userprefs *) { dbgprintf("BW check button callback\n"); fileprefs->psRenderDepth(PSREND_BW); return; } void smoothbutton_cb(Fl_Round_Button *b, userprefs *) { dbgprintf("Smooth button callback\n"); if (b->value()) fileprefs->psRenderSmooth(true); else fileprefs->psRenderSmooth(false); return; } void aabutton_cb(Fl_Round_Button *b, userprefs *) { dbgprintf("Antialias button callback\n"); if (b->value()) fileprefs->psAntialiasRender(true); else fileprefs->psAntialiasRender(false); return; } void boundingchoice_cb(Fl_Choice *b, userprefs *) { dbgprintf("Bounding box choice callback with value %d\n", b->value()); fileprefs->psBoundingBox((page_size)(b->value())); return; } // Server Tab void pollslider_cb(Fl_Slider *s, userprefs *up) { double v, nv; dbgprintf("Poll frequency slider callback\n"); v = s->value(); nv = ceil(pow(10,2*v+1)); // update the input field accordingly up->setInputHz(nv); // tell the preference manager fileprefs->pollFrequency(nv); return; } void pollinput_cb(Fl_Float_Input *i, userprefs *up) { double v, nv; char cv[20]; dbgprintf("Poll frequency input callback\n"); v = atof(i->value()); if (v <= 1) { // we can cheat a little and enter low values v = 10; // 10 Hz only the official minimum sprintf(cv, "%g", v); i->value(cv); } else if (v > 5000) { // 5kHz maxi, this is pushing it... v = 1000; sprintf(cv, "%g", v); i->value(cv); } nv = log(v)/(2*log(10.0)) - 0.5; // do the computation yourself! // update the slider up->setSliderHz(nv); // tell the preference manager fileprefs->pollFrequency(nv); return; } void requirepassword_cb(Fl_Round_Button *b, userprefs *up) { dbgprintf("Require password callback\n"); if (b->value()) fileprefs->requirePassword(true); else fileprefs->requirePassword(false); return; } void localhostonly_cb(Fl_Round_Button *b, userprefs *up) { dbgprintf("local host only callback\n"); if (b->value()) fileprefs->localhostOnly(true); else fileprefs->localhostOnly(false); return; } // Expert tab void hidemenu_cb(Fl_Round_Button *b, userprefs *) { dbgprintf("hide menu callback\n"); if (b->value()) fileprefs->hideMenu(true); else fileprefs->hideMenu(false); return; } // Hack Tab void showdebug_cb(Fl_Round_Button *, userprefs *) { dbgprintf("Debug button callback\n"); debugIsOn = !debugIsOn; return; } void stopdebug_cb(Fl_Round_Button *, userprefs *) { dbgprintf("Stop button callback\n"); stopDebug = !stopDebug; return; } void xorbreakline_cb(Fl_Input *s, userprefs *) { dbgprintf("XOR break line callback\n"); fileprefs->xorBreakLines(s->value()); return; } void xorprofileline_cb(Fl_Input *s, userprefs *panel) { dbgprintf("XOR profile line callback\n"); fileprefs->xorProfileLines(s->value()); return; } // main buttons void cancelbutton_cb(Fl_Button *, userprefs *panel) { dbgprintf("Cancel Button pressed on user prefs panel\n"); // revert to saved prefs panel->revertPrefs(); // hide the window, do nothing panel->hide(); return; } void savebutton_cb(Fl_Button *, userprefs *panel) { dbgprintf("Save Button pressed on user prefs panel\n"); // do the preference savings. panel->savePrefs(); return; } void okbutton_cb(Fl_Return_Button *, userprefs *panel) { dbgprintf("OK Button pressed on print prefs panel\n"); panel->hide(); return; } imview-1.1.9c/userPrefs.hxx0000644000076500007650000001162210065530012016474 0ustar talbottalbot00000000000000/* * $Id: userPrefs.hxx,v 4.2 2004/06/21 09:53:14 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2001 by Hugues Talbot and was * supported in parts by the Australian Commonwealth Science and * Industry Research Organisation. Please see the COPYRIGHT file * for full details. Imview also includes the contributions of * many others. Please see the CREDITS file for full details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * A user preference class * * Interface with fluid-generated panel * * *-----------------------------------------------------------------------*/ #ifndef USERPREFS_H #define USERPREFS_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using std::string; class userprefs { public: userprefs(); void setDefaults(); void setDebug(int isDebugOn) { if (isDebugOn) showDebugMsgButton->set(); else showDebugMsgButton->clear(); } void setStopDebug(int isStopOn) { if (isStopOn) stopAfterDebugMsgButton->set(); else stopAfterDebugMsgButton->clear(); } void setInputHz(double v) { char buff[20]; sprintf(buff, "%g", v); pollFrequencyInput->value(buff); } void setSliderHz(double v) { pollFrequencySlider->value(v); } // access to private values const char *getGSPath(void) {return pathToGsInput->value();} const char *getPreviewerPath(void) {return pathToPSPreviewer->value();} const char *getRenderRes(void) {return renderInput->value();} const char *getDisplayRes(void) {return displayInput->value();} const char *getBreakXORValue(void) {return xorValueBreakLineInput->value();} const char *getProfileXORValue(void) {return xorValueProfileLineInput->value();} string getPsPrefsHash(void); void revertPrefs(); void savePrefs(); void show(); void hide(); friend Fl_Window *userprefs_panel(userprefs &s); private: // the dialog window Fl_Window *userprefsWindow; // tabs themselves Fl_Group *generalGroup; // General tab: Fl_Input *pathToPrefsInput; Fl_Button *prefBrowse; Fl_Round_Button *smoothWhenZoomoutButton, *keepPointsButton; Fl_Check_Button *constrainZoomCheck, *unconstrainZoomCheck; Fl_Value_Slider *transparencyValueSlider; // Postscript Tab: Fl_Input *pathToGsInput; Fl_Button *gsBrowse; Fl_Int_Input *renderInput, *displayInput; Fl_Check_Button *colourCheck, *greyCheck, *bwCheck; Fl_Round_Button *smoothButton, *antialiasButton; Fl_Choice *boundingChoice; Fl_Input *pathToPSPreviewer; Fl_Button *gvBrowse; // Server Tab: Fl_Float_Input *pollFrequencyInput; Fl_Slider *pollFrequencySlider; Fl_Round_Button *securityPasswordButton, *securityLocalhostButton; // Expert tab Fl_Round_Button *hideMenuButton; // hack Tab Fl_Round_Button *showDebugMsgButton, *stopAfterDebugMsgButton; Fl_Input *xorValueBreakLineInput, *xorValueProfileLineInput; // the main buttons Fl_Return_Button *OKButton; Fl_Button *saveButton, *cancelButton; }; #endif // USERPREFS_H imview-1.1.9c/view3d.cxx0000644000076500007650000000451510211621417015720 0ustar talbottalbot00000000000000/* * $Id: view3d.cxx,v 4.1 2005/03/03 14:45:35 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2005 by the Australian Commonwealth * Science and Industry Research Organisation (CSIRO). Please see the * COPYRIGHT file for full details. Imview also includes the * contributions of many others. Please see the CREDITS file for full * details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * 3D view widget. Allows 3 views of a 3d object (or time series, or * hyperspectral image) at the same time. This is fairly standard in * medical imaging. The innovation here might be the zoom. * * Hugues Talbot 2 Mar 2005 * *-----------------------------------------------------------------------*/ #include "imnmspc.hxx" #include "imview.hxx" #include "view3d.hxx" view3D::view3D() { dbgprintf("3D view panel constructed\n"); view3dWindow = 0; // fluid depends on that return; } void view3D::setDefaults() { return; } // pass the message along void view3D::show() { view3dWindow->show(); return; } void view3D::hide() { view3dWindow->hide(); return; } imview-1.1.9c/view3d.hxx0000644000076500007650000000507210211621417015724 0ustar talbottalbot00000000000000/* * $Id: view3d.hxx,v 4.1 2005/03/03 14:45:35 hut66au Exp $ * * Imview, the portable image analysis application * http://www.cmis.csiro.au/Hugues.Talbot/imview * ---------------------------------------------------------- * * Imview is an attempt to provide an image display application * suitable for professional image analysis. It was started in * 1997 and is mostly the result of the efforts of Hugues Talbot, * Image Analysis Project, CSIRO Mathematical and Information * Sciences, with help from others (see the CREDITS files for * more information) * * Imview is Copyrighted (C) 1997-2005 by the Australian Commonwealth * Science and Industry Research Organisation (CSIRO). Please see the * COPYRIGHT file for full details. Imview also includes the * contributions of many others. Please see the CREDITS file for full * details. * * 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 program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. * */ /*------------------------------------------------------------------------ * * 3D view widget. Allows 3 views of a 3d object (or time series, or * hyperspectral image) at the same time. This is fairly standard in * medical imaging. The innovation here might be the zoom. * * Hugues Talbot 2 Mar 2005 * *-----------------------------------------------------------------------*/ #ifndef VIEW3D_H #define VIEW3D_H #include #include #include #include #include #include "simpleViewer.hxx" // generic class containing all the widgets class view3D { public: view3D(); void setDefaults(); void show(); void hide(); friend Fl_Double_Window *view3d_panel(view3D &s); private: // the outermost window Fl_Double_Window *view3dWindow; // So that views are independently resizable Fl_Tile *contentTile; // Views simpleViewer *topView; }; #endif // VIEW3D_H