NCBI C++ ToolKit
Go to the documentation of this file.

Go to the SVN repository for this file.

4 /* $Id: render_vector.hpp 43853 2019-09-10 17:42:16Z evgeniev $
5  * ===========================================================================
6  *
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Roman Katargin
30  *
31  * File Description: Common code of vector graphics renderers
32  *
33  */
35 #include <gui/opengl.h>
36 #include <gui/gui.hpp>
43 {
44 public:
45  CRenderVector();
47  virtual void PushAttrib(GLbitfield mask);
48  virtual void PopAttrib();
50  virtual void Enable(GLenum glstate);
51  virtual void Disable(GLenum glstate);
53  virtual void LineWidth(GLfloat w);
54  virtual void PointSize(GLfloat s);
56  virtual void ShadeModel(GLenum mode);
57  virtual void Scissor(GLint x, GLint y,
58  GLsizei width, GLsizei height);
59  /// Color{3,4}{f,d}{v} commands are defined above....
60  virtual void ColorMask(GLboolean red,
61  GLboolean green,
62  GLboolean blue,
63  GLboolean alpha);
65  virtual void PolygonMode(GLenum face, GLenum mode);
66  virtual void LineStipple(GLint factor, GLushort pattern);
67  virtual void PolygonStipple(GLubyte* mask);
68  virtual void BlendFunc(GLenum sfactor, GLenum dfactor);
69  virtual void TexEnvi(GLenum target, GLenum pname, GLint param);
70  virtual void BlendFuncSeparate(GLenum srcRGB, GLenum dstRGB,
71  GLenum srcAlpha, GLenum dstAlpha);
74  virtual void LineCapStyle(IGlState::ELineCapStyle c);
77  virtual void UseProgram(GLuint /*program*/) {}
79  virtual void MatrixMode(GLenum mode);
81  virtual void PushMatrix();
82  virtual void PopMatrix();
83  virtual void LoadIdentity();
84  virtual void LoadMatrixf(const GLfloat *m);
85  virtual void LoadMatrixd(const GLdouble* m);
87  virtual CMatrix4<float> GetModelViewMatrix() const;
88  virtual CMatrix4<float> GetProjectionMatrix() const;
89  virtual void GetModelViewMatrix(GLdouble* m) const;
90  virtual void GetProjectionMatrix(GLdouble* m) const;
92  virtual void Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
93  virtual void Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
94  virtual void Scaled(GLdouble x, GLdouble y, GLdouble z);
95  virtual void Scalef(GLfloat x, GLfloat y, GLfloat z);
96  virtual void Translated(GLdouble x, GLdouble y, GLdouble z);
97  virtual void Translatef(GLfloat x, GLfloat y, GLfloat z);
99  virtual void Ortho(GLdouble left, GLdouble right,
100  GLdouble bottom, GLdouble top,
101  GLdouble nearVal, GLdouble farVal);
103  /// Get font metrics - metrics differ when the font under opengl
104  /// has been replaced by a bitmap font for (screen) readability. Other than
105  /// that, it would be fine to use the glTextureFont metric function directly
106  virtual TModelUnit GetMetric(const CGlTextureFont* font,
107  IGlFont::EMetric metric,
108  const char* text = NULL,
109  int len = -1) const;
110  virtual TModelUnit TextWidth(const CGlTextureFont* font, const char* text) const;
111  virtual TModelUnit TextHeight(const CGlTextureFont* font) const;
112  virtual TModelUnit GetFontDescender(const CGlTextureFont* font) const;
113  virtual TModelUnit GetAdvance(const CGlTextureFont* font, char c) const;
114  virtual TModelUnit GetMaxWidth(const CGlTextureFont* font, int max_num) const;
116 private:
117  struct Matrix
118  {
119  double m[16];
120  };
122  void x_LoadMatrix(const Matrix& m);
123  void x_ApplyTransf(const Matrix& t);
125  static void x_MultMatrix(Matrix& d, const Matrix& s1, const Matrix& s2);
127  static void x_InitMatrixd(Matrix& d, const GLdouble* s);
128  static void x_InitMatrixf(Matrix& d, const GLfloat* s);
129  static void x_FromMatrix(const Matrix& d, GLdouble* res);
130  static CMatrix4<float> x_FromMatrix(const Matrix& d);
133  list<Matrix> m_ProjectionMatrix;
134  list<Matrix> m_ModelViewMatrix;
136  vector<pair<GLbitfield, CGlState> > m_PushedState;
137 };
142 /* @} */
ncbi::TMaskedQueryRegions mask
virtual TModelUnit TextWidth(const CGlTextureFont *font, const char *text) const
virtual TModelUnit GetFontDescender(const CGlTextureFont *font) const
virtual TModelUnit GetMaxWidth(const CGlTextureFont *font, int max_num) const
virtual TModelUnit GetAdvance(const CGlTextureFont *font, char c) const
virtual TModelUnit GetMetric(const CGlTextureFont *font, IGlFont::EMetric metric, const char *text=NULL, int len=-1) const
Calls the standard font metric functions except for pdf in which case it first replaces any bitmap fo...
virtual TModelUnit TextHeight(const CGlTextureFont *font) const
virtual void UseProgram(GLuint)
For shaders. Only works with OpenGL 2.0+.
list< Matrix > m_ModelViewMatrix
vector< pair< GLbitfield, CGlState > > m_PushedState
list< Matrix > m_ProjectionMatrix
#define NULL
Definition: ncbistd.hpp:225
virtual void Translated(GLdouble x, GLdouble y, GLdouble z)=0
GLdouble TModelUnit
Definition: gltypes.hpp:48
virtual void LoadMatrixd(const GLdouble *m)=0
virtual void Scalef(GLfloat x, GLfloat y, GLfloat z)=0
Enumerators for non-enumerated state values (e.g. pdf-only state values)
Definition: glstate.hpp:77
virtual void Translatef(GLfloat x, GLfloat y, GLfloat z)=0
virtual CMatrix4< float > GetProjectionMatrix() const =0
virtual void Enable(GLenum glstate)=0
virtual void LineStipple(GLint factor, GLushort pattern)=0
Set line stipple pattern: glLineStipple(). Deprecated in gl 3.2+.
virtual void Rotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)=0
virtual void BlendFunc(GLenum sfactor, GLenum dfactor)=0
Options to be used when GL_BLEND is enabled.
virtual void ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)=0
Set the color mask (glColorMask)
virtual CMatrix4< float > GetModelViewMatrix() const =0
virtual void MatrixMode(GLenum mode)=0
virtual void PointSize(GLfloat size)=0
Set point size for drawing: glPointSize()
virtual void LineJoinStyle(IGlState::ELineJoinStyle s)=0
PDF-specific rendering state.
virtual void Scissor(GLint x, GLint y, GLsizei width, GLsizei height)=0
Set clipping window: glScissor(x,y,width,height)
virtual void PdfShadeStyle(IGlState::EPdfShadeStyle s)=0
Set (override defualt) shading style for polygons.
virtual void PopAttrib()=0
virtual void PushAttrib(GLbitfield mask)=0
virtual void LoadIdentity()=0
virtual void PopMatrix()=0
virtual void ShadeModel(GLenum mode)=0
Set shade model for default lighting: glShadeModel(GL_FLAT or GL_SMOOTH)
virtual void Rotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)=0
virtual void TexEnvi(GLenum target, GLenum pname, GLint param)=0
virtual void PolygonMode(GLenum face, GLenum mode)=0
Set the polygon rasterization mode.
virtual void PolygonStipple(GLubyte *mask)=0
Set polygon stipple pattern: glPolygonStipple(). Deprecated in gl 3.2+.
Definition: glstate.hpp:78
virtual void LoadMatrixf(const GLfloat *m)=0
Definition: glstate.hpp:79
virtual void LineCapStyle(IGlState::ELineCapStyle c)=0
Set line cap ending style (pdf only)
virtual void Disable(GLenum glstate)=0
virtual void Ortho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal)=0
virtual void LineWidth(GLfloat w)=0
Set line width for drawing: glLineWidth()
virtual void PushMatrix()=0
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
Define ncbi namespace.
Definition: ncbistl.hpp:100
Definition: gui_export.h:514
int len
static void text(MDB_val *v)
Definition: mdb_dump.c:62
mdb_mode_t mode
Definition: lmdb++.h:38
EIPRangeType t
Definition: ncbi_localip.c:101
Standard mechanism to include OpenGL headers for all platforms.
Modified on Sat May 25 14:16:14 2024 by rev. 669887