Image Component Library (ICL)
|
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.GPL ** 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 <ICLQt/PaintEngine.h> 00036 #include <QtGui/QFont> 00037 00038 // forward declaration of the parent class 00039 class QGLWidget; 00040 00041 namespace icl{ 00042 namespace qt{ 00043 00045 00057 class GLPaintEngine : public PaintEngine{ 00058 public: 00059 00060 GLPaintEngine(QGLWidget *widget); 00061 virtual ~GLPaintEngine(); 00062 00063 virtual void color(float r, float g, float b, float a=255); 00064 virtual void fill(float r, float g, float b, float a=255); 00065 virtual void fontsize(float size); 00066 virtual void font(std::string name, 00067 float size = -1, 00068 PaintEngine::TextWeight weight = PaintEngine::Normal, 00069 PaintEngine::TextStyle style = PaintEngine::StyleNormal); 00070 00071 virtual void linewidth(float w); 00072 virtual void pointsize(float s); 00073 00074 virtual void line(const utils::Point32f &a, const utils::Point32f &b); 00075 virtual void point(const utils::Point32f &p); 00076 virtual void image(const utils::Rect32f &r,core::ImgBase *image, 00077 PaintEngine::AlignMode mode = PaintEngine::Justify, 00078 core::scalemode sm=core::interpolateNN); 00079 virtual void image(const utils::Rect32f &r,const QImage &image, 00080 PaintEngine::AlignMode mode = PaintEngine::Justify, 00081 core::scalemode sm=core::interpolateNN); 00082 virtual void rect(const utils::Rect32f &r); 00083 virtual void triangle(const utils::Point32f &a, const utils::Point32f &b, const utils::Point32f &c); 00084 virtual void quad(const utils::Point32f &a, const utils::Point32f &b, const utils::Point32f &c, const utils::Point32f &d); 00085 virtual void ellipse(const utils::Rect32f &r); 00086 virtual void text(const utils::Rect32f &r, const std::string text, PaintEngine::AlignMode mode = PaintEngine::Centered); 00087 00089 virtual void bci(float brightness=0, float contrast=0, float intensity=0); 00090 virtual void bciAuto(); 00091 00092 virtual void getColor(float *piColor); 00093 virtual void getFill(float *piColor); 00094 00095 virtual float getFontSize() const{ 00096 return m_font.pointSize(); 00097 } 00098 virtual float getLineWidth() const { 00099 return m_linewidth; 00100 } 00101 virtual float getPointSize() const { 00102 return m_pointsize; 00103 } 00104 // estimates the size of a given text 00105 utils::Size estimateTextBounds(const std::string &text) const; 00106 00107 00108 protected: 00109 void setupRasterEngine(const utils::Rect32f& r, const utils::Size32f &s, PaintEngine::AlignMode mode); 00110 void setPackAlignment(core::depth d, int linewidth); 00111 void setupPixelTransfer(core::depth d, float brightness, float contrast, float intensity); 00112 00113 QGLWidget *m_widget; 00114 00115 float m_linewidth; 00116 float m_pointsize; 00117 float m_linecolor[4]; 00118 float m_fillcolor[4]; 00119 float m_bci[3]; 00120 bool m_bciauto; 00121 00122 QFont m_font; 00123 00124 private: 00125 core::ImgBase *m_incompDepthBuf; 00126 }; 00127 } // namespace qt 00128 }// namespace