1
// $Id: Opengl.cpp,v 1.57 2006/01/06 00:34:23 geuzaine Exp $
1
// $Id: Opengl.cpp,v 1.72 2006/12/12 01:39:15 geuzaine Exp $
3
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
3
// Copyright (C) 1997-2007 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
70
70
void Draw_String(char *s, char *font_name, int font_enum, int font_size, int align)
73
// change the raster position only if not creating TeX files
74
if(CTX.print.gl_fonts || (CTX.print.format != FORMAT_TEX)){
76
glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
79
glGetDoublev(GL_CURRENT_RASTER_POSITION, pos);
80
double x[3], w[3] = {pos[0], pos[1], pos[2]};
81
gl_font(font_enum, font_size);
82
float width = gl_width(s);
83
float height = gl_height();
85
case 1: w[0] -= width/2.; break; // bottom center
86
case 2: w[0] -= width; break; // bottom right
87
case 3: w[1] -= height; break; // top left
88
case 4: w[0] -= width/2.; w[1] -= height; break; // top center
89
case 5: w[0] -= width; w[1] -= height; break; // top right
90
case 6: w[1] -= height/2.; break; // center left
91
case 7: w[0] -= width/2.; w[1] -= height/2.; break; // center center
92
case 8: w[0] -= width; w[1] -= height/2.; break; // center right
96
glRasterPos3d(x[0], x[1], x[2]);
72
if(CTX.printing && !CTX.print.text) return;
74
// change the raster position only if not creating TeX files
75
if(align > 0 && (!CTX.printing || CTX.print.format != FORMAT_TEX)){
77
glGetBooleanv(GL_CURRENT_RASTER_POSITION_VALID, &valid);
80
glGetDoublev(GL_CURRENT_RASTER_POSITION, pos);
81
double x[3], w[3] = {pos[0], pos[1], pos[2]};
82
gl_font(font_enum, font_size);
83
float width = gl_width(s);
84
float height = gl_height();
86
case 1: w[0] -= width/2.; break; // bottom center
87
case 2: w[0] -= width; break; // bottom right
88
case 3: w[1] -= height; break; // top left
89
case 4: w[0] -= width/2.; w[1] -= height; break; // top center
90
case 5: w[0] -= width; w[1] -= height; break; // top right
91
case 6: w[1] -= height/2.; break; // center left
92
case 7: w[0] -= width/2.; w[1] -= height/2.; break; // center center
93
case 8: w[0] -= width; w[1] -= height/2.; break; // center right
97
glRasterPos3d(x[0], x[1], x[2]);
101
if(CTX.print.gl_fonts) {
102
102
gl_font(font_enum, font_size);
105
else { // ps, pdf or *tex output
106
if(CTX.print.format == FORMAT_JPEGTEX ||
107
CTX.print.format == FORMAT_PNGTEX)
109
106
if(CTX.print.format == FORMAT_TEX){
111
108
SanitizeTeXString(s, tmp);
124
121
gl2psTextOpt(tmp, font_name, font_size, opt, 0.);
123
else if(CTX.print.eps_quality && (CTX.print.format == FORMAT_PS ||
124
CTX.print.format == FORMAT_EPS ||
125
CTX.print.format == FORMAT_PDF ||
126
CTX.print.format == FORMAT_SVG)){
127
127
gl2psText(s, font_name, font_size);
130
gl_font(font_enum, font_size);
182
189
// Select entity routine
184
char SelectEntity(int type, int *n,
185
Vertex *v[SELECTION_MAX_HITS],
186
Curve *c[SELECTION_MAX_HITS],
187
Surface *s[SELECTION_MAX_HITS])
191
char SelectEntity(int type,
192
std::vector<GVertex*> &vertices,
193
std::vector<GEdge*> &edges,
194
std::vector<GFace*> &faces,
195
std::vector<GRegion*> ®ions,
196
std::vector<MElement*> &elements)
189
200
WID->g_opengl_window->take_focus(); // force keyboard focus in GL window
190
201
WID->g_opengl_window->SelectionMode = true; // enable lasso selection
224
234
if(WID->try_selection) {
225
235
bool add = (WID->try_selection > 0) ? true : false;
226
bool multi = (WID->try_selection > 1) ? true : false;
236
bool multi = (abs(WID->try_selection) > 1) ? true : false;
227
237
WID->try_selection = 0;
228
238
if(WID->selection == ENT_NONE){ // just report the mouse click
229
239
WID->g_opengl_window->SelectionMode = false;
233
*n = Process_SelectionBuffer(WID->selection, multi,
242
else if(ProcessSelectionBuffer(WID->selection, multi, true,
234
243
WID->try_selection_xywh[0],
235
244
WID->try_selection_xywh[1],
236
245
WID->try_selection_xywh[2],
237
246
WID->try_selection_xywh[3],
241
for(int i = 0; i < *n; i++)
242
HighlightEntity(v[i], c[i], s[i], 1);
245
// don't call ZeroHighlight here if we (try to) deselect:
246
// deselection is not supported in all cases, so it's better
247
// to de-highlight the entities in the callback
248
WID->selection = ENT_NONE;
249
WID->g_opengl_window->SelectionMode = false;
247
vertices, edges, faces, regions,
249
WID->selection = ENT_NONE;
250
WID->g_opengl_window->SelectionMode = false;