1 /***********************************************************************/
2 /* Open Visualization Data Explorer */
3 /* (C) Copyright IBM Corp. 1989,1999 */
4 /* ALL RIGHTS RESERVED */
5 /* This code licensed under the */
6 /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */
7 /***********************************************************************/
8
9 #include <dxconfig.h>
10
11
12 #include <dx/dx.h>
13
14 Error
DXQueryPokeCount(Field p,int * knt)15 DXQueryPokeCount(Field p, int *knt)
16 {
17 Array pokes;
18
19 if (DXEmptyField(p))
20 {
21 if (knt) *knt = 0;
22 return OK;
23 }
24
25 pokes = (Array)DXGetComponentValue(p, "pokes");
26 if (! pokes)
27 {
28 DXSetError(ERROR_BAD_PARAMETER,
29 "field does not contain pick information");
30 return ERROR;
31 }
32
33 if (knt)
34 DXGetArrayInfo(pokes, knt, NULL, NULL, NULL, NULL);
35
36 return OK;
37 }
38
39 Error
DXQueryPickCount(Field p,int poke,int * nPicks)40 DXQueryPickCount(Field p, int poke, int *nPicks)
41 {
42 Array pokes;
43 Array picks;
44 int nPokes, thisStart, nextStart;
45
46 if (DXEmptyField(p))
47 {
48 DXSetError(ERROR_BAD_PARAMETER, "non-existent poke");
49 return ERROR;
50 }
51
52 pokes = (Array)DXGetComponentValue(p, "pokes");
53 picks = (Array)DXGetComponentValue(p, "picks");
54 if (! pokes || ! picks)
55 {
56 DXSetError(ERROR_BAD_PARAMETER,
57 "field does not contain pick information");
58 return ERROR;
59 }
60
61 DXGetArrayInfo(pokes, &nPokes, NULL, NULL, NULL, NULL);
62
63 if (poke >= nPokes)
64 {
65 DXSetError(ERROR_BAD_PARAMETER, "non-existent poke");
66 return ERROR;
67 }
68
69 thisStart = ((int *)DXGetArrayData(pokes))[poke];
70
71 if (poke == nPokes-1)
72 {
73 DXGetArrayInfo(picks, &nextStart, NULL, NULL, NULL, NULL);
74 }
75 else
76 {
77 nextStart = ((int *)DXGetArrayData(pokes))[poke+1];
78 }
79
80 if (nPicks)
81 *nPicks = nextStart - thisStart;
82
83 return OK;
84 }
85
86 Error
DXGetPickPoint(Field p,int poke,int pick,Point * point)87 DXGetPickPoint(Field p, int poke, int pick, Point *point)
88 {
89 Array pokes;
90 Array points;
91 int nPokes, index;
92
93 if (DXEmptyField(p))
94 {
95 DXSetError(ERROR_BAD_PARAMETER, "non-existent poke");
96 return ERROR;
97 }
98
99 pokes = (Array)DXGetComponentValue(p, "pokes");
100 points = (Array)DXGetComponentValue(p, "positions");
101 if (! pokes || ! points)
102 {
103 DXSetError(ERROR_BAD_PARAMETER,
104 "field does not contain pick information");
105 return ERROR;
106 }
107
108 DXGetArrayInfo(pokes, &nPokes, NULL, NULL, NULL, NULL);
109
110 if (poke >= nPokes)
111 {
112 DXSetError(ERROR_BAD_PARAMETER, "non-existent poke");
113 return ERROR;
114 }
115
116 index = ((int *)DXGetArrayData(pokes))[poke] + pick;
117
118 if (point)
119 *point = ((Point *)DXGetArrayData(points))[index];
120
121 return OK;
122 }
123
124 Error
DXQueryPickPath(Field p,int poke,int pick,int * len,int ** path,int * eid,int * vid)125 DXQueryPickPath(Field p, int poke, int pick,
126 int *len, int **path, int *eid, int *vid)
127 {
128 Array pokes;
129 Array picks;
130 Array paths;
131 int nPokes, nPicks, nPathElts;
132 int thisPick;
133 int thisPathStart, nextPathStart;
134
135 if (DXEmptyField(p))
136 {
137 DXSetError(ERROR_BAD_PARAMETER, "non-existent poke");
138 return ERROR;
139 }
140
141 pokes = (Array)DXGetComponentValue(p, "pokes");
142 picks = (Array)DXGetComponentValue(p, "picks");
143 paths = (Array)DXGetComponentValue(p, "pick paths");
144 if (! pokes || ! picks || ! paths)
145 {
146 DXSetError(ERROR_BAD_PARAMETER,
147 "field does not contain pick information");
148 return ERROR;
149 }
150
151 DXGetArrayInfo(pokes, &nPokes, NULL, NULL, NULL, NULL);
152 DXGetArrayInfo(picks, &nPicks, NULL, NULL, NULL, NULL);
153 DXGetArrayInfo(paths, &nPathElts, NULL, NULL, NULL, NULL);
154
155 if (poke >= nPokes)
156 {
157 DXSetError(ERROR_BAD_PARAMETER, "non-existent poke");
158 return ERROR;
159 }
160
161 thisPick = ((int *)DXGetArrayData(pokes))[poke] + pick;
162 thisPathStart = ((int *)DXGetArrayData(picks))[thisPick];
163
164 if (thisPick == nPicks-1)
165 {
166 nextPathStart = nPathElts;
167 }
168 else
169 {
170 nextPathStart = ((int *)DXGetArrayData(picks))[thisPick+1];
171 }
172
173 if (len)
174 {
175 *len = (nextPathStart - thisPathStart) - 2;
176 if (*len < 0)
177 *len = 0;
178 }
179
180 if (path)
181 *path = ((int *)DXGetArrayData(paths)) + thisPathStart;
182
183 if (eid)
184 *eid = ((int *)DXGetArrayData(paths))[nextPathStart-2];
185
186 if (vid)
187 *vid = ((int *)DXGetArrayData(paths))[nextPathStart-1];
188
189 return OK;
190 }
191
192 Object
DXTraversePickPath(Object current,int index,Matrix * stack)193 DXTraversePickPath(Object current, int index, Matrix *stack)
194 {
195 Object child;
196 Matrix matrix;
197
198 switch (DXGetObjectClass(current))
199 {
200 case CLASS_FIELD:
201 child = current;
202 break;
203
204 case CLASS_GROUP:
205 child = DXGetEnumeratedMember((Group)current, index, NULL);
206 break;
207
208 case CLASS_XFORM:
209 {
210 DXGetXformInfo((Xform)current, &child, &matrix);
211 if (stack)
212 *stack = DXConcatenate(matrix, *stack);
213
214 break;
215 }
216
217 case CLASS_CLIPPED:
218 DXGetClippedInfo((Clipped)current, &child, NULL);
219 break;
220
221 default:
222 child = NULL;
223 }
224
225 return child;
226 }
227
228
229
230
231