~ubuntu-branches/ubuntu/natty/avogadro/natty

« back to all changes in this revision

Viewing changes to avogadro/gl2ps/gl2psTest.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Banck, Daniel Leidert, Michael Banck
  • Date: 2010-05-19 18:35:43 UTC
  • mfrom: (3.2.9 sid)
  • Revision ID: james.westby@ubuntu.com-20100519183543-6jb03ca3yb9ar275
Tags: 1.0.1-3
[ Daniel Leidert ]
* debian/avogadro.install: Install manual pages from upstream.
* debian/avogadro.manpages,
  debian/avogadro.1: Dropped in favour of upstream manual pages.
* debian/libavogadro-dev.install: Install .prf file for QMake projects.

[ Michael Banck ]
* debian/rules (DEB_DH_GENCONTROL_ARGS_python-avogadro): Replace
  python$(PYVER)-sip4 by python$(PYVER)-sip (Closes: #581972). 
* debian/rules (binary-install/python-avogadro): Added dh_sip.
* debian/control (python-avogadro/Depends): Added ${sip:Depends}.
* debian/control (Build-Depends): Replaced python-sip4-dev by
  python-sip-dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: gl2psTest.c,v 1.84 2007/05/02 20:57:15 geuzaine Exp $ */
2
1
/*
3
2
 * GL2PS, an OpenGL to PostScript Printing Library
4
 
 * Copyright (C) 1999-2007 Christophe Geuzaine <geuz@geuz.org>
 
3
 * Copyright (C) 1999-2009 Christophe Geuzaine <geuz@geuz.org>
5
4
 *
6
5
 * This program is free software; you can redistribute it and/or
7
6
 * modify it under the terms of either:
28
27
 * library in the file named "COPYING.GL2PS"; if not, I will be glad
29
28
 * to provide one.
30
29
 *
31
 
 * Contributors:
32
 
 *   Rouben Rostamian <rostamian@umbc.edu>
33
 
 *   Guy Barrand <barrand@lal.in2p3.fr>
34
 
 *   Micha Bieber <bieber@traits.de>
 
30
 * For the latest info about gl2ps and a full list of contributors,
 
31
 * see http://www.geuz.org/gl2ps/.
35
32
 *
36
 
 * For the latest info about gl2ps, see http://www.geuz.org/gl2ps/.
37
33
 * Please report all bugs and problems to <gl2ps@geuz.org>.
38
34
 */
39
35
 
136
132
  "*..............................................................*",
137
133
  "****************************************************************"};
138
134
 
139
 
void triangles(void){
 
135
void triangles()
 
136
{
140
137
  /* two intersecting triangles */
141
138
  glBegin(GL_TRIANGLES);
142
139
  
157
154
  glEnd();
158
155
}
159
156
 
160
 
void extras(void){
 
157
void extras()
 
158
{
161
159
  glColor3f(1., 0., 0.);
162
160
 
163
161
  glPointSize(1.);
225
223
  gl2psLineWidth(1);
226
224
}
227
225
 
228
 
void objects(void){
 
226
void objects()
 
227
{
229
228
  glPushMatrix();
230
229
  glEnable(GL_LIGHTING);
231
230
  glRotatef(rotation, 2., 0., 1.);
240
239
  glPopMatrix();
241
240
}
242
241
 
243
 
void printstring(char *string){
 
242
void printstring(char *string, float angle)
 
243
{
244
244
  unsigned int i;
245
245
  char *fonts[] = 
246
246
    { "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic",
250
250
  
251
251
  /* call gl2psText before the glut function since glutBitmapCharacter
252
252
     changes the raster position... */
253
 
  gl2psText(string, fonts[4], 12);
 
253
  gl2psTextOpt(string, fonts[4], 12, GL2PS_TEXT_BL, angle);
254
254
 
255
255
  for (i = 0; i < strlen(string); i++)
256
256
    glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12, string[i]);
257
257
}
258
258
 
259
 
void text(void){
 
259
void text()
 
260
{
260
261
  double x = -1.25, y = -0.33, dy = 0.13;
261
262
 
262
263
  glColor3f(1., 1., 0.);
263
264
 
264
 
  glRasterPos2d(x, y); y -= dy;
265
 
  printstring("Press:");  
266
 
  glRasterPos2d(x, y); y -= dy;
267
 
  printstring("  p: to change the print format (PS, EPS, PDF, ...)");
268
 
  glRasterPos2d(x, y); y -= dy;
269
 
  printstring("  s: to save the images");
270
 
  glRasterPos2d(x, y); y -= dy;
271
 
  printstring("  t: to alternate between teapot and torus");
272
 
  glRasterPos2d(x, y); y -= dy;
273
 
  printstring("  v: to alternate between single and multiple viewport modes");
274
 
  glRasterPos2d(x, y); y -= dy;
275
 
  printstring("  b: to change the blending mode (transparency)");
276
 
  glRasterPos2d(x, y); y -= dy;
277
 
  printstring("  q: to quit");
278
 
  glRasterPos2d(x, y); y -= dy;
279
 
  printstring("Click and move the mouse to rotate the objects");
 
265
  glRasterPos2d(x, y);
 
266
  printstring("Press:", 0.);
 
267
  y -= dy;
 
268
  glRasterPos2d(x, y);
 
269
  printstring("  p: to change the print format (PS, EPS, PDF, ...)", 0.);
 
270
  y -= dy;
 
271
  glRasterPos2d(x, y);
 
272
  printstring("  s: to save the images", 0.);
 
273
  y -= dy;
 
274
  glRasterPos2d(x, y);
 
275
  printstring("  t: to alternate between teapot and torus", 0.);
 
276
  y -= dy;
 
277
  glRasterPos2d(x, y);
 
278
  printstring("  v: to alternate between single and multiple viewport modes", 0.);
 
279
  y -= dy;
 
280
  glRasterPos2d(x, y);
 
281
  printstring("  b: to change the blending mode (transparency)", 0.);
 
282
  y -= dy;
 
283
  glRasterPos2d(x, y);
 
284
  printstring("  q: to quit", 0.), 0.;
 
285
  y -= dy;
 
286
  glRasterPos2d(x, y);
 
287
  printstring("Click and move the mouse to rotate the objects", 0.);
 
288
 
 
289
  glRasterPos2d(0, 0.75);
 
290
  printstring("rotated", 45.);
280
291
 
281
292
  gl2psSpecial(GL2PS_TEX, "% This should only be printed in LaTeX output!");
282
293
}
283
294
 
284
 
void cube(void){
 
295
void cube()
 
296
{
285
297
  glColor3d (0.0,1.0,0.);   
286
298
  glBegin(GL_POLYGON);
287
299
  glVertex3d( 0.5,-0.5,-0.5);
316
328
  glEnd();
317
329
}
318
330
 
319
 
void image(float x, float y, GLboolean opaque){
 
331
void image(float x, float y, GLboolean opaque)
 
332
{
320
333
  int w = 64, h = 66, row, col, pos = 0;
321
334
  float *pixels, r = 0., g = 0., b = 0.;
322
335
 
369
382
}
370
383
 
371
384
/* A simple drawing function, using the default viewport */
372
 
void draw_single(void){
 
385
void draw_single()
 
386
{
373
387
  glScissor(0, 0, window_w, window_h);
374
388
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
375
389
  triangles();
380
394
}
381
395
 
382
396
/* A more complex drawing function, using 2 separate viewports */
383
 
void draw_multi(void){
 
397
void draw_multi()
 
398
{
384
399
  GLint viewport[4];
385
400
 
386
401
  glScissor(0, 0, window_w, window_h);
439
454
  glFlush();
440
455
}
441
456
 
442
 
void display(void){
 
457
void display()
 
458
{
443
459
  GLfloat spec[4] = {0.6, 0.6, 0.6, 1.0};
444
460
  glEnable(GL_DEPTH_TEST);
445
461
  glDepthFunc(GL_LESS);
465
481
  }
466
482
}
467
483
 
468
 
void reshape(int w, int h){
 
484
void reshape(int w, int h)
 
485
{
469
486
  window_w = w;
470
487
  window_h = h;
471
488
 
480
497
}
481
498
 
482
499
void writefile(int format, int sort, int options, int nbcol,
483
 
               char *filename, const char *extension){
 
500
               char *filename, const char *extension)
 
501
{
484
502
  FILE *fp;
485
503
  char file[256];
486
504
  int state = GL2PS_OVERFLOW, buffsize = 0;
520
538
  fflush(stdout);
521
539
}
522
540
 
523
 
void keyboard(unsigned char key, int x, int y){
 
541
void keyboard(unsigned char key, int x, int y)
 
542
{
524
543
  int opt;
525
544
  char ext[32];
526
545
  static int format = GL2PS_PS;
588
607
  }
589
608
}
590
609
 
591
 
void motion(int x, int y){
 
610
void motion(int x, int y)
 
611
{
592
612
  rotation += 10.;
593
613
  display();
594
614
}
595
615
 
596
 
int main(int argc, char **argv){
 
616
int main(int argc, char **argv)
 
617
{
597
618
  glutInit(&argc, argv);
598
619
  glutInitDisplayMode(GLUT_SINGLE | GLUT_DEPTH);
599
620
  glutInitWindowSize(400, 600);