1
// $Id: Opengl.cpp,v 1.73 2007-06-22 08:07:46 geuzaine Exp $
1
// $Id: Opengl.cpp,v 1.80 2008-03-20 11:44:03 geuzaine Exp $
3
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
3
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
5
5
// This program is free software; you can redistribute it and/or modify
6
6
// it under the terms of the GNU General Public License as published by
45
46
WID->redraw_opengl();
48
void SanitizeTeXString(char *in, char *out)
50
// if there is a '$' or a '\' in the string, assume the author knows
52
if(strstr(in, "$") || strstr(in, "\\")){
57
if(CTX.print.tex_as_equation) *out++ = '$';
59
// otherwise, escape the following special characters:
60
char bad[8] = { '%', '^', '#', '%', '&', '_', '{', '}' };
62
for(unsigned int i = 0; i < sizeof(bad); i++){
71
if(CTX.print.tex_as_equation) *out++ = '$';
76
void Draw_String(char *s, char *font_name, int font_enum, int font_size, int align)
49
void Draw_String(const char *s, const char *font_name, int font_enum, int font_size, int align)
78
51
if(CTX.printing && !CTX.print.text) return;
112
85
if(CTX.print.format == FORMAT_TEX){
114
SanitizeTeXString(s, tmp);
86
std::string tmp = sanitizeTeXString(s, CTX.print.tex_as_equation);
117
89
case 1: opt = GL2PS_TEXT_B; break; // bottom center
124
96
case 8: opt = GL2PS_TEXT_CR; break; // center right
125
97
default: opt = GL2PS_TEXT_BL; break; // bottom left
127
gl2psTextOpt(tmp, font_name, font_size, opt, 0.);
99
gl2psTextOpt(tmp.c_str(), font_name, font_size, opt, 0.);
129
101
else if(CTX.print.eps_quality && (CTX.print.format == FORMAT_PS ||
130
CTX.print.format == FORMAT_EPS ||
131
CTX.print.format == FORMAT_PDF ||
132
CTX.print.format == FORMAT_SVG)){
102
CTX.print.format == FORMAT_EPS ||
103
CTX.print.format == FORMAT_PDF ||
104
CTX.print.format == FORMAT_SVG)){
133
105
gl2psText(s, font_name, font_size);
142
void Draw_String(char *s)
114
void Draw_String(const char *s)
144
116
Draw_String(s, CTX.gl_font, CTX.gl_font_enum, CTX.gl_fontsize, 0);
147
void Draw_String_Center(char *s)
119
void Draw_String_Center(const char *s)
149
121
Draw_String(s, CTX.gl_font, CTX.gl_font_enum, CTX.gl_fontsize, 1);
152
void Draw_String_Right(char *s)
124
void Draw_String_Right(const char *s)
154
126
Draw_String(s, CTX.gl_font, CTX.gl_font_enum, CTX.gl_fontsize, 2);
157
void Draw_String(char *s, double style)
129
void Draw_String(const char *s, double style)
159
131
unsigned int bits = (unsigned int)style;
166
138
int font = (bits>>8 & 0xff);
167
139
int align = (bits>>16 & 0xff);
168
140
int font_enum = GetFontEnum(font);
169
char *font_name = GetFontName(font);
141
const char *font_name = GetFontName(font);
170
142
if(!size) size = CTX.gl_fontsize;
171
143
Draw_String(s, font_name, font_enum, size, align);
195
167
// Select entity routine
197
169
char SelectEntity(int type,
198
std::vector<GVertex*> &vertices,
199
std::vector<GEdge*> &edges,
200
std::vector<GFace*> &faces,
201
std::vector<GRegion*> ®ions,
202
std::vector<MElement*> &elements)
170
std::vector<GVertex*> &vertices,
171
std::vector<GEdge*> &edges,
172
std::vector<GFace*> &faces,
173
std::vector<GRegion*> ®ions,
174
std::vector<MElement*> &elements)
204
176
if(!WID) return 'q';
237
209
WID->undo_selection = 0;
212
if(WID->invert_selection) {
213
WID->invert_selection = 0;
240
216
if(WID->try_selection) {
241
217
bool add = (WID->try_selection > 0) ? true : false;
242
218
bool multi = (abs(WID->try_selection) > 1) ? true : false;
243
219
WID->try_selection = 0;
244
220
if(WID->selection == ENT_NONE){ // just report the mouse click
245
WID->g_opengl_window->SelectionMode = false;
221
WID->g_opengl_window->SelectionMode = false;
248
224
else if(ProcessSelectionBuffer(WID->selection, multi, true,
249
WID->try_selection_xywh[0],
250
WID->try_selection_xywh[1],
251
WID->try_selection_xywh[2],
252
WID->try_selection_xywh[3],
253
vertices, edges, faces, regions,
255
WID->selection = ENT_NONE;
256
WID->g_opengl_window->SelectionMode = false;
225
WID->try_selection_xywh[0],
226
WID->try_selection_xywh[1],
227
WID->try_selection_xywh[2],
228
WID->try_selection_xywh[3],
229
vertices, edges, faces, regions,
231
WID->selection = ENT_NONE;
232
WID->g_opengl_window->SelectionMode = false;