Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
GLPaintEngine.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/GLPaintEngine.h                        **
00010 ** Module : ICLQt                                                  **
00011 ** Authors: Christof Elbrechter, Robert Haschke                    **
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 #define NOMINMAX // needed for Win32 in order to not define min, max as macros
00034 
00035 #include <ICLUtils/CompatMacros.h>
00036 #include <ICLQt/PaintEngine.h>
00037 #include <QFont>
00038 #include <QtOpenGL/QGLWidget>
00039 
00040 namespace icl{
00041   namespace qt{
00042     
00044 
00056     class ICLQt_API GLPaintEngine : public PaintEngine{
00057       public:
00058       
00059       GLPaintEngine(QGLWidget *widget);
00060       virtual ~GLPaintEngine();
00061       
00062       virtual void color(float r, float g, float b, float a=255);
00063       virtual void fill(float r, float g, float b, float a=255);
00064       virtual void fontsize(float size);
00065       virtual void font(std::string name, 
00066                         float size = -1, 
00067                         PaintEngine::TextWeight weight = PaintEngine::Normal, 
00068                         PaintEngine::TextStyle style = PaintEngine::StyleNormal);
00069   
00070       virtual void linewidth(float w);
00071       virtual void pointsize(float s);
00072       
00073       virtual void line(const utils::Point32f &a, const utils::Point32f &b);
00074       virtual void point(const utils::Point32f &p);
00075       virtual void image(const utils::Rect32f &r,core::ImgBase *image, 
00076                          PaintEngine::AlignMode mode = PaintEngine::Justify, 
00077                          core::scalemode sm=core::interpolateNN);
00078       virtual void image(const utils::Rect32f &r,const QImage &image, 
00079                          PaintEngine::AlignMode mode = PaintEngine::Justify, 
00080                          core::scalemode sm=core::interpolateNN);
00081       virtual void rect(const utils::Rect32f &r);
00082       virtual void triangle(const utils::Point32f &a, const utils::Point32f &b, const utils::Point32f &c);
00083       virtual void quad(const utils::Point32f &a, const utils::Point32f &b, const utils::Point32f &c, const utils::Point32f &d);
00084       virtual void ellipse(const utils::Rect32f &r);
00085       virtual void text(const utils::Rect32f &r, const std::string text, PaintEngine::AlignMode mode = PaintEngine::Centered);
00086   
00088       virtual void bci(float brightness=0, float contrast=0, float intensity=0);
00089       virtual void bciAuto();
00090       
00091       virtual void getColor(float *piColor);
00092       virtual void getFill(float *piColor);
00093   
00094       virtual float getFontSize() const{
00095         return m_font.pointSize();
00096       }
00097       virtual float getLineWidth() const {
00098         return m_linewidth;
00099       }
00100       virtual float getPointSize() const {
00101         return m_pointsize;
00102       }
00103       virtual icl::utils::Size getSize() {
00104         return icl::utils::Size(m_widget->width(),m_widget->height());
00105       }
00106 
00107       // estimates the size of a given text
00108       utils::Size estimateTextBounds(const std::string &text) const;
00109   
00110   
00111       protected:
00112       void setupRasterEngine(const utils::Rect32f& r, const utils::Size32f &s, PaintEngine::AlignMode mode);
00113       void setPackAlignment(core::depth d, int linewidth);
00114       void setupPixelTransfer(core::depth d, float brightness, float contrast, float intensity);
00115   
00116       QGLWidget *m_widget;
00117       
00118       float m_linewidth;
00119       float m_pointsize;
00120       float m_linecolor[4];
00121       float m_fillcolor[4];
00122       float m_bci[3];
00123       bool m_bciauto;
00124   
00125       QFont m_font;
00126   
00127       private:
00128       core::ImgBase *m_incompDepthBuf;
00129     };
00130   } // namespace qt
00131 }// namespace
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines