File: Text.h

package info (click to toggle)
pymol 2.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 43,312 kB
  • sloc: cpp: 480,106; python: 79,860; ansic: 28,343; javascript: 6,792; sh: 47; makefile: 30; csh: 8
file content (137 lines) | stat: -rw-r--r-- 5,618 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

/* 
A* -------------------------------------------------------------------
B* This file contains source code for the PyMOL computer program
C* copyright 1998-2003 by Warren Lyford Delano of DeLano Scientific. 
D* -------------------------------------------------------------------
E* It is unlawful to modify or remove this copyright notice.
F* -------------------------------------------------------------------
G* Please see the accompanying LICENSE file for further information. 
H* --------------------------------------------------\-----------------
I* Additional authors of this source file include:
-* 
-* 
-*
Z* -------------------------------------------------------------------
*/
#ifndef _H_Text
#define _H_Text

#include"PyMOLGlobals.h"
#include"Base.h"


/* Here are the issues:

- Many different types of fonts:
   bitmap (glut)
   stroke vector
   3D-vector (extrusion) 
   pixmap (raster)
   texture

- Availability: 
   * we don't want to load fonts which consume resources before they're needed.
   * we don't want to slow down PyMOL launching any more than it already has been

- Performance:
   * really, only vector and texture fonts deliver the performance we seek
   * want zero overhead when using a pre-loaded font (no Python locks allowed)

- Raytracing: 
   * glut font cannot be raytraced, 
   * pixmap and texture mapped fonts need resolution resolution >= PNG file
   * need a geometric stand-in for the font for rendering (filled rect + alpha okay)

- Quality: 
   * vector font looks klunky
   * antialiasing essential if labels are to work with PyMOL imagery

- Flexibility: want to be able to color fonts on the fly, but also support multi-color fonts

- Threading: 
   * font loading will require the Python interpreter lock, since some fonts are defined
   * fonts are global PyMOL data

- Geometric:
   * are fonts rendered in screen space, model space, or both?
   * when we specify size, do we mean screen pixels or model distances?
   * do we support kerning? what other metrics are critical?

- Portability:
   * can we support fonts without C++?  FreeType2 is ANSI C...

*/


/* font_sources */

#define cTextSrcGeneral   0
#define cTextSrcGLUT      1
#define cTextSrcFreeType  2

int TextInit(PyMOLGlobals * G);
void TextFree(PyMOLGlobals * G);

void TextSetLabPos(PyMOLGlobals * G, const float *pos, const LabPosType * labpos, const char *text);
void TextSetColorFromUColor(PyMOLGlobals * G);

void TextSetWorldPos(PyMOLGlobals * G, const float *pos);
float *TextGetWorldPos(PyMOLGlobals * G);
void TextSetLabelPushPos(PyMOLGlobals * G, const float *pos);
float *TextGetLabelPushPos(PyMOLGlobals * G);
void TextSetLabelPos(PyMOLGlobals * G, const float *pos);
float *TextGetLabelPos(PyMOLGlobals * G);
void TextSetLabelPosIsSet(PyMOLGlobals * G, unsigned char isSet);
unsigned char TextGetLabelPosIsSet(PyMOLGlobals * G);
void TextSetScreenWorldOffset(PyMOLGlobals * G, const float *pos);
float *TextGetScreenWorldOffset(PyMOLGlobals * G);
void TextSetTargetPos(PyMOLGlobals * G, const float *pos);
float *TextGetTargetPos(PyMOLGlobals * G);
float TextGetWidth(PyMOLGlobals * G);
float TextGetHeight(PyMOLGlobals * G);
void TextSetWidth(PyMOLGlobals * G, float text_width);
void TextSetHeight(PyMOLGlobals * G, float text_height);
void TextSetIndentFactorX(PyMOLGlobals * G, float factor);
void TextSetIndentFactorY(PyMOLGlobals * G, float factor);
float *TextGetIndentFactor(PyMOLGlobals * G);
void TextSetPos(PyMOLGlobals * G, const float *pos);
void TextSetColor(PyMOLGlobals * G, const float *color);
void TextSetColor3f(PyMOLGlobals * G, float red, float green, float blue);
void TextGetOutlineColor(PyMOLGlobals * G,
                         unsigned char *red,
                         unsigned char *green, unsigned char *blue, unsigned char *alpha);
void TextSetOutlineColor(PyMOLGlobals * G, int color);
void TextSetPosNColor(PyMOLGlobals * G, const float *pos, const float *color);
float *TextGetColor(PyMOLGlobals * G);
float *TextGetPos(PyMOLGlobals * G);
void TextGetColorUChar(PyMOLGlobals * G, unsigned char *red,
                       unsigned char *green, unsigned char *blue, unsigned char *alpha);
unsigned char *TextGetColorUChar4uv(PyMOLGlobals * G);
const char *TextRenderOpenGL(PyMOLGlobals * G, RenderInfo * info, int text_id, const char *st,
                       float size, float *rpos, short needSize, short relativeMode, short shouldRender, CGO *shaderCGO);
const char *TextRenderRay(PyMOLGlobals * G, CRay * ray, int text_id, const char *st, float size,
                    float *rpos, short needSize, short relativeMode);

void TextDrawStrAt(PyMOLGlobals * G, const char *st, int x, int y ORTHOCGOARG);
void TextDrawStr(PyMOLGlobals * G, const char *st ORTHOCGOARG);
void TextIndent(PyMOLGlobals * G, float x, float y);
void TextAdvance(PyMOLGlobals * G, float advance);
void TextSetPos2i(PyMOLGlobals * G, int x, int y);
void TextDrawChar(PyMOLGlobals * G, char ch ORTHOCGOARG);
void TextDrawSubStrFast(PyMOLGlobals * G, const char *c, int x, int y, int start, int n ORTHOCGOARG);
void TextDrawCharRepeat(PyMOLGlobals * G, char c, int x, int y, int start, int n ORTHOCGOARG);

void TextSetLabelBkgrdInfo(PyMOLGlobals * G, float label_spacing, float label_just, const float *buff);

float TextGetSpacing(PyMOLGlobals * G);
float TextGetJustification(PyMOLGlobals * G);
float *TextGetLabelBuffer(PyMOLGlobals * G);

void TextSetIsPicking(PyMOLGlobals * G, bool IsPicking);
bool TextGetIsPicking(PyMOLGlobals * G);

bool TextStartsWithColorCode(const char *);
bool TextSetColorFromCode(PyMOLGlobals *, const char *, const float *);

#endif