~ubuntu-branches/ubuntu/karmic/gmsh/karmic

« back to all changes in this revision

Viewing changes to Fltk/Opengl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme, Christophe Prud'homme, Daniel Leidert
  • Date: 2008-05-18 12:46:05 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080518124605-716xqbqeo07o497k
Tags: 2.2.0-2
[Christophe Prud'homme]
* Bug fix: "gmsh ships no .desktop", thanks to Vassilis Pandis (Closes:
  #375770). Applied the Ubuntu patch.

[Daniel Leidert]
* debian/control (Vcs-Svn): Fixed.
  (Build-Depends): Use texlive instead of tetex-bin.
* debian/gmsh.doc-base (Section): Fixed accordingly to doc-base (>= 0.8.10).
* debian/rules: Removed some variable declarations, that lead to double
  configuration and seem to be useless.
  (build/gmsh): Try to avoid multiple runs by using a stamp.
  (orig-tarball): Renamed to get-orig-source and changed to use uscan.
* debian/watch: Added.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 $
2
2
//
3
 
// Copyright (C) 1997-2007 C. Geuzaine, J.-F. Remacle
 
3
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
4
4
//
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
19
19
// 
20
20
// Please report all bugs and problems to <gmsh@geuz.org>.
21
21
 
22
 
#include "Gmsh.h"
23
22
#include "GmshUI.h"
 
23
#include "GmshDefines.h"
24
24
#include "Numeric.h"
25
25
#include "Context.h"
26
26
#include "Draw.h"
27
27
#include "SelectBuffer.h"
 
28
#include "StringUtils.h"
28
29
#include "GUI.h"
29
30
#include "gl2ps.h"
30
31
 
45
46
  WID->redraw_opengl();
46
47
}
47
48
 
48
 
void SanitizeTeXString(char *in, char *out)
49
 
{
50
 
  // if there is a '$' or a '\' in the string, assume the author knows
51
 
  // what he's doing:
52
 
  if(strstr(in, "$") || strstr(in, "\\")){
53
 
    strcpy(out, in);
54
 
    return;
55
 
  }
56
 
 
57
 
  if(CTX.print.tex_as_equation) *out++ = '$';
58
 
 
59
 
  // otherwise, escape the following special characters:
60
 
  char bad[8] = { '%', '^', '#', '%', '&', '_', '{', '}' };
61
 
  while(*in){
62
 
    for(unsigned int i = 0; i < sizeof(bad); i++){
63
 
      if(*in == bad[i]){
64
 
        *out++ = '\\';
65
 
        break;
66
 
      }
67
 
    }
68
 
    *out++ = *in++;
69
 
  }
70
 
 
71
 
  if(CTX.print.tex_as_equation) *out++ = '$';
72
 
 
73
 
  *out = '\0';
74
 
}
75
 
 
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)
77
50
{
78
51
  if(CTX.printing && !CTX.print.text) return;
79
52
 
110
83
  }
111
84
  else{
112
85
    if(CTX.print.format == FORMAT_TEX){
113
 
      char tmp[1024];
114
 
      SanitizeTeXString(s, tmp);
 
86
      std::string tmp = sanitizeTeXString(s, CTX.print.tex_as_equation);
115
87
      int opt;
116
88
      switch(align){
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
126
98
      }
127
 
      gl2psTextOpt(tmp, font_name, font_size, opt, 0.);
 
99
      gl2psTextOpt(tmp.c_str(), font_name, font_size, opt, 0.);
128
100
    }
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);
134
106
    }
135
107
    else{
139
111
  }
140
112
}
141
113
 
142
 
void Draw_String(char *s)
 
114
void Draw_String(const char *s)
143
115
{
144
116
  Draw_String(s, CTX.gl_font, CTX.gl_font_enum, CTX.gl_fontsize, 0);
145
117
}
146
118
 
147
 
void Draw_String_Center(char *s)
 
119
void Draw_String_Center(const char *s)
148
120
{
149
121
  Draw_String(s, CTX.gl_font, CTX.gl_font_enum, CTX.gl_fontsize, 1);
150
122
}
151
123
 
152
 
void Draw_String_Right(char *s)
 
124
void Draw_String_Right(const char *s)
153
125
{
154
126
  Draw_String(s, CTX.gl_font, CTX.gl_font_enum, CTX.gl_fontsize, 2);
155
127
}
156
128
 
157
 
void Draw_String(char *s, double style)
 
129
void Draw_String(const char *s, double style)
158
130
{
159
131
  unsigned int bits = (unsigned int)style;
160
132
 
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);
172
144
  }
195
167
// Select entity routine
196
168
 
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*> &regions,
202
 
                  std::vector<MElement*> &elements)
 
170
                  std::vector<GVertex*> &vertices,
 
171
                  std::vector<GEdge*> &edges,
 
172
                  std::vector<GFace*> &faces,
 
173
                  std::vector<GRegion*> &regions,
 
174
                  std::vector<MElement*> &elements)
203
175
{
204
176
  if(!WID) return 'q';
205
177
 
237
209
      WID->undo_selection = 0;
238
210
      return 'u';
239
211
    }
 
212
    if(WID->invert_selection) {
 
213
      WID->invert_selection = 0;
 
214
      return 'i';
 
215
    }
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;
246
 
        return 'c';
 
221
        WID->g_opengl_window->SelectionMode = false;
 
222
        return 'c';
247
223
      }
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,
254
 
                                     elements)){
255
 
        WID->selection = ENT_NONE;
256
 
        WID->g_opengl_window->SelectionMode = false;
257
 
        if(add)
258
 
          return 'l';
259
 
        else
260
 
          return 'r';
 
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,
 
230
                                     elements)){
 
231
        WID->selection = ENT_NONE;
 
232
        WID->g_opengl_window->SelectionMode = false;
 
233
        if(add)
 
234
          return 'l';
 
235
        else
 
236
          return 'r';
261
237
      }
262
238
    }
263
239
  }