LTI-Lib latest version v1.9 - last update 10 Apr 2010

ltiViewer.h

00001 /*
00002  * Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006
00003  * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany
00004  *
00005  * This file is part of the LTI-Computer Vision Library (LTI-Lib)
00006  *
00007  * The LTI-Lib is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License (LGPL)
00009  * as published by the Free Software Foundation; either version 2.1 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * The LTI-Lib is distributed in the hope that it will be
00013  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
00014  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with the LTI-Lib; see the file LICENSE.  If
00019  * not, write to the Free Software Foundation, Inc., 59 Temple Place -
00020  * Suite 330, Boston, MA 02111-1307, USA.
00021  */
00022 
00023 
00024 /*----------------------------------------------------------------
00025  * project ....: LTI Digital Image/Signal Processing Library
00026  * file .......: ltiViewer.h
00027  * authors ....: Pablo Alvarado
00028  * organization: LTI, RWTH Aachen
00029  * creation ...: 21.4.2000
00030  * revisions ..: $Id: ltiViewer.h,v 1.17 2006/12/26 03:38:59 alvarado Exp $
00031  */
00032 
00033 #ifndef _LTI_VIEWER_H_
00034 #define _LTI_VIEWER_H_
00035 
00036 #include "ltiConfig.h"
00037 
00038 #include "ltiViewerBase.h"
00039 #include "ltiHistogram.h"
00040 #include "ltiImage.h"
00041 #include "ltiException.h"
00042 
00043 #ifdef HAVE_GTK
00044 #include "ltiGtkWidget.h"
00045 #endif
00046 
00047 namespace lti {
00048 
00049   // this can be implemented with any gui toolkit...
00050   class viewerWindow;
00051 
00052   // this class draws everything
00053   class viewerFunctor;
00054 
00055   /**
00056    * Use objects of this class to display your data in a window.
00057    *
00058    * The GTK-GUI Toolkit is required to compile this object.
00059    *
00060    * The use of the lti::viewer is very simple.  Each viewer
00061    * administrates one window, and this window will exist as long as
00062    * the viewer object exists.  This means, if you destroy the
00063    * viewer-object, the window will be automatically destroyed.
00064    *
00065    * To use the viewer see following example:
00066    *
00067    * \code
00068    *
00069    *  #include "ltiImage.h"
00070    *  #include "ltiSplitImage.h"
00071    *  #include "ltiViewer.h"
00072    *  #include "ltiBMPFunctor.h"
00073    *
00074    *  ...
00075    *
00076    *  lti::image img;                // an image
00077    *  lti::channel chnl;             // a channel
00078    *  lti::splitImageTorgI splitter; // a functor to get the intensity channel
00079    *
00080    *  lti::loadBMP loader;
00081    *
00082    *  loader.load("yourImage.bmp",img); // load the image in the given file
00083    *  splitter.getIntensity(img,chnl);  // get the intensity channel of the img
00084    *
00085    *  lti::viewer view1,view2;
00086    *
00087    *  view1.show(img);                  // open a window and show the image
00088    *  view2.show(chnl);                 // open a new window and show the
00089    *                                    // intensity channel.
00090    *  ...
00091    *
00092    *  // until the end of the execution block the images will be displayed.
00093    *  // When view1 and view2 are destroyed, their windows will disappear!
00094    *
00095    * \endcode
00096    *
00097    * If you press the left-button of the mouse on a pixel, the value
00098    * of this pixel will be displayed on the status bar.
00099    *
00100    * You can configure some display-options by using the viewer::parameters.
00101    *
00102    * If you press the right-mouse button an options-dialog will be displayed.
00103    * You can control directly some display parameters (brightness, contrast,
00104    * zoom, etc.)  You can also save exactly the
00105    * image you are viewing pressing the button "Save" on the options dialog.
00106    * See lti::viewer::parameters for more information
00107    *
00108    * The statistic values computed will correspond always to intensity
00109    * values, even for color images.  Remember that intensity is
00110    * defined as (R+G+B)/3.
00111    *
00112    * The method waitButtonPressed() allows you to block the execution of your
00113    * program until the user clicks somewhere on the viewer window.  The
00114    * position of the pixel clicked will be returned.
00115    *
00116    * <b>Known Bugs</b>
00117    *
00118    * The multithreaded nature of the viewer functor has shown a few bugs.
00119    * Until a proper fix is provided, the following workaround have to be done:
00120    * 
00121    * 1. A crash at the very end of the application can be expected
00122    *    since the destruction of window handlers is done by two 
00123    *    threads simultaneously.  The secondary GTK+ thread is the only one
00124    *    that should do this, but the main thread destroys everything open at
00125    *    the end of the application, which also include stuff that secondary
00126    *    thread should do.  To avoid this conflict you can force termination of
00127    *    the secondary "GTK-Server" thread explicitely:
00128    *
00129    * \code
00130    *   #include "ltiGtkServer.h"
00131    *   #include "ltiTimer.h"
00132    *
00133    *   int main() {
00134    *
00135    *     // ... your code here
00136    *     // ... try to hide all viewers that aren't used any more
00137    *     //
00138    *
00139    *     lti::passiveWait(50000);     // wait 50ms that all viewers end its 
00140    *                                  // event handling
00141    *     lti::gtkServer::shutdown();  // stop the server (secondary thread)
00142    *     lti::passiveWait(50000);     // wait 50ms that all viewers end its 
00143    *                                  // event handling
00144    *     return 1;
00145    *   }
00146    *   
00147    * \endcode
00148    *    
00149    *    Please note that the shutdown() method is called at the very end of
00150    *    the main method.  This must be done this way, because after removing
00151    *    the GTK Server, there is no way to start it again in order to create
00152    *    or display the data on viewers.  The last passiveWait forces to wait
00153    *    until everything that has to do with viewers is removed.
00154    *
00155    * 2. The second bug has to do with a race condition when two
00156    *    viewers try to display data at almost the same time.  Even if the
00157    *    LTI-Lib calls the locking mechanisms of GTK, they don't seem to
00158    *    work and the application ends in a dead-lock.  The workaround is
00159    *    to avoid calling show() methods successively, separating them by
00160    *    small pauses.  This has to be done only once, before the windows are
00161    *    created:
00162    *
00163    * \code
00164    *    lti::viewer v1,v2; // two viewers
00165    *    v1.show(img1);     // show an image
00166    *    lti::passiveWait(50000) // wait 50ms (WORKAROUND FOR BUG)
00167    *    v2.show(img2);     // show another image
00168    *
00169    *    for (int i=0;i<10;i++) {
00170    *      v1.show(imgs[i]); // show images, since the viewer was already
00171    *                        // displayed, the problem does not occur anymore.
00172    *    }
00173    * \endcode
00174    *
00175    *
00176    * 3. There is also a "bug" in X.Org's composite extension and some pixbuf
00177    *    stuff of GTK.  If you get the following error message when starting
00178    *    your application (or something similar):
00179    *    \code
00180    *      Gdk-ERROR **: BadMatch (invalid parameter attributes)
00181    *        serial 252 error_code 8 request_code 148 minor_code 3
00182    *    \endcode
00183    *    then you can wether desactivate the composite extension in the
00184    *    xorg.conf file (in /etc/X11/) or you can define the variable
00185    *    \code
00186    *      export XLIB_SKIP_ARGB_VISUALS=1
00187    *    \endcode
00188    *    before starting your application.
00189    *
00190    * A new viewer generation is being developed to fix this awful bugs.
00191    */
00192   class viewer : public viewerBase {
00193   public:
00194     /**
00195      * The parameters for the class viewer.
00196      *
00197      * These parameters control the way an image or channel is
00198      * displayed.  You can also use them to generate with the
00199      * lti::viewerFunctor images as shown by the lti::viewer.
00200      */
00201     class parameters : public viewerBase::parameters {
00202     public:
00203       /**
00204        * default constructor
00205        */
00206       parameters();
00207 
00208       /**
00209        * copy constructor
00210        */
00211       parameters(const parameters& other);
00212 
00213       /**
00214        * destructor
00215        */
00216       virtual ~parameters();
00217 
00218       /**
00219        * copy member
00220        */
00221       parameters& copy(const parameters& other);
00222 
00223       /**
00224        * copy data of "other" parameters
00225        */
00226       parameters& operator=(const parameters& other);
00227 
00228       /**
00229        * returns a pointer to a clone of the parameters
00230        */
00231       virtual functor::parameters* clone() const;
00232 
00233       /**
00234        * returns name of this type
00235        */
00236       const char* getTypeName() const;
00237 
00238       /**
00239        * write the parameters in the given ioHandler
00240        * @param handler the ioHandler to be used
00241        * @param complete if true (the default) the enclosing begin/end will
00242        *        be also written, otherwise only the data block will be written.
00243        * @return true if write was successful
00244        */
00245       virtual bool write(ioHandler& handler,
00246                          const bool complete=true) const;
00247 
00248       /**
00249        * read the parameters from the given ioHandler
00250        * @param handler the ioHandler to be used
00251        * @param complete if true (the default) the enclosing begin/end will
00252        *        be also written, otherwise only the data block will be written.
00253        * @return true if write was successful
00254        */
00255       virtual bool read(ioHandler& handler,const bool complete=true);
00256 
00257 #     ifdef _LTI_MSC_6
00258       /**
00259        * this function is required by MSVC only, as a workaround for a
00260        * very awful bug, which exists since MSVC V.4.0, and still by
00261        * V.6.0 with all bugfixes (so called "service packs") remains
00262        * there...  This method is public due to another bug!, so please
00263        * NEVER EVER call this method directly
00264        */
00265       bool readMS(ioHandler& handler,const bool complete=true);
00266 
00267       /**
00268        * this function is required by MSVC only, as a workaround for a
00269        * very awful bug, which exists since MSVC V.4.0, and still by
00270        * V.6.0 with all bugfixes (so called "service packs") remains
00271        * there...  This method is public due to another bug!, so please
00272        * NEVER EVER call this method directly
00273        */
00274       bool writeMS(ioHandler& handler,const bool complete=true) const;
00275 #     endif
00276 
00277       // ------------------------
00278       // the parameters
00279       // ------------------------
00280 
00281       /**
00282        * Predefined color palettes for the channel and channel8 display
00283        */
00284       enum eDefaultPalette {
00285         Gray,       /**< Gray Palette  */
00286         Hue,        /**< Hue Palette   */
00287         Red,        /**< Red Palette   */
00288         Green,      /**< Green Palette */
00289         Blue,       /**< Blue Palette  */
00290         UserDefined /**< User Defined Palette */
00291       };
00292 
00293       /**
00294        * @name General parameters
00295        */
00296       //@{
00297       /**
00298        * color of the overflow values.
00299        *
00300        * For vectors and 1D histograms, this is used to draw the mean value of 
00301        * the elements and the mean index value.
00302        *
00303        * The default is Yellow
00304        */
00305       rgbPixel overflowColor;
00306 
00307       /**
00308        * color of the underflow values.
00309        *
00310        * For vectors and 1D histograms, this is used as the axis color.
00311        *
00312        * The default is Blue
00313        */
00314       rgbPixel underflowColor;
00315 
00316       /**
00317        * zoom factor of the window.  The scale factor is 2^zoomFactor.
00318        * Only values between -4 and 4 are valid.
00319        *
00320        * Default value: 0
00321        */
00322       int zoomFactor;
00323 
00324       /**
00325        * Parameter to control the constrast of the displayed image.
00326        * - +2.0 Use all the dynamic range.  This is the maximum possible
00327        *        contrast, without losing any information of the normal
00328        *        intensity value range (due to underflow or overflow).
00329        * - +1.0 means keep the original image contrast.
00330        * -  0.0 Zero contrast (a gray value)
00331        * - -1.0 produce the negative of the image using the original value
00332        *        range.
00333        * - -2.0 Use all the dynamic range to generate the negative of the
00334        *        shown image.
00335        *
00336        * Default value: 1.0
00337        */
00338       float contrast;
00339 
00340       /**
00341        * Add the given value to the intensity channel.  Independent of
00342        * the type of image or channel used, 1.0 means the complete
00343        * intensity range.
00344        *
00345        * Default value: 0.0
00346        */
00347       float brightness;
00348 
00349       /**
00350        * if showValue is true, then the color or channel value will be
00351        * displayed in a status bar.
00352        *
00353        * Default value: true
00354        */
00355       bool showValue;
00356 
00357       /**
00358        * if showHex is true, then the RGB value will be displayed in hex.
00359        *
00360        * Default value: false
00361        */
00362       bool showHex;
00363 
00364       //@}
00365 
00366       /**
00367        * @name Options for monochromatic channels
00368        */
00369       //@{
00370       /**
00371        * Which palette should be used?
00372        *
00373        * Default value: Gray
00374        */
00375       eDefaultPalette whichPalette;
00376 
00377       /**
00378        * if the data to be show is a channel or channel8, then the color
00379        * palette specified here will be used if <code>whichPalette</code> is
00380        * UserDefined.
00381        *
00382        * The default is a grey values palette.
00383        */
00384       palette colors;
00385 
00386       /**
00387        * for integer images, consider them as a label-mask and use
00388        * only a few colors to appreciate the different labeled regions in
00389        * a better way.  @see labelAdjacencyMap
00390        *
00391        * Default value: false
00392        */
00393       bool labelAdjacencyMap;
00394 
00395       /**
00396        * If labelAdjacencyMap is true, indicate if an 8-Neighborhood (true) or
00397        * a 4-Neighborhood (false) between the regions exist.
00398        *
00399        * Default value: 4-Neighborhood (i.e. false);
00400        */
00401       bool neighborhood8;
00402 
00403       /**
00404        * If labelAdjacencyMap is true, indicate if all colors in the user
00405        * defined palette should be used or only the first ones.
00406        *
00407        * Default value: false (i.e. use all colors in the palette if possible)
00408        */
00409       bool useFewColors;
00410       //@}
00411 
00412 
00413       /**
00414        * @name Options for vectors and histograms
00415        */
00416       //@{
00417       /**
00418        * Number of pixels used at the y-coordinate of the vector or 
00419        * histogram1D representation
00420        *
00421        * Default value: 256
00422        */
00423       int vectorHeight;
00424 
00425       /**
00426        * Number of pixels per element or per histogram bin used
00427        * 
00428        * Default value: 1 pixel
00429        */
00430       int pixelsPerElement;
00431 
00432       /**
00433        * Used to specify if the elements of the vector or bins of histogram1D s
00434        * should be represented with boxes or with points.
00435        *
00436        * If false, points will represent each cell:
00437        * \code
00438        *  |
00439        *  |           .
00440        *  |           |
00441        *  |        .  |           .
00442        *  |        |  |     .     |
00443        *  |  .     |  |  .  |     |
00444        *  |  |  .  |  |  |  |  .  |
00445        *  .  |  |  |  |  |  |  |  |
00446        *  |__|__|__|__|__|__|__|__|____
00447        * \endcode
00448        *
00449        * If true, boxes will be used:
00450        * \code
00451        *  |
00452        *  |           .__
00453        *  |           |  |
00454        *  |        .__|  |        .__
00455        *  |        |  |  |  .__   |  |
00456        *  |  .__   |  |  .__|  |  |  |
00457        *  |  |  .__|  |  |  |  .__|  |
00458        *  .__|  |  |  |  |  |  |  |  |
00459        *  |__|__|__|__|__|__|__|__|__|_
00460        * \endcode
00461        *
00462        * Default value: true (i.e. boxes will be displayed)
00463        */
00464       bool useBoxes;
00465 
00466       /**
00467        * show the lines between the coordinate system and the points should
00468        * be drawn.
00469        *
00470        * If true, (and with \c useBoxes=false) the result will be like the one
00471        * on the left side.
00472        *
00473        * \code
00474        *  |                               |
00475        *  |           .                   |           .
00476        *  |           |                   |
00477        *  |        .  |           .       |        .              .
00478        *  |        |  |     .     |       |                 .
00479        *  |  .     |  |  .  |     |       |  .           .
00480        *  |  |  .  |  |  |  |  .  |       |     .              .
00481        *  .  |  |  |  |  |  |  |  |       .
00482        *  |__|__|__|__|__|__|__|__|____   |____________________________
00483        * \endcode
00484        *
00485        * Default value: false
00486        */
00487       bool useLines;
00488 
00489       /**
00490        * Background color
00491        *
00492        * @see lineColor, underflowColor, overflowColor
00493        *
00494        * Default value: Black
00495        */
00496       rgbPixel backgroundColor;
00497 
00498       /**
00499        * Line color
00500        *
00501        * @see backgroundColor, underflowColor, overflowColor
00502        *
00503        * Default value: White
00504        */
00505       rgbPixel lineColor;
00506 
00507       /**
00508        * Show axis.
00509        *
00510        * If true, the horizontal axis (value 0) will be drawn using the color
00511        * given in underflowColor.
00512        *
00513        * Default value: true
00514        */
00515       bool drawHorizontalAxis;
00516       
00517       /**
00518        * Show mean values
00519        *
00520        * If true, the mean value of the elements and the mean value of
00521        * the indices will be drawn using the color given by
00522        * overflowColor
00523        *
00524        * Default value: false
00525        */
00526       bool drawMeanValues;
00527       //@}
00528 
00529       /**
00530        * @name Informational Parameters
00531        */
00532       //@{
00533 
00534       /**
00535        * Size of the matrix, image or vector.
00536        */
00537       point size;
00538 
00539       /**
00540        * minimum intensity value
00541        */
00542       float minI;
00543 
00544       /**
00545        * maximum intensity value
00546        */
00547       float maxI;
00548 
00549       /**
00550        * intensity average
00551        */
00552       float averageI;
00553 
00554       /**
00555        * minimum RGB components
00556        */
00557       rgbPixel minRGB;
00558 
00559       /**
00560        * maximum RGB components
00561        */
00562       rgbPixel maxRGB;
00563 
00564       /**
00565        * RGB average
00566        */
00567       trgbPixel<float> averageRGB;
00568 
00569       /**
00570        * standard deviation
00571        */
00572       float stdDeviation;
00573 
00574       /**
00575        * square root of the diagonal of covariance matrix
00576        */
00577       trgbPixel<float> diagCovariance;
00578 
00579       //@}
00580     };
00581 
00582     /**
00583      * construct a viewer with the given title, contrast and brightness
00584      *
00585      * @param title Window title.  Default value "lti::viewer"
00586      * @param contrast contrast for the image.  Default value 1.0f
00587      *                 (see viewer::parameters::contrast)
00588      * @param brightness brightness for the image. Default value 0.0f
00589      *                   (see viewer::parameters::brightness)
00590      * @param zoom zoom factor.  Default value 0. 
00591      *                  (see viewer::parameters::zoomFactor)
00592      * @param labelMap if true, the label adjacency map modus will be turned on
00593      */
00594     viewer(const std::string& title = "lti::viewer", 
00595            const float contrast = 1.0f,
00596            const float brightness = 0.0f,
00597            const int zoom=0,
00598            const bool labelMap=false);
00599 
00600     /**
00601      * constructor with given parameters
00602      */ 
00603     viewer(const parameters& par);
00604 
00605     /**
00606      * copy constructor
00607      * @param other the object to be copied
00608      */
00609     viewer(const viewer& other);
00610 
00611     /**
00612      * destructor
00613      */
00614     virtual ~viewer();
00615 
00616     /**
00617      * returns the name of this type ("viewer")
00618      */
00619     virtual const char* getTypeName() const;
00620 
00621     /**
00622      * shows a color image.
00623      * @param data the object to be shown.
00624      * @return true if successful, false otherwise.
00625      */
00626     virtual bool show(const image& data);
00627 
00628     /**
00629      * shows a channel
00630      * @param data the object to be shown.
00631      * @return true if successful, false otherwise.
00632      */
00633     virtual bool show(const matrix<float>& data);
00634 
00635     /**
00636      * shows a matrix of doubles as a channel
00637      * @param data the object to be shown.
00638      * @return true if successful, false otherwise.
00639      */
00640     virtual bool show(const matrix<double>& data);
00641 
00642     /**
00643      * shows a channel
00644      * @param data the object to be shown.
00645      * @return true if successful, false otherwise.
00646      */
00647     virtual bool show(const matrix<int>& data);
00648     /**
00649      * shows a channel
00650      * @param data the object to be shown.
00651      * @return true if successful, false otherwise.
00652      */
00653     virtual bool show(const matrix<ubyte>& data);
00654 
00655     /**
00656      * shows histogram as vector of double
00657      * @param data the object to be shown.
00658      * @return true if successful, false otherwise.
00659      */
00660     virtual bool show(const histogram1D& data);
00661 
00662     /**
00663      * shows histogram as vector of double
00664      * @param data the object to be shown.
00665      * @return true if successful, false otherwise.
00666      */
00667     virtual bool show(const histogram2D& data);
00668 
00669     /**
00670      * shows a vector of double
00671      * @param data the object to be shown.
00672      * @return true if successful, false otherwise.
00673      */
00674     virtual bool show(const vector<double>& data);
00675 
00676     /**
00677      * shows a vector of double
00678      * @param data the object to be shown.
00679      * @return true if successful, false otherwise.
00680      */
00681     virtual bool show(const vector<float>& data);
00682 
00683     /**
00684      * shows a vector of double
00685      * @param data the object to be shown.
00686      * @return true if successful, false otherwise.
00687      */
00688     virtual bool show(const vector<int>& data);
00689 
00690     /**
00691      * shows a vector of double
00692      * @param data the object to be shown.
00693      * @return true if successful, false otherwise.
00694      */
00695     virtual bool show(const vector<ubyte>& data);
00696 
00697     /**
00698      * hides the display window
00699      */
00700     bool hide();
00701 
00702     /**
00703      * copy data of "other" functor.
00704      */
00705     viewer& copy(const viewer& other);
00706 
00707     /**
00708      * returns a pointer to a clone of the functor.
00709      */
00710     virtual viewerBase* clone() const;
00711 
00712     /**
00713      * @name Parameters
00714      */
00715     //@{
00716 
00717     /**
00718      * returns used parameters
00719      */
00720     const parameters& getParameters() const;
00721 
00722     /**
00723      * set the parameters to be used
00724      */
00725     virtual bool setParameters(const viewerBase::parameters& param);
00726 
00727     /**
00728      * set position of the window
00729      */
00730     void setPosition(const point& p);
00731 
00732     /**
00733      * get position of the window
00734      */
00735     point getPosition() const;
00736 
00737     /**
00738      * set size of the window
00739      */
00740     void setSize(const point& p);
00741 
00742     /**
00743      * get size of the window
00744      */
00745     point getSize() const;
00746     //@}
00747 
00748     /**
00749      * Get the last clicked position and write the result at the given
00750      * parameter.  If this position lies within the displayed image, the
00751      * returned value is true, otherwise false.
00752      *
00753      * This method does not block the program execution.  It just returns
00754      * the last clicked position (which can be seen in the status bar)
00755      *
00756      * Note that the clicked position can be out of range.
00757      *
00758      * @see waitButtonPressed()
00759      *
00760      * @param pos the last clicked position will be written here
00761      * @return true, if the position lies within the displayed image,
00762      *         false otherwise.
00763      */
00764     bool lastClickedPosition(point& pos) const;
00765 
00766     /**
00767      * Wait until the user clicks somewhere on the image/vector
00768      * and returns the clicked position.
00769      *
00770      * Note that the clicked position can be out of range, unless you
00771      * specify with the parameter, that you expect only in-image points.
00772      *
00773      * @see lastClickedPosition()
00774      */
00775     point waitButtonPressed(const bool reportOnlyValidPos = false) const;
00776 
00777 
00778     /**
00779      * return the last pressed key
00780      *
00781      * This method does not block the program execution.  It just returns
00782      * the value of the last key pressed.
00783      *
00784      * @see waitKey()
00785      */
00786     int lastKey() const;
00787 
00788     /**
00789      * Wait until the user press some key while the viewer window is active
00790      * and return the code of the key pressed.
00791      *
00792      * @return the last key pressed or a negative number if the window
00793      *         was destroyed.
00794      *
00795      * @see lastKey()
00796      */
00797     int waitKey() const;
00798 
00799     /**
00800      * Wait until the user presses a key or a mouse button.
00801      *
00802      * @param key will be set to true if the user presses a key, otherwise
00803      *            will be set to false.
00804      * @param button will be set to true if the user presses a mouse button,
00805      *               otherwise will be set to false.
00806      * @return the key code at the x attribute of the point if the user
00807      *         presses a key or the clicked position if the user pressed a 
00808      *         mouse button.
00809      */
00810     point waitKeyOrButton(bool& key,bool& button) const;
00811 
00812   protected:
00813 
00814 #ifdef HAVE_GTK
00815     /**
00816      * Parent class for all types of configuration dialogs for the normal
00817      * viewer.
00818      */
00819     class configDialog : public configGTKDialog {
00820     public:
00821 
00822       /**
00823        * Default constructor
00824        */
00825       configDialog();
00826 
00827       /**
00828        * @name Virtual members to be reimplemented
00829        *
00830        * Following members should be reimplemented in your derived class
00831        * if you add new dialog options.
00832        */
00833       //@{
00834 
00835       /**
00836        * Inserts all pages in the main settings dialog.
00837        *
00838        */
00839       virtual void insertFrames();
00840 
00841       /**
00842        * copy the contents of the dialog in the parameters object.
00843        *
00844        * This method should read all data from the GTK-Widget and write them
00845        * in the parameter object.  Do not forget to check first if the
00846        * parameter pointer is valid or not.
00847        *
00848        * @return true if successful, false otherwise.
00849        */
00850       virtual bool getDialogData();
00851 
00852       /**
00853        * copy the contents of the parameters object into the dialog entries
00854        *
00855        * This method should write all data given in the parameters
00856        * into the GTK-Widget.
00857        * Do not forget to check first if the parameter pointer is
00858        * valid or not.
00859        *
00860        * @return true if successful, false otherwise.
00861        */
00862       virtual bool setDialogData();
00863 
00864       /**
00865        * create a new instance of this configuration dialog
00866        */
00867       virtual configGTKDialog* newInstance() const;
00868       //@}
00869 
00870       /**
00871        * set the drawing functor being used
00872        */
00873       void useFunctor(viewerFunctor& fct);
00874 
00875     protected:
00876       /**
00877        * Non virtual function to set all common dialog data
00878        */
00879       bool setCommonDialogData();
00880 
00881       /**
00882        * Set all widgets as NULL
00883        */
00884       void clearAllWidgets();
00885 
00886       /**
00887        * Build and Append the intensity control frame
00888        */
00889       void buildIntensityControlFrame();
00890 
00891       /**
00892        * Build and Append the intensity control frame
00893        */
00894       void buildZoomFrame();
00895 
00896       /**
00897        * Build and Append the statistics frame
00898        */
00899       void buildStatisticsFrame();
00900 
00901       /**
00902        * Build and Append the Palette frame
00903        */
00904       void buildPaletteFrame();
00905 
00906       /**
00907        * Build and Append the Palette frame with label control
00908        */
00909       void buildPaletteAndLabelFrame();
00910 
00911       /**
00912        * Build hexadecimal button
00913        */
00914       void buildHexadecimalDisplayFrame();
00915 
00916       /**
00917        * Build vector options frame
00918        */
00919       void buildVectorFrame();
00920 
00921       /**
00922        * The painting functor
00923        */
00924       viewerFunctor* master;
00925 
00926       /**
00927        * GTK Widgets
00928        */
00929       //@{
00930       // Statistics Frame
00931       GtkWidget *StatisticsFrame;
00932       GtkWidget *StatisticsBox;
00933       GtkWidget *StatisticsSubBox;
00934       GtkWidget *MinLabel;
00935       GtkWidget *MaxLabel;
00936       GtkWidget *AverageLabel;
00937       GtkWidget *StdDevLabel;
00938       GtkWidget *SizeEntry;
00939       GtkWidget *MinEntry;
00940       GtkWidget *MaxEntry;
00941       GtkWidget *AverageEntry;
00942       GtkWidget *StdDevEntry;
00943       GtkWidget *ScaleMinimumButton;
00944       GtkWidget *ScaleMaximumButton;
00945       GtkWidget *ScaleMinMaxButton;
00946       GtkWidget *Size;
00947       GtkWidget *AvrgStdDevScalingBox;
00948       GtkWidget *ScaleStdDevButton;
00949       GtkWidget *ScalingFactorEntry;
00950       GtkWidget *ColorsBox;
00951       GtkWidget *UnderflowColorLabel;
00952       GtkWidget *UnderflowColorButton;
00953       GtkWidget *OverflowColorButton;
00954       GtkWidget *OverflowColorLabel;
00955 
00956       // Intensity Control Frame
00957       GtkWidget *IntensityControlFrame;
00958       GtkWidget *table1;
00959       GtkWidget *ZoomLabel;
00960       GtkWidget *ContrastLabel;
00961       GtkWidget *BrightnessLabel;
00962       GtkWidget *ZoomScale;
00963       GtkObject *ZoomAdjustment;
00964       GtkObject *BrightnessAdjustment;
00965       GtkObject *ContrastAdjustment;
00966       GtkWidget *BrightnessEntry;
00967       GtkWidget *ContrastEntry;
00968       GtkWidget *ZoomEntry;
00969       GtkWidget *ContrastScale;
00970       GtkWidget *BrightnessScale;
00971 
00972       // Palette Control Frame
00973       GtkWidget *PaletteControlFrame;
00974       GtkWidget *PaletteOptionsBox;
00975       GtkWidget *UsualPalettes;
00976       GSList *_1_group;
00977       GtkWidget *GrayButton;
00978       GtkWidget *RedButton;
00979       GtkWidget *GreenButton;
00980       GtkWidget *BlueButton;
00981       GtkWidget *HueButton;
00982       GtkWidget *UserDefinedButton;
00983 
00984       // Label Adjacency
00985       GtkWidget *LabelAdjacencyButton;
00986       GtkWidget *hbox2;
00987       GSList *_2_group;
00988       GtkWidget *Neigh4Button;
00989       GtkWidget *Neigh8;
00990       GtkWidget *MinColorsButton;
00991 
00992       // Hexadecimal Display
00993       GtkWidget *hexDisplay;
00994 
00995       // Vector Options Frame
00996       GtkWidget *VectorOptionsFrame;
00997       GtkWidget *vctSubframe;
00998       GtkWidget *vctbox1;
00999       GtkWidget *vctSizes;
01000       GtkWidget *vctHeightLabel;
01001       GtkWidget *vctHeight;
01002       GtkWidget *vctPixPerElemLabel;
01003       GtkWidget *vctPixPerElem;
01004       GtkWidget *vctBools;
01005       GtkWidget *useBoxes;
01006       GtkWidget *useLines;
01007       GtkWidget *horizontalAxis;
01008       GtkWidget *drawMeanValues;
01009       GtkWidget *vctColors;
01010       GtkWidget *backgroundColor;
01011       GtkWidget *lineColor;
01012       //@}
01013 
01014       /**
01015        * Callback functions
01016        */
01017       //@{
01018       static void on_ScaleMinimumButton_clicked(GtkButton *button,
01019                                                 gpointer user_data);
01020 
01021       static void on_ScaleMaximumButton_clicked(GtkButton *button,
01022                                                 gpointer user_data);
01023 
01024       static void on_ScaleMinMaxButton_clicked(GtkButton *button,
01025                                                gpointer user_data);
01026 
01027       static void on_ScaleStdDevButton_clicked(GtkButton *button,
01028                                                gpointer user_data);
01029 
01030       static void on_UnderflowColorButton_clicked(GtkButton *button,
01031                                                   gpointer user_data);
01032 
01033       static void on_OverflowColorButton_clicked(GtkButton *button,
01034                                                  gpointer user_data);
01035 
01036       static void on_zoom_value_changed(GtkAdjustment* widget,
01037                                         gpointer value);
01038 
01039       static void on_contrast_value_changed(GtkAdjustment* widget,
01040                                             gpointer value);
01041 
01042       static void on_brightness_value_changed(GtkAdjustment* widget,
01043                                               gpointer value);
01044 
01045       static void on_BrightnessEntry_changed(GtkEditable *editable,
01046                                              gpointer user_data);
01047 
01048       static void on_ContrastEntry_changed(GtkEditable *editable,
01049                                            gpointer user_data);
01050 
01051       static void on_ZoomEntry_changed(GtkEditable *editable,
01052                                        gpointer user_data);
01053 
01054       static void on_palette_toggled(GtkToggleButton *togglebutton,
01055                                      gpointer user_data);
01056 
01057       static void on_LabelAdjacencyButton_toggled(GtkToggleButton *togglebutton,
01058                                                   gpointer user_data);
01059 
01060       static void on_neighborhood_toggled(GtkToggleButton *togglebutton,
01061                                           gpointer user_data);
01062 
01063       static void on_MinColorsButton_toggled(GtkToggleButton *togglebutton,
01064                                              gpointer user_data);
01065 
01066       static void on_hexDisplay_toggled(GtkToggleButton *togglebutton,
01067                                         gpointer user_data);
01068 
01069 
01070       static void on_vctHeight_changed(GtkEditable *editable,
01071                                        gpointer user_data);
01072       
01073       static void on_vctPixPerElem_changed(GtkEditable *editable,
01074                                            gpointer user_data);
01075       
01076       static void on_useBoxes_toggled(GtkToggleButton *togglebutton,
01077                                       gpointer user_data);
01078       
01079       static void on_useLines_toggled(GtkToggleButton *togglebutton,
01080                                       gpointer user_data);
01081       
01082       static void on_horizontalAxis_toggled(GtkToggleButton *togglebutton,
01083                                             gpointer user_data);
01084       
01085       static void on_drawMeanValues_toggled(GtkToggleButton *togglebutton,
01086                                             gpointer user_data);
01087       
01088       static void on_backgroundColor_clicked(GtkButton *button,
01089                                              gpointer user_data);
01090       
01091       static void on_lineColor_clicked(GtkButton *button,
01092                                        gpointer user_data);
01093       
01094 
01095 
01096       /**
01097        * compute, using the min and max values in the parameters object,
01098        * which contrast and brightness are required to have an interval
01099        * between 0 and max
01100        */
01101       void minScaling(float& contr,float& bright);
01102 
01103       /**
01104        * compute, using the min and max values in the parameters object,
01105        * which contrast and brightness are required to have an interval
01106        * between min and 1
01107        */
01108       void maxScaling(float& contr,float& bright);
01109 
01110       /**
01111        * compute, using the min and max values in the parameters object,
01112        * which contrast and brightness are required to have an interval
01113        * between avrg-factor*stddev and avrg+factor*stddev
01114        */
01115       void deltaScaling(float& contr,float& bright);
01116 
01117       /**
01118        * Value used as 1.0 in the given image type (usually 1.0 or 255);
01119        */
01120       float norm;
01121 
01122       /**
01123        * Temporal parameters object.  The real parameters are taken only
01124        * if the user does an ok!
01125        */
01126       parameters tmpParam;
01127 
01128       //@}
01129     };
01130 
01131     /**
01132      * Configuration Dialog for viewer of images of fixed point scalar
01133      * values, like channel8 or matrix<int>
01134      */
01135     class configChannelFixed : public configDialog {
01136     public:
01137       /**
01138        * constructor
01139        */
01140       configChannelFixed();
01141 
01142       /**
01143        * Inserts all pages in the main settings dialog.
01144        *
01145        */
01146       virtual void insertFrames();
01147 
01148       /**
01149        * copy the contents of the parameters object into the dialog entries
01150        *
01151        * This method should write all data given in the parameters
01152        * into the GTK-Widget.
01153        * Do not forget to check first if the parameter pointer is
01154        * valid or not.
01155        *
01156        * @return true if successful, false otherwise.
01157        */
01158       virtual bool setDialogData();
01159 
01160       /**
01161        * create a new instance of this configuration dialog
01162        */
01163       virtual configGTKDialog* newInstance() const;
01164     };
01165 
01166     /**
01167      * Configuration Dialog for viewer of images of floating point scalar
01168      * values, like channel or matrix<double>
01169      */
01170     class configChannelFloat : public configDialog {
01171     public:
01172       /**
01173        * constructor
01174        */
01175       configChannelFloat();
01176 
01177       /**
01178        * Inserts all pages in the main settings dialog.
01179        *
01180        */
01181       virtual void insertFrames();
01182 
01183       /**
01184        * copy the contents of the parameters object into the dialog entries
01185        *
01186        * This method should write all data given in the parameters
01187        * into the GTK-Widget.
01188        * Do not forget to check first if the parameter pointer is
01189        * valid or not.
01190        *
01191        * @return true if successful, false otherwise.
01192        */
01193       virtual bool setDialogData();
01194 
01195       /**
01196        * create a new instance of this configuration dialog
01197        */
01198       virtual configGTKDialog* newInstance() const;
01199     };
01200 
01201     /**
01202      * Configuration Dialog for viewer of images of rgbPixel elements.
01203      */
01204     class configImage : public configDialog {
01205     public:
01206       /**
01207        * constructor
01208        */
01209       configImage();
01210 
01211       /**
01212        * Inserts all pages in the main settings dialog.
01213        *
01214        */
01215       virtual void insertFrames();
01216 
01217       /**
01218        * copy the contents of the parameters object into the dialog entries
01219        *
01220        * This method should write all data given in the parameters
01221        * into the GTK-Widget.
01222        * Do not forget to check first if the parameter pointer is
01223        * valid or not.
01224        *
01225        * @return true if successful, false otherwise.
01226        */
01227       virtual bool setDialogData();
01228 
01229       /**
01230        * create a new instance of this configuration dialog
01231        */
01232       virtual configGTKDialog* newInstance() const;
01233     };
01234 
01235     /**
01236      * Configuration Dialog for viewer of vectors
01237      */
01238     class configVector : public configDialog {
01239     public:
01240       /**
01241        * constructor
01242        */
01243       configVector();
01244 
01245       /**
01246        * Inserts all pages in the main settings dialog.
01247        *
01248        */
01249       virtual void insertFrames();
01250 
01251       /**
01252        * copy the contents of the parameters object into the dialog entries
01253        *
01254        * This method should write all data given in the parameters
01255        * into the GTK-Widget.
01256        * Do not forget to check first if the parameter pointer is
01257        * valid or not.
01258        *
01259        * @return true if successful, false otherwise.
01260        */
01261       virtual bool setDialogData();
01262 
01263       /**
01264        * create a new instance of this configuration dialog
01265        */
01266       virtual configGTKDialog* newInstance() const;
01267     };
01268 
01269     /**
01270      * Abstract class for all main windows for the different data types
01271      */
01272     class mainWindow : public mainGTKWindow {
01273     public:
01274       /**
01275        * Constructor
01276        */
01277       mainWindow();
01278 
01279       /**
01280        * Copy constructor
01281        */
01282       mainWindow(const mainWindow& other);
01283 
01284       /**
01285        * Destructor
01286        */
01287       virtual ~mainWindow();
01288 
01289       /**
01290        * clone this window
01291        */
01292       virtual mainGTKWindow* clone() const = 0;
01293 
01294       /**
01295        * Types accepted by this viewer (and its subclasses)
01296        */
01297       enum eDataType {
01298         Invalid,
01299         MatrixUByte,
01300         MatrixInt,
01301         MatrixFloat,
01302         MatrixDouble,
01303         Image,
01304         VectorUByte,
01305         VectorInt,
01306         VectorFloat,
01307         VectorDouble
01308       };
01309 
01310       /**
01311        * Set the data to be displayed (matrix<ubyte> and inherited classes)
01312        */
01313       void setData(const matrix<ubyte>& data);
01314 
01315       /**
01316        * Set the data to be displayed
01317        */
01318       void setData(const matrix<int>& data);
01319 
01320       /**
01321        * Set the data to be displayed (matrix<float> and inherited classes)
01322        */
01323       void setData(const matrix<float>& data);
01324 
01325       /**
01326        * Set the data to be displayed (matrix<float> and inherited classes)
01327        */
01328       void setData(const matrix<double>& data);
01329 
01330       /**
01331        * Set the data to be displayed
01332        */
01333       void setData(const matrix<rgbPixel>& data);
01334 
01335       /**
01336        * Set the data to be displayed
01337        */
01338       void setData(const vector<ubyte>& data);
01339 
01340       /**
01341        * Set the data to be displayed
01342        */
01343       void setData(const vector<int>& data);
01344 
01345       /**
01346        * Set the data to be displayed
01347        */
01348       void setData(const vector<float>& data);
01349 
01350       /**
01351        * Set the data to be displayed
01352        */
01353       void setData(const vector<double>& data);
01354 
01355       /**
01356        * generate an event which will show the data
01357        */
01358       virtual bool drawData();
01359 
01360       /**
01361        * Indicate which functor should be used for painting
01362        */
01363       void useFunctor(viewerFunctor& fct);
01364 
01365       /**
01366        * Get the last clicked position and write the result at the given
01367        * parameter.  If this position lies within the displayed image, the
01368        * returned value is true, otherwise false.
01369        *
01370        * This method does not block the program execution.  It just returns
01371        * the last clicked position (which can be seen in the status bar)
01372        *
01373        * Note that the clicked position can be out of range.
01374        *
01375        * @see waitButtonPressed()
01376        *
01377        * @param pos the last clicked position will be written here
01378        * @return true, if the position lies within the displayed image,
01379        *         false otherwise.
01380        */
01381       bool lastClickedPosition(point& pos) const;
01382 
01383       /**
01384        * Wait until the user clicks somewhere on the image/vector
01385        * and returns the clicked position.
01386        *
01387        * Note that the clicked position can be out of range.
01388        *
01389        * @see lastClickedPosition()
01390        */
01391       point waitButtonPressed(const bool onlyValidPos) const;
01392 
01393       /**
01394        * return the last pressed key
01395        *
01396        * This method does not block the program execution.  It just returns
01397        * the value of the last key pressed.
01398        *
01399        * @see waitKey()
01400        */
01401       int lastKey() const;
01402 
01403       /**
01404        * Wait until the user press some key while the viewer window is active
01405        * and return the code of the key pressed.
01406        *
01407        * @see lastKey()
01408        */
01409       int waitKey() const;
01410 
01411       /**
01412        * Wait until the user presses a key or a mouse button.
01413        *
01414        * @param key will be set to true if the user presses a key, otherwise
01415        *            will be set to false.
01416        * @param button will be set to true if the user presses a mouse button,
01417        *               otherwise will be set to false.
01418        * @return the key code if the user presses a key or the mouse button 
01419        *         number.
01420        */
01421       point waitKeyOrButton(bool& key,bool& button) const;
01422       
01423     protected:
01424       /**
01425        * Type of the data contained in this class
01426        */
01427       eDataType dataType;
01428 
01429       /**
01430        * copy of the data wished to be visualized
01431        */
01432       const mathObject* theData;
01433 
01434       /**
01435        * The painting functor
01436        */
01437       viewerFunctor* master;
01438 
01439       /**
01440        * Value used as 1.0 in the given image type (usually 1.0 or 255);
01441        */
01442       float norm;
01443 
01444       /**
01445        * true if the data has been set and no statistics have been
01446        * computed for it yet.
01447        */
01448       bool newDataFlag;
01449 
01450       /**
01451        * mutex to protect the data attribute
01452        */
01453       mutable mutex dataLock;
01454 
01455       /**
01456        * drawing available
01457        */
01458       semaphore drawRequestSem;
01459 
01460       /**
01461        * @name Members to be reimplemented
01462        */
01463       //@{
01464       /**
01465        * This method is the one where your data should be drawn.
01466        * You just need to draw on the "theImage" attribute image.
01467        */
01468       virtual void dataToImage(image& img) = 0;
01469 
01470       /**
01471        * This method is called as soon as all data has been drawn.  You can
01472        * use it to send a message to another widget or object, in order to
01473        * allow further actions.  The default implementation does nothing.
01474        */
01475       virtual void drawReady();
01476 
01477       /**
01478        * Prepare the parameters before the configuration dialog is started.
01479        *
01480        * This member gets some information of the displayed data into
01481        * the informational attributes of the parameters instance.
01482        * It is called just before opening the settings dialog, and is
01483        * the proper place to update the mentioned informational data.
01484        */
01485       virtual void prepareParameters() = 0;
01486 
01487       /**
01488        * Indicate if there are valid data to show.
01489        *
01490        * This method must check if the provided data is ready
01491        * to be shown, i.e. if the dataToImage() can be already
01492        * be used to draw the data.
01493        */
01494       virtual bool validData(void);
01495 
01496       /**
01497        * this method will be called to invalidate the data.
01498        *
01499        * Usually will set a few pointers to NULL to indicate
01500        * that the window has been hidden, and no valid data is
01501        * keeped in this class any more.
01502        */
01503       virtual void indicateDataHide(void);
01504 
01505       /**
01506        * window destruction handler.
01507        *
01508        * This method is called when the window is destroyed.  You don't
01509        * need to call GTK hide methods or stuff like that, because the
01510        * enclosing application will take care on these matters.  Just
01511        * finalize tasks you started that should be active as long as the
01512        * widget window does.  
01513        *
01514        * A typical use for this method is un-locking keyboard or mouse
01515        * mutexes that wait for the user.  If he closes the window
01516        * without giving any information, these mutexes will remain locked, 
01517        * blocking some other threads.  This method is the proper place to
01518        * un-lock them.
01519        */
01520       virtual void windowDestructionHandler();
01521 
01522 
01523       /**
01524        * this function is called when a mouse button is pressed and the mouse
01525        * moved.
01526        * @param button which button is pressed (0 means none,
01527        *               1 left button, 3 right button)
01528        * @param pos actual position of mouse pointer
01529        * @param shift true if the shift-key has been pressed while moving the
01530        *              mouse.
01531        * @param ctrl true if the control-key has been pressed while moving the
01532        *              mouse.
01533        */
01534       virtual void mouseMovedHandler(const int& button,
01535                                      const point& pos,
01536                                      const bool shift,
01537                                      const bool ctrl);
01538 
01539       /**
01540        * this function is called when a mouse button is pressed.
01541        * @param button which button is pressed (0 means none,
01542        *               1 left button, 3 right button)
01543        * @param pos actual position of mouse pointer
01544        * @param shift true if the shift-key has been pressed while moving the
01545        *              mouse.
01546        * @param ctrl true if the control-key has been pressed while moving the
01547        *              mouse.
01548        * @param pressed true if the button was pressed, false if the button was
01549        *              released.
01550        */
01551       virtual void mouseButtonHandler(const int& button,
01552                                       const point& pos,
01553                                       const bool shift,
01554                                       const bool ctrl,
01555                                       const bool pressed);
01556 
01557       /**
01558        * this method is called when a key is pressed while the viewer window
01559        * is active.
01560        * @param shift true if the shift-key has been pressed while moving the
01561        *              mouse.
01562        * @param ctrl true if the control-key has been pressed while moving the
01563        *              mouse.
01564        * @param key integer value containing the key code.  You can find
01565        *            symbol definitions for the values used here in the file
01566        *            <gdk/gdkkeysym.h>
01567        */
01568       virtual void keyPressedHandler(const bool shift,
01569                                      const bool ctrl,
01570                                      const int key);
01571 
01572       /**
01573        * this method is called when a key is pressed while the viewer window
01574        * is active.
01575        * @param shift true if the shift-key has been pressed while moving the
01576        *              mouse.
01577        * @param ctrl true if the control-key has been pressed while moving the
01578        *              mouse.
01579        * @param key integer value containing the key code.  You can find
01580        *            symbol definitions for the values used here in the file
01581        *            <gdk/gdkkeysym.h>
01582        */
01583       virtual void keyReleasedHandler(const bool shift,
01584                                       const bool ctrl,
01585                                       const int key);
01586 
01587       /**
01588        * called when the status bar information needs to be updated
01589        */
01590       virtual void updateStatusBar(const point& pos)=0;
01591       //@}
01592 
01593       /**
01594        * last position in the image where the mouse was clicked
01595        */
01596       point lastPosition;
01597 
01598       /**
01599        * This flag indicates, if the lastPosition contains a valid
01600        * value, i.e. if the point lies within the displayed image
01601        */
01602       bool validLastPosition;
01603 
01604       /**
01605        * semaphore to wait until the user clicks on the window
01606        */
01607       mutable semaphore waitInteraction;
01608 
01609       /**
01610        * set to true, when the user waits for a mouse click
01611        */
01612       mutable bool waitingForClick;
01613 
01614       /**
01615        * last position in the image where the mouse was clicked
01616        */
01617       mutable int lastKeyCode;
01618 
01619       /**
01620        * set to true, when the user waits for a mouse click
01621        */
01622       mutable bool waitingForKey;
01623     };
01624 
01625     /**
01626      * Main Window for channels of fixed point values
01627      */
01628     class mainWndChannelFixed : public mainWindow {
01629     public:
01630       /**
01631        * Constructor
01632        */
01633       mainWndChannelFixed();
01634 
01635       /**
01636        * Copy constructor
01637        */
01638       mainWndChannelFixed(const mainWndChannelFixed& other);
01639 
01640       /**
01641        * Destructor
01642        */
01643       virtual ~mainWndChannelFixed();
01644 
01645       /**
01646        * clone this window
01647        */
01648       virtual mainGTKWindow* clone() const;
01649 
01650     protected:
01651       /**
01652        * @name Members to be reimplemented
01653        */
01654       //@{
01655       /**
01656        * This method is the one where your data should be drawn.
01657        * You just need to draw on the "theImage" attribute image.
01658        */
01659       virtual void dataToImage(image& img);
01660 
01661       /**
01662        * normal grey channel to image
01663        */
01664       void channelToImage();
01665 
01666       /**
01667        * labeled mask to image
01668        */
01669       void labelsToImage();
01670 
01671       /**
01672        * Prepare the parameters before the configuration dialog is started.
01673        *
01674        * This member gets some information of the displayed data into
01675        * the informational attributes of the parameters instance.
01676        * It is called just before opening the settings dialog, and is
01677        * the proper place to update the mentioned informational data.
01678        */
01679       virtual void prepareParameters();
01680 
01681       /**
01682        * called when the status bar information needs to be updated
01683        */
01684       virtual void updateStatusBar(const point& pos);
01685       //@}
01686 
01687     private:
01688       /**
01689        * this pointer equals always the theData pointer, and is
01690        * used to make unnecessary casting theData to the proper type each time
01691        */
01692       const matrix<ubyte>* chnl8;
01693 
01694       /**
01695        * this pointer equals always the theData pointer, and is
01696        * used to make unnecessary casting theData to the proper type each time
01697        */
01698       const matrix<int>* chnl32;
01699     };
01700 
01701     /**
01702      * Main Window for channels of floating point values
01703      */
01704     class mainWndChannelFloat : public mainWindow {
01705     public:
01706       /**
01707        * Constructor
01708        */
01709       mainWndChannelFloat();
01710 
01711       /**
01712        * Copy constructor
01713        */
01714       mainWndChannelFloat(const mainWndChannelFloat& other);
01715 
01716       /**
01717        * Destructor
01718        */
01719       virtual ~mainWndChannelFloat();
01720 
01721       /**
01722        * clone this window
01723        */
01724       virtual mainGTKWindow* clone() const;
01725 
01726     protected:
01727       /**
01728        * This method is the one where your data should be drawn.
01729        * You just need to draw on the "theImage" attribute image.
01730        */
01731       virtual void dataToImage(image& img);
01732 
01733       /**
01734        * Prepare the parameters before the configuration dialog is started.
01735        *
01736        * This member gets some information of the displayed data into
01737        * the informational attributes of the parameters instance.
01738        * It is called just before opening the settings dialog, and is
01739        * the proper place to update the mentioned informational data.
01740        */
01741       virtual void prepareParameters();
01742 
01743       /**
01744        * called when the status bar information needs to be updated
01745        */
01746       virtual void updateStatusBar(const point& pos);
01747 
01748     private:
01749       /**
01750        * Casted alias for theData
01751        */
01752       const matrix<float>* chnl;
01753 
01754       /**
01755        * Casted alias for theData
01756        */
01757       const matrix<double>* dchnl;
01758     };
01759 
01760     /**
01761      * Main Window for vectors
01762      */
01763     class mainWndVector : public mainWindow {
01764     public:
01765       /**
01766        * Constructor
01767        */
01768       mainWndVector();
01769 
01770       /**
01771        * Copy constructor
01772        */
01773       mainWndVector(const mainWndVector& other);
01774 
01775       /**
01776        * Destructor
01777        */
01778       virtual ~mainWndVector();
01779 
01780       /**
01781        * clone this window
01782        */
01783       virtual mainGTKWindow* clone() const;
01784 
01785     protected:
01786       /**
01787        * This method is the one where your data should be drawn.
01788        * You just need to draw on the "theImage" attribute image.
01789        */
01790       virtual void dataToImage(image& img);
01791 
01792       /**
01793        * Prepare the parameters before the configuration dialog is started.
01794        *
01795        * This member gets some information of the displayed data into
01796        * the informational attributes of the parameters instance.
01797        * It is called just before opening the settings dialog, and is
01798        * the proper place to update the mentioned informational data.
01799        */
01800       virtual void prepareParameters();
01801 
01802       /**
01803        * called when the status bar information needs to be updated
01804        */
01805       virtual void updateStatusBar(const point& pos);
01806 
01807     private:
01808       /**
01809        * casted alias
01810        */
01811       const vector<double>* dvct;
01812 
01813       /**
01814        * casted alias
01815        */
01816       const vector<float>* fvct;
01817 
01818       /**
01819        * casted alias
01820        */
01821       const vector<int>* ivct;
01822 
01823       /**
01824        * casted alias
01825        */
01826       const vector<ubyte>* uvct;
01827     };
01828 
01829     /**
01830      * Main Window for color images
01831      */
01832     class mainWndImage : public mainWindow {
01833     public:
01834       /**
01835        * Constructor
01836        */
01837       mainWndImage();
01838 
01839       /**
01840        * Copy constructor
01841        */
01842       mainWndImage(const mainWndImage& other);
01843 
01844       /**
01845        * Destructor
01846        */
01847       virtual ~mainWndImage();
01848 
01849       /**
01850        * clone this window
01851        */
01852       virtual mainGTKWindow* clone() const;
01853     protected:
01854       /**
01855        * This method is the one where your data should be drawn.
01856        * You just need to draw on the "theImage" attribute image.
01857        */
01858       virtual void dataToImage(image& img);
01859 
01860       /**
01861        * Prepare the parameters before the configuration dialog is started.
01862        *
01863        * This member gets some information of the displayed data into
01864        * the informational attributes of the parameters instance.
01865        * It is called just before opening the settings dialog, and is
01866        * the proper place to update the mentioned informational data.
01867        */
01868       virtual void prepareParameters();
01869 
01870       /**
01871        * called when the status bar information needs to be updated
01872        */
01873       virtual void updateStatusBar(const point& pos);
01874 
01875     private:
01876       /**
01877        * Casted alias for theData
01878        */
01879       const image* chnl;
01880 
01881     };
01882 
01883     /**
01884      * Ensure that the wnds array contains a valid window with the
01885      * actual parameters at each given position
01886      */
01887     void ensureWindow(const int newWnd);
01888 
01889     /**
01890      * The current used window (the index in the wnds vector
01891      */
01892     int wnd;
01893 
01894     /**
01895      * Number of different window types
01896      */
01897     static const int winTypes;
01898 
01899     /**
01900      * Window instance for channels of fixed point arithmetic
01901      */
01902     mainWindow* wnds[4]; // 4 == winTypes
01903 
01904     /**
01905      * returns used parameters as a read/write reference
01906      */
01907     parameters& getParameters();
01908 
01909     /**
01910      * This is the master who paints everything nice
01911      */
01912     viewerFunctor* master;
01913 #endif
01914 
01915   };
01916 }
01917 
01918 #endif

Generated on Sat Apr 10 15:26:22 2010 for LTI-Lib by Doxygen 1.6.1