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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
/*
* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
* Copyright (C) 1998-2001 - ENPC - Jean-Philipp Chancelier
* Copyright (C) 2004-2006 - INRIA - Fabrice Leray
* Copyright (C) 2011 - DIGITEO - Manuel Juliachs
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at
* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
*
*/
/*------------------------------------------------------------------------
* Graphic library
--------------------------------------------------------------------------*/
#include "math_graphics.h"
#include "PloEch.h"
#include "GetProperty.h"
#include "SetProperty.h"
#include "BuildObjects.h"
#include "Axes.h"
#include "Champ.h"
#include "MALLOC.h" /* MALLOC */
#include "localization.h"
#include "Plot2d.h"
#include "Scierror.h"
#include "createGraphicObject.h"
#include "getGraphicObjectProperty.h"
#include "setGraphicObjectProperty.h"
#include "graphicObjectProperties.h"
#include "CurrentSubwin.h"
#include "CurrentObject.h"
/*-----------------------------------------------------------------
* int C2F(champ)(x,y,fx,fy,n1,n2,strflag,brect,arfact,lstr)
* int C2F(champ1)(x,y,fx,fy,n1,n2,strflag,brect,arfact,lstr)
*
* Used for Drawing 2 dimensional vector fields
* (fx[i+(*n1)*j], fy[i+(*n1)*j]) is the value of the vector field
* at point X=(x[i],y[j]);
*
* - fx and fy are (*n1)*(*n2) matrix of double
* - arfact : a factor by which to multiply the default arrow size
* usr 1.0 by defaut
* - strflag : a string of length 3 (see plot2d)
* - brect=[xmin,ymin,xmax,ymax] (see plot2d)
*
* - lstr : (used when called from Fortran code)
-------------------------------------------------------------------*/
void champg(char *name, int colored, double *x, double *y, double *fx, double *fy, int *n1,
int *n2, char *strflag, double *brect, double *arfact, int lstr)
{
int iSubwinUID = 0;
int iNewSegsUID = 0;
int clipState = 0;
char textLogFlags[3];
double xx[2];
double yy[2];
double* boundingBox = NULL;
double rotationAngles[2];
int nn1 = 1;
int nn2 = 2;
int autoScale = 0;
int* piAutoScale = &autoScale;
int firstPlot = 0;
int* piFirstPlot = &firstPlot;
int logFlags[3];
int flag, type = 1;
double arsize1 = 0.;
int *style = NULL;
int iTmp = 0;
int* piTmp = &iTmp;
int i = 0;
double drect[6];
BOOL bounds_changed = FALSE;
BOOL axes_properties_changed = FALSE;
/* champ with color inherited from subwin */
/* or champ1 (normed vector + color) is enabled */
int typeofchamp = (colored == 0 ? 0 : 1);
/* First create champ object */
/* F.Leray Allocation de style[dim = Nbr1] */
if ((style = (int*)MALLOC ((*n1) * sizeof (int))) == NULL)
{
Scierror(999, _("%s: No more memory.\n"), "champg");
return;
}
flag = 1; /* je le mets � 1 pour voir F.Leray 19.02.04*/
arsize1 = *arfact;
iSubwinUID = getCurrentSubWin();
/* then modify subwindow if needed */
checkRedrawing();
/* Force clipping to CLIPGRF (1) */
clipState = 1;
setGraphicObjectProperty(iSubwinUID, __GO_CLIP_STATE__, &clipState, jni_int, 1);
for (i = 0; i < (*n1); i++)
{
style[i] = i;
}
iNewSegsUID = createChamp(iSubwinUID, x, *n1, y, *n2, fx, *n1 * *n2, fy, *n1 * *n2, arsize1, typeofchamp != 0);
if (iNewSegsUID == 0)
{
Scierror(999, _("%s: No more memory.\n"), "champg");
if (style != NULL)
{
FREE(style);
}
return;
}
setCurrentObject(iNewSegsUID);
if (style != NULL)
{
FREE(style);
style = NULL;
}
/* Get segs bounding box */
getGraphicObjectProperty(iNewSegsUID, __GO_BOUNDING_BOX__, jni_double_vector, (void **)&boundingBox);
xx[0] = boundingBox[0];
xx[1] = boundingBox[1];
yy[0] = boundingBox[2];
yy[1] = boundingBox[3];
releaseGraphicObjectProperty(__GO_BOUNDING_BOX__, boundingBox, jni_double_vector, 4);
rotationAngles[0] = 0.0;
rotationAngles[1] = 270.0;
setGraphicObjectProperty(iSubwinUID, __GO_ROTATION_ANGLES__, rotationAngles, jni_double_vector, 2);
getGraphicObjectProperty(iSubwinUID, __GO_AUTO_SCALE__, jni_bool, (void **)&piAutoScale);
getGraphicObjectProperty(iSubwinUID, __GO_FIRST_PLOT__, jni_bool, (void **)&piFirstPlot);
if (autoScale)
{
/* compute and merge new specified bounds with the data bounds */
switch (strflag[1])
{
case '0':
/* do not change data bounds */
break;
case '1' :
case '3' :
case '5' :
case '7':
/* Force data bounds=brect */
re_index_brect(brect, drect);
break;
case '2' :
case '4' :
case '6' :
case '8':
case '9':
getGraphicObjectProperty(iSubwinUID, __GO_X_AXIS_LOG_FLAG__, jni_bool, (void **)&piTmp);
logFlags[0] = iTmp;
getGraphicObjectProperty(iSubwinUID, __GO_Y_AXIS_LOG_FLAG__, jni_bool, (void **)&piTmp);
logFlags[1] = iTmp;
getGraphicObjectProperty(iSubwinUID, __GO_Z_AXIS_LOG_FLAG__, jni_bool, (void **)&piTmp);
logFlags[2] = iTmp;
/* Conversion required by compute_data_bounds2 */
textLogFlags[0] = getTextLogFlag(logFlags[0]);
textLogFlags[1] = getTextLogFlag(logFlags[1]);
textLogFlags[2] = getTextLogFlag(logFlags[2]);
/* Force data bounds to the x and y bounds */
compute_data_bounds2(0, 'g', textLogFlags, xx, yy, nn1, nn2, drect);
break;
}
/* merge data bounds and drect */
if (!firstPlot &&
(strflag[1] == '7' || strflag[1] == '8' || strflag[1] == '9'))
{
double* dataBounds;
getGraphicObjectProperty(iSubwinUID, __GO_DATA_BOUNDS__, jni_double_vector, (void **)&dataBounds);
drect[0] = Min(dataBounds[0], drect[0]); /*xmin*/
drect[2] = Min(dataBounds[2], drect[2]); /*ymin*/
drect[1] = Max(dataBounds[1], drect[1]); /*xmax*/
drect[3] = Max(dataBounds[3], drect[3]); /*ymax*/
}
if (strflag[1] != '0')
{
bounds_changed = update_specification_bounds(iSubwinUID, drect, 2);
}
}
if (firstPlot)
{
bounds_changed = TRUE;
}
axes_properties_changed = strflag2axes_properties(iSubwinUID, strflag);
/* just after strflag2axes_properties */
firstPlot = 0;
setGraphicObjectProperty(iSubwinUID, __GO_FIRST_PLOT__, &firstPlot, jni_bool, 1);
}
int C2F(champ)(double *x, double *y, double *fx, double *fy, int *n1, int *n2, char *strflag, double *brect, double *arfact, int lstr)
{
champg("champ", 0, x, y, fx, fy, n1, n2, strflag, brect, arfact, lstr);
return(0);
}
int C2F(champ1)(double *x, double *y, double *fx, double *fy, int *n1, int *n2, char *strflag, double *brect, double *arfact, int lstr)
{
champg("champ1", 1, x, y, fx, fy, n1, n2, strflag, brect, arfact, lstr);
return(0);
}
/*----------------------------------------------------------------------------------*/
|