last update 20 Sep 2009 |
00001 /* 00002 * Copyright (C) 2007 by Pablo Alvarado 00003 * 00004 * This file is part of the Computer Vision and Robotics Library (CVR-Lib) 00005 * 00006 * The CVR-Lib is free software; you can redistribute it and/or 00007 * modify it under the terms of the BSD License. 00008 * 00009 * All rights reserved. 00010 * 00011 * Redistribution and use in source and binary forms, with or without 00012 * modification, are permitted provided that the following conditions are met: 00013 * 00014 * 1. Redistributions of source code must retain the above copyright notice, 00015 * this list of conditions and the following disclaimer. 00016 * 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 00021 * 3. Neither the name of the authors nor the names of its contributors may be 00022 * used to endorse or promote products derived from this software without 00023 * specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00028 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00029 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00030 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00031 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00032 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00033 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00034 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00035 * POSSIBILITY OF SUCH DAMAGE. 00036 */ 00037 00038 /** 00039 * \file cvrExternViewer2D.h 00040 * Contains the class cvr::externViewer used when there is no 00041 * possibility to use GTK or any other widget tool for which we have a 00042 * viewer 00043 * \author Pablo Alvarado 00044 * \date 21.07.99 00045 * 00046 * revisions ..: $Id: cvrExternViewer2D.h,v 1.1 2007/10/22 00:48:00 alvarado Exp $ 00047 */ 00048 00049 #ifndef _CVR_EXTERNVIEWER_2_D_H_ 00050 #define _CVR_EXTERNVIEWER_2_D_H_ 00051 00052 #include "cvrMatrix.h" 00053 #include "cvrRGBAPixel.h" 00054 #include "cvrParametersManager.h" 00055 #include "cvrStatus.h" 00056 #include "cvrIoObject.h" 00057 00058 #include <string> 00059 #include <list> 00060 00061 namespace cvr { 00062 /** 00063 * External viewer for 2D images. 00064 * 00065 * This object shows an image using an external application like 00066 * kview, xv, mspaint, etc. 00067 * 00068 * Use the externViewer::parameters to specify which application 00069 * should be used. 00070 * 00071 * A temporal image file will be created to transfer the image data 00072 * to the external application. If you need a faster viewer, use 00073 * the cvr::viewer2D instead! 00074 * 00075 * The default viewer used in Linux is the kview and in Windows the 00076 * mspaint. Make sure that these programs are included in one of 00077 * the directories specified by the system variable PATH. 00078 */ 00079 class externViewer2D : public ioObject, 00080 public status, 00081 public parametersManager { 00082 00083 public: 00084 00085 /** 00086 * Parameters of the cvr::externViewer2D class 00087 */ 00088 class parameters : public parametersManager::parameters { 00089 public: 00090 /** 00091 * default constructor 00092 */ 00093 parameters(); 00094 00095 /** 00096 * copy constructor 00097 */ 00098 parameters(const parameters& other); 00099 00100 /** 00101 * destructor 00102 */ 00103 virtual ~parameters(); 00104 00105 /** 00106 * copy member 00107 */ 00108 parameters& copy(const parameters& other); 00109 00110 /** 00111 * copy data of "other" parameters 00112 */ 00113 parameters& operator=(const parameters& other); 00114 00115 /** 00116 * Returns the name of this class 00117 */ 00118 virtual const std::string& name() const; 00119 00120 /** 00121 * Returns a pointer to a clone of the parameters. 00122 */ 00123 virtual parameters* clone() const; 00124 00125 /** 00126 * Returns a pointer to a new instance of the parameters. 00127 */ 00128 virtual parameters* newInstance() const; 00129 00130 /** 00131 * Write the parameters in the given ioHandler 00132 * @param handler the ioHandler to be used 00133 * @param complete if true (the default) the enclosing begin/end will 00134 * be also written, otherwise only the data block will be written. 00135 * @return true if write was successful 00136 */ 00137 virtual bool write(ioHandler& handler, 00138 const bool complete=true) const; 00139 00140 /** 00141 * Read the parameters from the given ioHandler 00142 * @param handler the ioHandler to be used 00143 * @param complete if true (the default) the enclosing begin/end will 00144 * be also written, otherwise only the data block will be written. 00145 * @return true if write was successful 00146 */ 00147 virtual bool read(ioHandler& handler,const bool complete=true); 00148 00149 // ------------------------ 00150 // the parameters 00151 // ------------------------ 00152 00153 /** 00154 * Name of the directory that will hold the temporary image files. 00155 * 00156 * Default directory: /tmp in Linux and C:\\TEMP in Windows 00157 */ 00158 std::string tmpDirectory; 00159 00160 /** 00161 * Name of the external application. 00162 * 00163 * Default application: kview in Linux and MSPaint in Windows 00164 */ 00165 std::string externViewerApp; 00166 }; 00167 00168 // -------------------------------------------------- 00169 // externViewer 00170 // -------------------------------------------------- 00171 00172 /** 00173 * Default constructor 00174 */ 00175 externViewer2D(); 00176 00177 /** 00178 * Constructor with a window name 00179 * 00180 * (some implementations ignore the given name) 00181 */ 00182 externViewer2D(const std::string& wndName); 00183 00184 /** 00185 * Constructor with parameters 00186 */ 00187 externViewer2D(const parameters& par); 00188 00189 /** 00190 * Copy constructor 00191 */ 00192 externViewer2D(const externViewer2D& other); 00193 00194 /** 00195 * Default destructor 00196 */ 00197 ~externViewer2D(); 00198 00199 /** 00200 * Returns the name of this class 00201 */ 00202 virtual const std::string& name() const; 00203 00204 /** 00205 * Returns a pointer to a clone of this instance. 00206 */ 00207 virtual externViewer2D* clone() const; 00208 00209 /** 00210 * Returns a pointer to a new instance of this class. 00211 */ 00212 virtual externViewer2D* newInstance() const; 00213 00214 /** 00215 * copy data of "other" functor. 00216 */ 00217 externViewer2D& copy(const externViewer2D& other); 00218 00219 /** 00220 * copy data of "other" functor. 00221 */ 00222 externViewer2D& operator=(const externViewer2D& other); 00223 00224 /** 00225 * returns the give parameters 00226 */ 00227 const parameters& getParameters() const; 00228 00229 /** 00230 * Shows an cvr::image 00231 * @param data the object to be shown. 00232 * @return true if successful, false otherwise. 00233 */ 00234 bool show(const matrix<rgbaPixel>& data); 00235 00236 /** 00237 * Shows a 8-bit channel 00238 * @param data the object to be shown. 00239 * @return true if successful, false otherwise. 00240 */ 00241 virtual bool show(const matrix<ubyte>& data); 00242 00243 /** 00244 * Shows a floating point channel 00245 * @param data the object to be shown. 00246 * @return true if successful, false otherwise. 00247 */ 00248 virtual bool show(const matrix<float>& data); 00249 00250 /** 00251 * Shows an integer matrix. 00252 * @param data the object to be shown. 00253 * @return true if successful, false otherwise. 00254 */ 00255 virtual bool show(const matrix<int32>& data); 00256 00257 /** 00258 * hides the display window 00259 * @return true if successful, false otherwise. 00260 */ 00261 virtual bool hide(); 00262 00263 00264 protected: 00265 /** 00266 * How many times has 'show' been used? 00267 */ 00268 static int numberShows; 00269 00270 }; // class externViewer2D 00271 00272 00273 } // namespace cvr 00274 00275 #endif // _CVR_EXTERNVIEWER_2_D_H_