summaryrefslogtreecommitdiffstats
path: root/src/controller/actions/selection_from_db.sqc (plain)
blob: 675bc2c2da28b6b1a7e5897e802c4cebaee4128f
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
#define GL_GLEXT_PROTOTYPES
#include "selection_from_db.h"
#include "../../model/geometry/map_geometry.h"
#include "../../view/state0.h"
#include "../../util/check_error.h"
#include <GL/glut.h>
#include "sqlca.h"
extern struct sqlca sqlca;

/*
 * A simple alias to make the code more readable.
 */
#define S state0

void
selection_from_db (void)
{
  /*
   * db2dclgn -d exp004 -t vis_sel_set
   */
  EXEC SQL BEGIN DECLARE SECTION;
  EXEC SQL INCLUDE 'controller/actions/vis_sel_set.h';
  EXEC SQL END DECLARE SECTION;

  EXEC SQL DECLARE c3 CURSOR FOR
    SELECT * FROM vis_sel_set ORDER BY title, id DESC;

  EXEC SQL OPEN c3;
  check_error (__FILE__, __LINE__);

  /*
   * This loop currently assumes only one set in the table and does
   * not use the title assigned to that set.  This should be improved
   * to allow the user to manage multiple sets by name.
   */
  EXEC SQL FETCH c3 INTO:vis_sel_set;
  while (sqlca.sqlcode != 100)
    {
      int i = vis_sel_set.id - 1;

      /*
       * Loaded sets do not automatically become part of the current
       * selection, however they could be added to it.  This is an
       * issue to work out in the interaction.
       */
      // S.selection.set[i] = true;

      float *c = S.base_colors_data + (i * 4);
      *c = vis_sel_set.r;
      c++;
      *c = vis_sel_set.g;
      c++;
      *c = vis_sel_set.b;
      c++;
      *c = 0.6;

      EXEC SQL FETCH c3 INTO:vis_sel_set;
    }

  EXEC SQL CLOSE c3;
  check_error (__FILE__, __LINE__);

  EXEC SQL COMMIT;
  check_error (__FILE__, __LINE__);

  /*
   * Update the graphics memory.
   */

  glBindBuffer (GL_ARRAY_BUFFER, S.buffers[BASE_COLORS]);
  glColorPointer (4, GL_FLOAT, 0, 0);
  glBufferData (GL_ARRAY_BUFFER,
		sizeof (S.base_colors_data), S.base_colors_data,
		GL_STATIC_DRAW);

  /*
   * Rebuild the display list.
   */
  map_geometry ();

  glutPostRedisplay ();

  return;
}

Valid XHTML 1.0 Strict

Copyright © 2009 Don Pellegrino All Rights Reserved.