Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GLImg.h
Go to the documentation of this file.
00001 /********************************************************************
00002 **                Image Component Library (ICL)                    **
00003 **                                                                 **
00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld          **
00005 **                         Neuroinformatics Group                  **
00006 ** Website: www.iclcv.org and                                      **
00007 **          http://opensource.cit-ec.de/projects/icl               **
00008 **                                                                 **
00009 ** File   : ICLQt/src/ICLQt/GLImg.h                                **
00010 ** Module : ICLQt                                                  **
00011 ** Authors: Christof Elbrechter                                    **
00012 **                                                                 **
00013 **                                                                 **
00014 ** GNU LESSER GENERAL PUBLIC LICENSE                               **
00015 ** This file may be used under the terms of the GNU Lesser General **
00016 ** Public License version 3.0 as published by the                  **
00017 **                                                                 **
00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
00019 ** included in the packaging of this file.  Please review the      **
00020 ** following information to ensure the license requirements will   **
00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt                **
00022 **                                                                 **
00023 ** The development of this software was supported by the           **
00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology.    **
00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche       **
00026 ** Forschungsgemeinschaft (DFG) in the context of the German       **
00027 ** Excellence Initiative.                                          **
00028 **                                                                 **
00029 ********************************************************************/
00030 
00031 #pragma once
00032 
00033 #include <ICLUtils/CompatMacros.h>
00034 #include <ICLUtils/Uncopyable.h>
00035 #include <ICLUtils/Function.h>
00036 #include <ICLUtils/Range.h>
00037 #include <ICLMath/FixedVector.h>
00038 #include <ICLCore/ImgBase.h>
00039 #include <ICLQt/ImageStatistics.h>
00040 
00041 namespace icl{
00042   namespace qt{
00044 
00081     class ICLQt_API GLImg : public utils::Uncopyable{
00082       struct Data;  
00083       Data *m_data; 
00084       
00085       public:      
00087 
00092       GLImg(const core::ImgBase *src=0, core::scalemode sm=core::interpolateNN, int maxCellSize=4096);
00093       
00095       ~GLImg();
00096       
00098 
00099       void update(const core::ImgBase *src, int maxCellSize=4096);
00100       
00102       void setScaleMode(core::scalemode sm);
00103       
00105       bool isNull() const;
00106       
00108 
00109       void draw2D(const utils::Rect &r, const utils::Size &windowSize);
00110   
00112 
00113       void draw2D(const float a[2], const float b[2], const float c[2],const float e[2], const utils::Size &windowSize);
00114       
00116 
00129       void draw3D(const float a[3],const float b[3],const float c[3],const float d[3],
00130                   const float na[3]=0, const float nb[3]=0, const float nc[3]=0, const float nd[3]=0,
00131                   const utils::Point32f &texCoordsA=utils::Point32f(0,0),
00132                   const utils::Point32f &texCoordsB=utils::Point32f(1,0),
00133                   const utils::Point32f &texCoordsC=utils::Point32f(0,1),
00134                   const utils::Point32f &texCoordsD=utils::Point32f(1,1));     
00135   
00137 
00139       void draw3DGeneric(int numPoints,
00140                          const float *xs, const float *ys, const float *zs, int xyzStride,
00141                          const utils::Point32f *texCoords, const float *nxs=0, const float *nys=0,
00142                          const float *nzs=0, int nxyzStride=1, bool invertNormals=false);
00143   
00145       inline void draw3D(const float a[3],const float b[3],const float c[3]){
00146         const float d[3] = { b[0] + c[0] -a[0], b[1] + c[1] -a[1], b[2] + c[2] -a[2]  };
00147         draw3D(a,b,c,d);
00148       }
00149   
00150   
00152 
00180       void drawToGrid(int nx, int ny, const float *xs, const float *ys, const float *zs,
00181                       const float *nxs=0, const float *nys=0, const float *nzs=0,
00182                       const int stride = 1, bool invertNormals=false);
00183       
00185       typedef math::FixedColVector<float,3> Vec3;
00186       
00188       typedef utils::Function<Vec3,int,int> grid_function; 
00189       
00191 
00210       void drawToGrid(int nx, int ny, grid_function gridVertices, 
00211                       grid_function gridNormals = grid_function());
00212       
00213   
00215       static int getMaxTextureSize();
00216       
00218       utils::Size getCells() const;
00219       
00221       void bind(int xCell=0, int yCell=0);
00222   
00224       inline utils::Size getSize() const { return utils::Size(getWidth(), getHeight()); }
00225   
00227       int getWidth() const;
00228   
00230       int getHeight() const;
00231   
00233       int getChannels() const;
00234       
00236       core::depth getDepth() const;
00237       
00239       core::format getFormat() const;
00240       
00242       utils::Rect getROI() const;
00243   
00245       utils::Time getTime() const;
00246   
00248 
00249       void setBCI(int b=-1, int c=-1, int i=-1);
00250   
00252       std::vector<utils::Range64f> getMinMax() const;
00253       
00255       std::vector<icl64f> getColor(int x, int y)const;
00256   
00258 
00259       const core::ImgBase *extractImage() const;
00260   
00262       const ImageStatistics &getStats() const;
00263   
00265       void setDrawGrid(bool enabled, float *color=0);
00266   
00268       void setGridColor(float *color);
00269   
00271       const float *getGridColor() const;
00272       
00274       core::scalemode getScaleMode() const;
00275       
00277       void lock() const;
00278   
00280       void unlock() const;
00281   
00282       
00283     };
00284   } // namespace qt
00285 }
00286 
00287 
00288 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines