00001 /** 00002 \file Robots/LoBot/ui/LoLaserWindowMarkings.H 00003 00004 \brief A helper class for drawing markers to indicate distances on the 00005 LRF tester's main window. 00006 00007 This file defines an abstract base class for a helper object that 00008 draws markers of some sort within the LRF test program's window. These 00009 markers indicate distances at regular intervals. 00010 00011 For example, we can have markings every 100, 500, 1000 and 5000 mm. 00012 Each of these markings can be drawn in a different color. Thus, the 00013 100 mm markings can be one color, the 500 mm markings another color, 00014 the 1000 mm markings yet another color, and, finally the 5000 mm 00015 markings in a fourth color. Furthermore, we can also specify the zoom 00016 ranges at which the 100, 500, 1000 and 5000 mm markings should be 00017 visible. 00018 00019 This helps make the laser range finder's distance measurements more 00020 readable and easier to interpret. 00021 */ 00022 00023 // //////////////////////////////////////////////////////////////////// // 00024 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005 // 00025 // by the University of Southern California (USC) and the iLab at USC. // 00026 // See http://iLab.usc.edu for information about this project. // 00027 // //////////////////////////////////////////////////////////////////// // 00028 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00029 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00030 // in Visual Environments, and Applications'' by Christof Koch and // 00031 // Laurent Itti, California Institute of Technology, 2001 (patent // 00032 // pending; application number 09/912,225 filed July 23, 2001; see // 00033 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00034 // //////////////////////////////////////////////////////////////////// // 00035 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00036 // // 00037 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00038 // redistribute it and/or modify it under the terms of the GNU General // 00039 // Public License as published by the Free Software Foundation; either // 00040 // version 2 of the License, or (at your option) any later version. // 00041 // // 00042 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00043 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00044 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00045 // PURPOSE. See the GNU General Public License for more details. // 00046 // // 00047 // You should have received a copy of the GNU General Public License // 00048 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00049 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00050 // Boston, MA 02111-1307 USA. // 00051 // //////////////////////////////////////////////////////////////////// // 00052 // 00053 // Primary maintainer for this file: mviswana usc edu 00054 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Robots/LoBot/ui/LoLaserWindowMarkings.H $ 00055 // $Id: LoLaserWindowMarkings.H 13037 2010-03-23 01:00:53Z mviswana $ 00056 // 00057 00058 #ifndef LOBOT_LASER_WINDOW_MARKINGS_DOT_H 00059 #define LOBOT_LASER_WINDOW_MARKINGS_DOT_H 00060 00061 //------------------------------ HEADERS -------------------------------- 00062 00063 // lobot headers 00064 #include "Robots/LoBot/ui/LoGLCanvas.H" 00065 00066 #include "Robots/LoBot/misc/LoTypes.H" 00067 #include "Robots/LoBot/misc/singleton.hh" 00068 00069 #include "Robots/LoBot/util/LoMath.H" 00070 #include "Robots/LoBot/util/triple.hh" 00071 #include "Robots/LoBot/util/range.hh" 00072 00073 // Standard C++ headers 00074 #include <vector> 00075 00076 //----------------------------- NAMESPACE ------------------------------- 00077 00078 namespace lobot { 00079 00080 //------------------------- CLASS DEFINITION ---------------------------- 00081 00082 /** 00083 \class lobot::LaserWindowMarkings 00084 \brief A helper class for drawing markers indicating distances. 00085 00086 The laser range finder's test program depicts the distance 00087 measurements as rays emanating from the origin of a world coordinate 00088 system that is setup to match the units and range of the LRF device. 00089 To help make sense of the lengths of these rays, we draw some markers 00090 at regular intervals. Each marker indicates a particular distance from 00091 the laser range finder. 00092 00093 We can have markers of different types (e.g., regularly spaced grid or 00094 concentric rings). This class provides a common interface for all the 00095 different marker types. 00096 */ 00097 class LaserWindowMarkings { 00098 /// The markings are drawn using a collection of marking 00099 /// specifications. 00100 //@{ 00101 public: 00102 typedef range<float> ZoomRange ; 00103 typedef triple<float, GLColor, ZoomRange> Marking ; 00104 typedef std::vector<Marking> Markings ; 00105 protected: 00106 Markings m_markings ; 00107 //@} 00108 00109 /// To draw the markings properly, we need to know the current zoom 00110 /// level, which is maintained by the OpenGL canvas. 00111 const GLCanvas* m_canvas ; 00112 00113 /// The markings usually span the range of the laser range finder's 00114 /// maximum distance measurement. For example, if the device's max 00115 /// reading is 30000 mm, then the markings will cover the area between 00116 /// -30000 and +30000 units both horizontally and vertically. 00117 /// 00118 /// Clients must specify this maximum value. 00119 float m_max ; 00120 00121 /// A protected constructor because only derived classes should be 00122 /// able to call it. 00123 LaserWindowMarkings() ; 00124 00125 public: 00126 /// Specify the OpenGL canvas to use. 00127 void use_canvas(const GLCanvas* C) {m_canvas = C ;} 00128 00129 /// We draw the concentric rings (which are contours marking distance 00130 /// from the laser range finder) centered at the canvas's origin and 00131 /// spanning the entire range of the laser range finder's distance 00132 /// measurements. This method allows clients to specify the maximum 00133 /// value in the world coordinate system over which the rings should 00134 /// extend. 00135 void set_maximum(float m) {m_max = abs(m) ;} 00136 00137 /// Draw the markers. Each subclass must implement this method using 00138 /// its own technique for representing the markers. 00139 virtual void render() const = 0 ; 00140 00141 /// Clean-up. 00142 virtual ~LaserWindowMarkings() ; 00143 00144 protected: 00145 /// Helper for drawing the main axes. 00146 void draw_main_axes() const ; 00147 00148 /// This inner class encapsulates various parameters that can be used 00149 /// to tweak different aspects of LRF distance markings. 00150 class Params : public singleton<Params> { 00151 /// Private constructor because this is a singleton. 00152 Params() ; 00153 friend class singleton<Params> ; 00154 00155 /// Whether or not the main axes should be drawn. 00156 bool m_draw_main_axes ; 00157 00158 /// The main axes color. 00159 GLColor m_main_axes_color ; 00160 00161 public: 00162 // Accessing the various parameters 00163 static bool main_axes_enabled() ; 00164 static bool main_axes_disabled() {return ! main_axes_enabled() ;} 00165 static const GLColor& main_axes_color() ; 00166 00167 // Clean-up 00168 ~Params() ; 00169 } ; 00170 } ; 00171 00172 //----------------------------------------------------------------------- 00173 00174 } // end of namespace encapsulating this file's definitions 00175 00176 #endif 00177 00178 /* So things look consistent in everyone's emacs... */ 00179 /* Local Variables: */ 00180 /* indent-tabs-mode: nil */ 00181 /* End: */