PlotBuffer.H

Go to the documentation of this file.
00001 /*!@file ModelNeuron/PlotBuffer.H Class declaration for PlotBuffer,
00002    which will hold and plot information from any SimUnit. */
00003 
00004 // //////////////////////////////////////////////////////////////////// //
00005 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the //
00006 // University of Southern California (USC) and the iLab at USC.         //
00007 // See http://iLab.usc.edu for information about this project.          //
00008 // //////////////////////////////////////////////////////////////////// //
00009 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00010 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00011 // in Visual Environments, and Applications'' by Christof Koch and      //
00012 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00013 // pending; application number 09/912,225 filed July 23, 2001; see      //
00014 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00015 // //////////////////////////////////////////////////////////////////// //
00016 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00017 //                                                                      //
00018 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00019 // redistribute it and/or modify it under the terms of the GNU General  //
00020 // Public License as published by the Free Software Foundation; either  //
00021 // version 2 of the License, or (at your option) any later version.     //
00022 //                                                                      //
00023 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00024 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00025 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00026 // PURPOSE.  See the GNU General Public License for more details.       //
00027 //                                                                      //
00028 // You should have received a copy of the GNU General Public License    //
00029 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00030 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00031 // Boston, MA 02111-1307 USA.                                           //
00032 // //////////////////////////////////////////////////////////////////// //
00033 //
00034 // Primary maintainer for this file: David J. Berg <dberg@usc.edu>
00035 // $HeadURL:svn://ilab.usc.edu/trunk/saliency/src/ModelNeuron/PlotBuffer.H$
00036 
00037 #ifndef MODELNEURON_PLOTBUFFER_H_DEFINED
00038 #define MODELNEURON_PLOTBUFFER_H_DEFINED
00039 
00040 #include "Image/Layout.H"
00041 #include "Image/Image.H"
00042 #include "Image/Pixels.H"
00043 #include "Image/Range.H"
00044 #include "Util/SimTime.H"
00045 
00046 class SimUnit;
00047 // ######################################################################
00048 // ! A class for storing output of simulation units and plotting. 
00049 // ######################################################################
00050 class PlotBuffer
00051 {
00052 public:
00053   //! This will only construct the object. The object will be setup on
00054   //! the first call to push(). w and h set the maximum size of the
00055   //! display. Length is the number of samples to display in the
00056   //! window. Use 0 for length to display all samples.
00057   PlotBuffer();
00058   
00059   //!!destructor
00060   ~PlotBuffer() { };
00061   
00062   //!push data onto the plot buffer
00063   void push(const SimUnit& nsm, const uint length = 250,
00064             const uint depth = 4, const bool usedisplayout = false);
00065   
00066   //!reset the state to that just after construction
00067   void reset();
00068   
00069   //!plot and possibly clear the buffer
00070   Layout<PixRGB<byte> > draw(const bool clear = false, 
00071                              const uint w = 640, const uint h = 480, 
00072                              const Range<double>& range = Range<double>(0.0,0.0));
00073   
00074   //!plot and possibly clear the buffer
00075   void draw(Image<PixRGB<byte> >& img, const bool clear = false, 
00076             const uint w = 640, const uint h = 480, 
00077             const Range<double>& range = Range<double>(0.0,0.0));
00078   
00079   //!set the sampling rate of the input so the x-label can be set correctly
00080   void setSamplingRate(const SimTime& time);
00081 
00082   //!get the total number of units plotted by this buffer
00083   const uint getTotal();
00084   
00085   //!convert a SimeTime object to its SI representation as a
00086   //!string. For example a SimTime object with a value of .001s will
00087   //!return 'milliseconds', an object with a value of .005ms will
00088   //!return "5 microseconds".
00089   static std::string SimTimeToSI(const SimTime& time);
00090   
00091 private:
00092   //!actually add the data. called from push
00093   void addData(const SimUnit& nsm, const uint length , 
00094                const uint depth, const bool usedisplayout = false);  
00095 
00096   //!count the total nodes of our objec hierarchy
00097   void getSubInfo(const SimUnit& nsm, const uint depth);
00098 
00099   std::vector<std::deque<double> > itsData;
00100   std::vector<std::string> names, units;
00101   std::string itsXlabel;
00102   uint itsCount, itsChildCount, itsTotal, itsDepth;
00103 };
00104 
00105 // ######################################################################
00106 // ! A class for storing a list of plotbuffers (lots of 1D plots)
00107 // ######################################################################
00108 class PlotBufferList
00109 {
00110 public:
00111   //!constrcutor
00112   PlotBufferList() : 
00113     itsPb() {};
00114 
00115   //!destructor
00116   ~PlotBufferList() {};
00117 
00118   //!add data from a vector of neural simulation modules
00119   void push(const std::vector<const SimUnit*>& nsm, 
00120             const uint length = 250, const uint depth = 4,
00121             const bool usedisplayout = false);
00122 
00123   //!clear all plots in buffer
00124   void clear();
00125 
00126   //!get a layout of the plot, Dims(1,0) will contatinate images along
00127   //!the horizontal axis. Dims(0,1) will contatinate along the
00128   //!vertical axis. For other Dims configurations the function will
00129   //!attempt to fill a grid, working across columns until the data is
00130   //!exausted for the grid is filled.
00131   Layout<PixRGB<byte> > draw(bool clear = false, const uint w = 640, 
00132                              const uint h = 480, const Dims& d = Dims(0,1), 
00133                              const Range<double>& range = Range<double>(0.0, 0.0));
00134   
00135   //!into an image - see above
00136   void draw(Image<PixRGB<byte> >& img, bool clear = false, 
00137             const uint w = 640, const uint h = 480, const Dims& d = Dims(0,1), 
00138             const Range<double>& range = Range<double>(0.0, 0.0));
00139   
00140   //!set the sampling rate of the input so the x-axis can be properly labeled
00141   void setSamplingRate(const SimTime& samplerate);
00142   
00143 private:
00144   std::vector<PlotBuffer> itsPb;
00145 };
00146 
00147 #endif
00148 
00149 // ######################################################################
00150 /* So things look consistent in everyone's emacs... */
00151 /* Local Variables: */
00152 /* indent-tabs-mode: nil */
00153 /* End: */
Generated on Sun May 8 08:05:21 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3