Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/post/src/ElmerPost.c
3196 views
1
/*****************************************************************************
2
*
3
* Elmer, A Finite Element Software for Multiphysical Problems
4
*
5
* Copyright 1st April 1995 - , CSC - IT Center for Science Ltd., Finland
6
*
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program (in file fem/GPL-2); if not, write to the
19
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
* Boston, MA 02110-1301, USA.
21
*
22
*****************************************************************************/
23
24
/*******************************************************************************
25
*
26
*
27
*******************************************************************************
28
*
29
* Author: Juha Ruokolainen
30
*
31
* Address: CSC - IT Center for Science Ltd.
32
* Keilaranta 14, P.O. BOX 405
33
* 02101 Espoo, Finland
34
* Tel. +358 0 457 2723
35
* Telefax: +358 0 457 2302
36
* EMail: [email protected]
37
*
38
* Date: 27 Sep 1995
39
*
40
* Modified by:
41
*
42
* Date of modification:
43
*
44
******************************************************************************/
45
46
#define MODULE_MAIN
47
#include "elmerpost.h"
48
#include "../config.h"
49
50
#include <tcl.h>
51
#include <tk.h>
52
53
static char str[512];
54
55
static Tcl_DString TCLCommand;
56
Tcl_Interp *TCLInterp,*TCLIntInterp;
57
58
#define MAX_COLORMAP_ENTRIES 512
59
60
double tx,ty,tz,ax,ay,az,sx=1.,sy=1.,sz=1.,br=0.0,bg=0.0,bb=0.0;
61
double XMin,XMax,YMin,YMax,ZMin,ZMax;
62
63
void opengl_draw(),Mouse();
64
65
static int UpdatePending = FALSE;
66
67
#ifndef MINGW32
68
#include <sys/time.h>
69
#endif
70
71
#define MAX_OBJECTS 10
72
73
static int ShowVectors,ShowContours,ShowColorMesh=1, ShowSpheres,
74
ShowMeshLines,ShowIsosurfaces,ShowParticles,ShowColorScale;
75
76
static int MeshStyle,MeshEdgeStyle=1,MeshLineStyle,MeshQuality = 1;
77
static double MeshRadius = 1.0;
78
static int MeshColorSetMinMax,MeshNodeNumbers=0;
79
static scalar_t MeshColor[MAX_OBJECTS];
80
81
static int ContourLines=5,ContourLineStyle,ContourQuality = 1,ContourColorSetMinMax;
82
static double ContourRadius = 1.0;
83
static scalar_t ContourColor[MAX_OBJECTS],ContourContour[MAX_OBJECTS];
84
85
static int VectorLineStyle,VectorQuality=1;
86
static double VectorRadius=1.0,VectorLengthScale=1.0;
87
88
static scalar_t VectorColor,VectorLength,VectorThreshold;
89
static scalar_t VectorArrow[4];
90
static double VectorCeiling,VectorFloor;
91
92
static int IsosurfaceStyle,IsosurfaceContours=1,IsosurfaceLineStyle,IsosurfaceQuality = 1;
93
static int IsosurfaceRecompute=TRUE, IsosurfaceContourSetMinMax;
94
static double IsosurfaceRadius = 1.0;
95
static scalar_t IsosurfaceContour,IsosurfaceColor,IsosurfaceNormal[4];
96
static int IsosurfaceColorSetMinMax;
97
98
static int ParticleLineStyle,ParticleQuality=1,ParticleNofParticles,ParticleArrowStyle;
99
static int ParticleAdvance=1;
100
static int ParticleIntegMethod=1, ParticleIntegPolicy=1,ParticleStyle;
101
static double ParticleRadius = 1.0, ParticleOutDT = 1.0E-1,
102
ParticleMaxDT = 1.0E-3, ParticleTolerance = 1.0E-5;
103
static scalar_t ParticleParticle[5],ParticleVelocity[4],ParticleColor;
104
105
static double SphereRadiusScale=1.0,SphereFloor,SphereCeiling;
106
static int SphereQuality=1;
107
static scalar_t SphereColor,SphereRadius,SphereThreshold;
108
109
static int ColorScaleEntries,ColorScaleDecimals,ColorScaleStyle,ColorScaleFontColor;
110
static scalar_t ColorScaleColor;
111
static double ColorScaleX,ColorScaleY,ColorScaleThickness,ColorScaleLength,ColorScaleFontSize = 17.0;
112
static int ColorScaleColorSetMinMax;
113
114
static int NumberOfScalarVariables, NumberOfVectorVariables, NumberOfParticleVariables;
115
int CurrentTimeStep, GraphicsClearOn = 1, KeepScale = 0, NormalUpdate = 1;
116
117
double xmin,xmax,ymin,ymax,zmin,zmax;
118
119
// Optional FTGL-text rendering functionality:
120
//=============================================
121
#if defined(HAVE_FTGL_NEW) || defined(HAVE_FTGL_OLD)
122
int FtFont(ClientData,Tcl_Interp*,int,char**);
123
int FtText(ClientData,Tcl_Interp*,int,char**);
124
#endif
125
126
127
static void fpe_sig( int sig ) { signal( SIGFPE, fpe_sig ); }
128
129
static void int_sig( int sig )
130
{
131
fprintf( stdout, "\n^C\n" );
132
133
BreakLoop = TRUE;
134
signal( SIGINT, int_sig );
135
}
136
137
void DrawItSomeTimeWhenIdle()
138
{
139
if ( !UpdatePending )
140
{
141
UpdatePending = TRUE;
142
Tk_DoWhenIdle( (Tk_IdleProc *)opengl_draw,NULL );
143
}
144
}
145
146
static void epSwapBuffers()
147
{
148
auxSwapBuffers();
149
UpdatePending = FALSE;
150
}
151
152
object_t *obj_find( object_t *, char * );
153
object_t *obj_add_object( object_t *, char * );
154
155
static int SetObject( ClientData cl,Tcl_Interp *interp,int argc,char **argv )
156
{
157
object_t *obj;
158
159
obj = (object_t *)obj_find( &VisualObject,argv[1] );
160
if ( !obj ) obj = (object_t *)obj_add_object( &VisualObject, argv[1] );
161
162
Tcl_UnlinkVar( TCLInterp, "MeshColorMin" );
163
Tcl_UnlinkVar( TCLInterp, "MeshColorMax" );
164
165
Tcl_LinkVar( TCLInterp,"MeshColorMin",(char *)&MeshColor[obj->Id].min, TCL_LINK_DOUBLE );
166
Tcl_LinkVar( TCLInterp,"MeshColorMax",(char *)&MeshColor[obj->Id].max, TCL_LINK_DOUBLE );
167
168
Tcl_UnlinkVar( TCLInterp, "ContourColorMin" );
169
Tcl_UnlinkVar( TCLInterp, "ContourColorMax" );
170
171
Tcl_LinkVar( TCLInterp,"ContourColorMin",(char *)&ContourColor[obj->Id].min, TCL_LINK_DOUBLE );
172
Tcl_LinkVar( TCLInterp,"ContourColorMax",(char *)&ContourColor[obj->Id].max, TCL_LINK_DOUBLE );
173
174
CurrentObject = obj;
175
Tcl_Eval( TCLInterp, "math who" );
176
177
return TCL_OK;
178
}
179
180
static int SetParentObject( ClientData cl,Tcl_Interp *interp,int argc,char **argv )
181
{
182
object_t *obj;
183
184
obj = (object_t *)obj_find( &VisualObject,argv[1] );
185
if ( !obj )
186
{
187
sprintf( interp->result, "parent: no such object [%s]", argv[1] );
188
return TCL_ERROR;
189
}
190
191
obj_set_parent( CurrentObject, obj);
192
return TCL_OK;
193
}
194
195
static int GetInterpolate( ClientData cl,Tcl_Interp *interp,int argc,char **argv)
196
{
197
static int r0,g0,b0,r1,g1,b1,n0,n1,i;
198
double r,g,b,dr,dg,db;
199
200
static char result[7*MAX_COLORMAP_ENTRIES],color[32];
201
202
sscanf( argv[1], "%d", &n0 );
203
sscanf( argv[2], "%d", &n1 );
204
205
sscanf( argv[3], "#%02x%02x%02x", &r0,&g0,&b0 );
206
sscanf( argv[4], "#%02x%02x%02x", &r1,&g1,&b1 );
207
208
if ( n0 < n1 )
209
{
210
dr = (r1-r0)/(double)(n1-n0);
211
dg = (g1-g0)/(double)(n1-n0);
212
db = (b1-b0)/(double)(n1-n0);
213
}
214
215
r = r0;
216
g = g0;
217
b = b0;
218
219
result[0] = '\0';
220
for( i=n0; i<n1; i++ )
221
{
222
sprintf( color, "#%02x%02x%02x ",(int)r,(int)g,(int)b );
223
strcat( result, color );
224
225
r += dr;
226
g += dg;
227
b += db;
228
}
229
230
Tcl_SetResult(interp,result,TCL_STATIC);
231
232
return TCL_OK;
233
}
234
235
static int GetColorMap(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
236
{
237
static int first = TRUE,rr, gg, bb, i, n;
238
char *str;
239
colormap_t *cmp = &DefaultColorMap;
240
241
if ( strncmp( argv[1], "-vectors", 8 ) == 0 ) {
242
if ( ArrowColorMap != &DefaultColorMap ) {
243
free( ArrowColorMap->Values );
244
free( ArrowColorMap );
245
}
246
cmp = ArrowColorMap = (colormap_t *)malloc( sizeof(colormap_t) );
247
cmp->Values = NULL;
248
argv++;
249
}
250
else if ( strncmp( argv[1], "-mesh", 5 ) == 0 ) {
251
if ( MeshColorMap != &DefaultColorMap ) {
252
free( MeshColorMap->Values );
253
free( MeshColorMap );
254
}
255
cmp = MeshColorMap = (colormap_t *)malloc( sizeof(colormap_t) );
256
cmp->Values = NULL;
257
argv++;
258
}
259
else if ( strncmp( argv[1], "-contour", 8 ) == 0 ) {
260
if ( ContourColorMap != &DefaultColorMap ) {
261
free( ContourColorMap->Values );
262
free( ContourColorMap );
263
}
264
cmp = ContourColorMap = (colormap_t *)malloc( sizeof(colormap_t) );
265
cmp->Values = NULL;
266
argv++;
267
}
268
else if ( strncmp( argv[1], "-isosurface", 11 ) == 0 ) {
269
if ( IsoSurfaceColorMap != &DefaultColorMap ) {
270
free( IsoSurfaceColorMap->Values );
271
free( IsoSurfaceColorMap );
272
}
273
cmp = IsoSurfaceColorMap = (colormap_t *)malloc( sizeof(colormap_t) );
274
cmp->Values = NULL;
275
argv++;
276
}
277
else if ( strncmp( argv[1], "-sphere", 7 ) == 0 ) {
278
if ( SphereColorMap != &DefaultColorMap ) {
279
free( SphereColorMap->Values );
280
free( SphereColorMap );
281
}
282
argv++;
283
cmp = SphereColorMap = (colormap_t *)malloc( sizeof(colormap_t) );
284
cmp->Values = NULL;
285
}
286
else if ( strncmp( argv[1], "-particles", 9 ) == 0 ) {
287
if ( ParticleColorMap != &DefaultColorMap ) {
288
free( ParticleColorMap->Values );
289
free( ParticleColorMap );
290
}
291
argv++;
292
cmp = ParticleColorMap = (colormap_t *)malloc( sizeof(colormap_t) );
293
cmp->Values = NULL;
294
} else if ( *argv[1] == '-' ) {
295
argv++;
296
}
297
298
sscanf( argv[1], "%d", &n );
299
if ( cmp->Values ) free( cmp->Values );
300
301
cmp->Values = (rgb_t *)calloc(n,sizeof(rgb_t));
302
303
if ( !cmp->Values ) return TCL_ERROR;
304
305
str = argv[2];
306
for( i=0; i<n; i++ )
307
{
308
sscanf( &str[7*i], "#%02x%02x%02x", &rr,&gg,&bb );
309
cmp->Values[i].r = rr;
310
cmp->Values[i].g = gg;
311
cmp->Values[i].b = bb;
312
}
313
314
cmp->Changed = TRUE;
315
cmp->NumberOfEntries = n;
316
317
if ( first )
318
{
319
def_map.Values = (rgb_t *)malloc( n*sizeof(rgb_t) );
320
memcpy( def_map.Values,DefaultColorMap.Values,n*sizeof(rgb_t));
321
def_map.Changed = TRUE;
322
def_map.NumberOfEntries = n;
323
}
324
325
{
326
void UpdateObject(), DrawItSomeTimeWhenIdle();
327
UpdateObject();
328
DrawItSomeTimeWhenIdle();
329
}
330
331
return TCL_OK;
332
}
333
334
static int StopProcessing(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
335
{
336
int_sig( 0 );
337
338
return TCL_OK;
339
}
340
341
static int RecomputeNormals(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
342
{
343
344
geo_vertex_normals( CurrentObject->Geometry, 50.0 );
345
return TCL_OK;
346
}
347
348
static int ClipPlane( ClientData cl,Tcl_Interp *interp,int argc,char **argv)
349
{
350
int i,id;
351
352
if ( argc != 6 ) {
353
sprintf( interp->result, "clip: Wrong number of arguments.\n" );
354
return TCL_ERROR;
355
}
356
357
sscanf( argv[1], "%d", &id );
358
if ( id < 0 || id > 5 ) {
359
sprintf( interp->result, "clip: Plane argument should be from a int from 0..5.\n" );
360
return TCL_ERROR;
361
}
362
CurrentObject->ClipPlane[id] = id;
363
sscanf( argv[2], "%lf", &CurrentObject->ClipEquation[id][0] );
364
sscanf( argv[3], "%lf", &CurrentObject->ClipEquation[id][1] );
365
sscanf( argv[4], "%lf", &CurrentObject->ClipEquation[id][2] );
366
sscanf( argv[5], "%lf", &CurrentObject->ClipEquation[id][3] );
367
368
return TCL_OK;
369
}
370
371
static int UpdateBackColor(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
372
{
373
argv++; argc--;
374
if ( strcmp( *argv, "color") != 0 ) return TCL_ERROR;
375
376
argv++; argc--;
377
if ( argc <= 0 ) return TCL_ERROR;
378
379
argv++; argc--;
380
if ( argc ) sscanf( *argv, "%lf", &br );
381
382
argv++; argc--;
383
if ( argc ) sscanf( *argv, "%lf", &bg );
384
385
argv++; argc--;
386
if ( argc ) sscanf( *argv, "%lf", &bb );
387
388
br /= 100.0;
389
bg /= 100.0;
390
bb /= 100.0;
391
392
DrawItSomeTimeWhenIdle();
393
394
return TCL_OK;
395
}
396
397
static int UpdateColor(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
398
{
399
static int diffuse = FALSE;
400
401
static double r=1.,g=1.,b=1.,alpha=1.0,shininess=0.0,spec_r,spec_g,spec_b;
402
403
double rr,gg,bb;
404
405
material_t *mat = &DefaultMaterial;
406
407
if ( strncmp( argv[1], "-vectors", 8 ) == 0 ) {
408
if ( ArrowMaterial != &DefaultMaterial ) {
409
free( ArrowMaterial );
410
}
411
mat = ArrowMaterial = (material_t *)malloc( sizeof(material_t) );
412
argv++;
413
argc--;
414
}
415
else if ( strncmp( argv[1], "-mesh", 5 ) == 0 ) {
416
if ( MeshMaterial != &DefaultMaterial ) {
417
free( MeshMaterial );
418
}
419
mat = MeshMaterial = (material_t *)malloc( sizeof(material_t) );
420
argv++;
421
argc--;
422
}
423
else if ( strncmp( argv[1], "-contour", 8 ) == 0 ) {
424
if ( ContourMaterial != &DefaultMaterial ) {
425
free( ContourMaterial );
426
}
427
mat = ContourMaterial = (material_t *)malloc( sizeof(material_t) );
428
argv++;
429
argc--;
430
}
431
else if ( strncmp( argv[1], "-isosurface", 11 ) == 0 ) {
432
if ( IsoSurfaceMaterial != &DefaultMaterial ) {
433
free( IsoSurfaceMaterial );
434
}
435
mat = IsoSurfaceMaterial = (material_t *)malloc( sizeof(material_t) );
436
argv++;
437
argc--;
438
}
439
else if ( strncmp( argv[1], "-sphere", 7 ) == 0 ) {
440
if ( SphereMaterial != &DefaultMaterial ) {
441
free( SphereMaterial );
442
}
443
argv++;
444
argc--;
445
mat = SphereMaterial = (material_t *)malloc( sizeof(material_t) );
446
}
447
else if ( strncmp( argv[1], "-particles", 9 ) == 0 ) {
448
if ( ParticleMaterial != &DefaultMaterial ) {
449
free( ParticleMaterial );
450
}
451
argv++;
452
argc--;
453
mat = ParticleMaterial = (material_t *)malloc( sizeof(material_t) );
454
} else if ( strncmp( argv[1], "-default",8 ) ) {
455
argv++;
456
argc--;
457
}
458
459
while( argc )
460
{
461
argv++; argc--;
462
if ( argc )
463
{
464
if ( strcmp( *argv, "opacity" ) == 0 )
465
{
466
argv++; argc--;
467
if ( argc ) { sscanf( *argv, "%lf", &alpha ); alpha /= 100; } else return TCL_ERROR;
468
} else if ( strcmp( *argv, "color" ) == 0 )
469
{
470
argv++; argc--;
471
if ( argc <= 0 ) return TCL_ERROR;
472
473
diffuse = FALSE;
474
if ( strcmp( *argv,"diffuse" ) == 0 ) diffuse = TRUE;
475
476
argv++; argc--;
477
if ( argc > 0 ) sscanf( *argv, "%lf", &rr ); else return TCL_ERROR;
478
479
argv++; argc--;
480
if ( argc > 0 ) sscanf( *argv, "%lf", &gg );
481
482
argv++; argc--;
483
if ( argc > 0 ) sscanf( *argv, "%lf", &bb );
484
485
if ( diffuse )
486
{
487
r = rr / 100.0;
488
g = gg / 100.0;
489
b = bb / 100.0;
490
} else
491
{
492
spec_r = rr / 100.0;
493
spec_g = gg / 100.0;
494
spec_b = bb / 100.0;
495
}
496
} else if ( strcmp( *argv, "shininess" ) == 0 )
497
{
498
argv++; argc--;
499
if ( argc ) { sscanf( *argv, "%lf", &shininess ); } else return TCL_ERROR;
500
}
501
}
502
}
503
504
mat->Changed = TRUE;
505
506
mat->Shininess = shininess;
507
508
mat->Diffuse[0] = r;
509
mat->Diffuse[1] = g;
510
mat->Diffuse[2] = b;
511
mat->Diffuse[3] = alpha;
512
513
mat->Specular[0] = spec_r;
514
mat->Specular[1] = spec_g;
515
mat->Specular[2] = spec_b;
516
mat->Specular[3] = alpha;
517
mat->Changed = TRUE;
518
519
520
{
521
void UpdateObject(), DrawItSomeTimeWhenIdle();
522
UpdateObject();
523
DrawItSomeTimeWhenIdle();
524
}
525
526
return TCL_OK;
527
}
528
529
static int UpdateEdgeColor(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
530
{
531
static int diffuse = FALSE;
532
533
static double r=1.,g=1.,b=1.,alpha=1.0,shininess=0.0,spec_r,spec_g,spec_b;
534
535
double rr,gg,bb;
536
537
while( argc )
538
{
539
argv++; argc--;
540
if ( argc )
541
{
542
if ( strcmp( *argv, "opacity" ) == 0 )
543
{
544
argv++; argc--;
545
if ( argc ) { sscanf( *argv, "%lf", &alpha ); alpha /= 100; } else return TCL_ERROR;
546
} else if ( strcmp( *argv, "color" ) == 0 )
547
{
548
argv++; argc--;
549
if ( argc <= 0 ) return TCL_ERROR;
550
551
diffuse = FALSE;
552
if ( strcmp( *argv,"diffuse" ) == 0 ) diffuse = TRUE;
553
554
argv++; argc--;
555
if ( argc > 0 ) sscanf( *argv, "%lf", &rr ); else return TCL_ERROR;
556
557
argv++; argc--;
558
if ( argc > 0 ) sscanf( *argv, "%lf", &gg );
559
560
argv++; argc--;
561
if ( argc > 0 ) sscanf( *argv, "%lf", &bb );
562
563
if ( diffuse )
564
{
565
r = rr / 100.0;
566
g = gg / 100.0;
567
b = bb / 100.0;
568
} else
569
{
570
spec_r = rr / 100.0;
571
spec_g = gg / 100.0;
572
spec_b = bb / 100.0;
573
}
574
} else if ( strcmp( *argv, "shininess" ) == 0 )
575
{
576
argv++; argc--;
577
if ( argc ) { sscanf( *argv, "%lf", &shininess ); } else return TCL_ERROR;
578
}
579
}
580
}
581
582
DefaultEdgeMaterial.Changed = TRUE;
583
584
DefaultEdgeMaterial.Shininess = shininess;
585
586
DefaultEdgeMaterial.Diffuse[0] = r;
587
DefaultEdgeMaterial.Diffuse[1] = g;
588
DefaultEdgeMaterial.Diffuse[2] = b;
589
DefaultEdgeMaterial.Diffuse[3] = alpha;
590
591
DefaultEdgeMaterial.Specular[0] = spec_r;
592
DefaultEdgeMaterial.Specular[1] = spec_g;
593
DefaultEdgeMaterial.Specular[2] = spec_b;
594
DefaultEdgeMaterial.Specular[3] = alpha;
595
596
DrawItSomeTimeWhenIdle();
597
598
return TCL_OK;
599
}
600
601
602
static void GetScalarVariable( scalar_t *Func, char *name, element_model_t *model, int TimeAll, int SetMinMax )
603
{
604
char str[256];
605
606
VARIABLE *var;
607
608
double *T;
609
610
int len = strlen(name)-1, index = 0, n, t, i;
611
612
strcpy(str,name);
613
614
if ( str[len-1] == '_' )
615
{
616
index = str[len] - 'x';
617
str[len-1] = 0;
618
}
619
620
Func->f = NULL;
621
622
if ( !(var = (VARIABLE *)lst_find( VARIABLES, str ) ) ) return;
623
624
n = NCOL(var) % model->NofNodes;
625
t = NCOL(var) / model->NofNodes - 1;
626
627
if ( n || t < 0 ) return;
628
629
T = &M(var,index,0);
630
if ( TimeAll )
631
Func->f = T;
632
else
633
Func->f = &T[MIN(CurrentTimeStep,t)*model->NofNodes];
634
635
if ( !SetMinMax ) return;
636
637
Func->min = 1.0e20;
638
Func->max = -1.0e20;
639
for( i=0; i<NCOL(var); i++ )
640
{
641
Func->min = MIN( Func->min, T[i] );
642
Func->max = MAX( Func->max, T[i] );
643
}
644
645
if ( Func->name ) free( Func->name );
646
Func->name = (char *)malloc( len+2 );
647
strcpy( Func->name, name );
648
}
649
650
static void GetVectorVariable( scalar_t Func[4], char *name, element_model_t *model, int TimeAll )
651
{
652
VARIABLE *var;
653
654
double *T;
655
656
int i,n,t,index;
657
Func[0].f = Func[1].f =
658
Func[2].f = Func[3].f = NULL;
659
660
if ( !(var = (VARIABLE *)lst_find( VARIABLES, name ) ) ) return;
661
662
n = NCOL(var) % model->NofNodes;
663
t = NCOL(var) / model->NofNodes - 1;
664
665
if ( n || t < 0 ) return;
666
667
if ( TimeAll )
668
{
669
Func[1].f = &M(var,0,0);
670
Func[2].f = &M(var,1,0);
671
Func[3].f = &M(var,2,0);
672
} else
673
{
674
T = &M(var,0,0);
675
Func[1].f = &T[MIN(CurrentTimeStep,t)*model->NofNodes];
676
677
T = &M(var,1,0);
678
Func[2].f = &T[MIN(CurrentTimeStep,t)*model->NofNodes];
679
680
T = &M(var,2,0);
681
Func[3].f = &T[MIN(CurrentTimeStep,t)*model->NofNodes];
682
}
683
684
for( n=1; n<4; n++ )
685
{
686
Func[n].min = 1.0e20;
687
Func[n].max = -1.0e20;
688
for( i=0; i<NCOL(var); i++ )
689
{
690
Func[n].min = MIN( Func[n].min, M(var,n-1,i) );
691
Func[n].max = MAX( Func[n].max, M(var,n-1,i) );
692
}
693
}
694
}
695
696
static void GetParticleVariable( scalar_t Func[5], char *name )
697
{
698
VARIABLE *var;
699
700
double *T;
701
702
int i,n,index;
703
704
var = (VARIABLE *)lst_find( VARIABLES, name );
705
706
Func[0].f =
707
Func[1].f =
708
Func[2].f =
709
Func[3].f =
710
Func[4].f = NULL;
711
712
if ( !var || NROW(var) != 5 ) return;
713
714
Func[0].f = &M(var,0,0);
715
Func[1].f = &M(var,1,0);
716
Func[2].f = &M(var,2,0);
717
Func[3].f = &M(var,3,0);
718
Func[4].f = &M(var,4,0);
719
720
ParticleNofParticles = NCOL(var);
721
}
722
723
724
static int UpdateVariable( ClientData cl,Tcl_Interp *interp,int argc,char **argv)
725
{
726
element_model_t *model = CurrentObject->ElementModel;
727
728
if ( !model ) return TCL_OK;
729
730
if ( strcmp( argv[1], "VectorColor") == 0 )
731
732
GetScalarVariable( &VectorColor, (char *)Tcl_GetVar( TCLInterp,argv[1],TCL_GLOBAL_ONLY ),model, 0, TRUE );
733
734
else if ( strcmp( argv[1], "VectorLength" ) == 0 )
735
736
GetScalarVariable( &VectorLength, (char *)Tcl_GetVar( TCLInterp,argv[1],TCL_GLOBAL_ONLY ),model, 0, TRUE );
737
738
else if ( strcmp( argv[1], "VectorThreshold" ) == 0 )
739
740
GetScalarVariable( &VectorThreshold, (char *)Tcl_GetVar( TCLInterp,argv[1],TCL_GLOBAL_ONLY ),model, 0, TRUE );
741
742
else if ( strcmp( argv[1], "MeshColor" ) == 0 )
743
744
GetScalarVariable( &MeshColor[CurrentObject->Id],
745
(char *)Tcl_GetVar( TCLInterp,argv[1],TCL_GLOBAL_ONLY ),model,0,!MeshColorSetMinMax );
746
747
else if ( strcmp( argv[1], "ColorScaleColor" ) == 0 )
748
749
GetScalarVariable( &ColorScaleColor, (char *)Tcl_GetVar( TCLInterp,argv[1],TCL_GLOBAL_ONLY ),model, 0, !ColorScaleColorSetMinMax );
750
751
else if ( strcmp( argv[1], "ContourColor" ) == 0 )
752
753
GetScalarVariable( &ContourColor[CurrentObject->Id],
754
(char *)Tcl_GetVar( TCLInterp,argv[1],TCL_GLOBAL_ONLY ),model, 0, !ContourColorSetMinMax );
755
756
else if ( strcmp( argv[1], "ContourContour" ) == 0 )
757
758
GetScalarVariable( &ContourContour[0], (char *)Tcl_GetVar( TCLInterp,argv[1],TCL_GLOBAL_ONLY ),model, 0, TRUE );
759
760
else if ( strcmp( argv[1], "IsosurfaceColor" ) == 0 )
761
762
GetScalarVariable( &IsosurfaceColor, (char *)Tcl_GetVar( TCLInterp,argv[1],TCL_GLOBAL_ONLY ),model, 0, !IsosurfaceColorSetMinMax );
763
764
else if ( strcmp( argv[1], "IsosurfaceContour" ) == 0 )
765
766
GetScalarVariable( &IsosurfaceContour, (char *)Tcl_GetVar( TCLInterp,argv[1],TCL_GLOBAL_ONLY ),model, 0, !IsosurfaceContourSetMinMax );
767
768
else if ( strcmp( argv[1], "ParticleColor" ) == 0 )
769
770
GetScalarVariable( &ParticleColor, (char *)Tcl_GetVar( TCLInterp,argv[1],TCL_GLOBAL_ONLY ),model, 0, TRUE );
771
772
else if ( strcmp( argv[1], "SphereThreshold" ) == 0 )
773
774
GetScalarVariable( &SphereThreshold, (char *)Tcl_GetVar( TCLInterp,argv[1],TCL_GLOBAL_ONLY ),model, 0, TRUE );
775
776
return TCL_OK;
777
}
778
779
780
static int TimeStep(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
781
{
782
double s;
783
static int n,i,j;
784
785
element_model_t *ElementModel = CurrentObject->ElementModel;
786
787
if ( argc != 2 )
788
{
789
sprintf( interp->result, "c_TimeStep: wrong number of parameters.\n" );
790
return TCL_ERROR;
791
}
792
793
if ( !ElementModel ) return TCL_OK;
794
795
n = 0;
796
sscanf( argv[1], "%d", &n );
797
798
if ( n < 0 || n >= ElementModel->NofTimesteps )
799
{
800
sprintf( interp->result, "c_TimeStep: Invalid timestep.\n" );
801
return TCL_ERROR;
802
}
803
804
CurrentTimeStep = n;
805
806
{
807
static vertex_t *vertex;
808
809
vertex = CurrentObject->Geometry->Vertices;
810
811
if ( !KeepScale ) {
812
xmin = ymin = zmin = 1.0e20;
813
xmax = ymax = zmax = -1.0e20;
814
815
for( i=0; i<CurrentObject->ElementModel->NofNodes; i++ )
816
{
817
xmin = MIN( xmin,ElementModel->NodeArray[i] );
818
ymin = MIN( ymin,ElementModel->NodeArray[ElementModel->NofNodes+i] );
819
zmin = MIN( zmin,ElementModel->NodeArray[2*ElementModel->NofNodes+i] );
820
821
xmax = MAX( xmax,ElementModel->NodeArray[i] );
822
ymax = MAX( ymax,ElementModel->NodeArray[ElementModel->NofNodes+i] );
823
zmax = MAX( zmax,ElementModel->NodeArray[2*ElementModel->NofNodes+i] );
824
}
825
826
s = MAX(MAX(xmax-xmin,ymax-ymin),zmax-zmin);
827
828
CurrentObject->Geometry->Scale = s;
829
CurrentObject->Geometry->MinMax[0].x[0] = xmin;
830
CurrentObject->Geometry->MinMax[0].x[1] = ymin;
831
CurrentObject->Geometry->MinMax[0].x[2] = zmin;
832
833
CurrentObject->Geometry->MinMax[1].x[0] = xmax;
834
CurrentObject->Geometry->MinMax[1].x[1] = ymax;
835
CurrentObject->Geometry->MinMax[1].x[2] = zmax;
836
} else {
837
s = CurrentObject->Geometry->Scale;
838
xmin = CurrentObject->Geometry->MinMax[0].x[0];
839
ymin = CurrentObject->Geometry->MinMax[0].x[1];
840
zmin = CurrentObject->Geometry->MinMax[0].x[2];
841
842
xmax = CurrentObject->Geometry->MinMax[1].x[0];
843
ymax = CurrentObject->Geometry->MinMax[1].x[1];
844
zmax = CurrentObject->Geometry->MinMax[1].x[2];
845
}
846
847
for( i=0; i<ElementModel->NofNodes; i++,vertex++ )
848
{
849
vertex->x[0] = (2.0 * (ElementModel->NodeArray[i]-xmin)-(xmax-xmin))/s;
850
vertex->x[1] = (2.0 * (ElementModel->NodeArray[ElementModel->NofNodes+i]-ymin)-(ymax-ymin)) / s;
851
vertex->x[2] = (2.0 * (ElementModel->NodeArray[2*ElementModel->NofNodes+i]-zmin)-(zmax-zmin)) / s;
852
}
853
}
854
855
856
/*
857
* DrawItSomeTimeWhenIdle();
858
* opengl_draw();
859
*/
860
861
return TCL_OK;
862
}
863
864
static void cam_set_current( camera_t *camera )
865
{
866
static char str[200];
867
868
Tcl_SetVar2( TCLInterp, "camera","name", camera->Name, TCL_GLOBAL_ONLY );
869
870
Tcl_SetVar2( TCLInterp, "camera","display", "on", TCL_GLOBAL_ONLY );
871
872
if ( camera->ProjectionType == camera_proj_ortho )
873
Tcl_SetVar2( TCLInterp, "camera","projection", "ortho",TCL_GLOBAL_ONLY );
874
else
875
Tcl_SetVar2( TCLInterp, "camera","projection", "perspective",TCL_GLOBAL_ONLY );
876
877
sprintf( str, "%g", camera->LookFromX );
878
Tcl_SetVar2( TCLInterp, "camera","from_x", str, TCL_GLOBAL_ONLY );
879
880
sprintf( str, "%g", camera->LookFromY );
881
Tcl_SetVar2( TCLInterp, "camera","from_y", str, TCL_GLOBAL_ONLY );
882
883
sprintf( str, "%g", camera->LookFromZ );
884
Tcl_SetVar2( TCLInterp, "camera","from_z", str, TCL_GLOBAL_ONLY );
885
886
sprintf( str, "%g", camera->LookAtX );
887
Tcl_SetVar2( TCLInterp, "camera","to_x", str, TCL_GLOBAL_ONLY );
888
889
sprintf( str, "%g", camera->LookAtY );
890
Tcl_SetVar2( TCLInterp, "camera", "to_y", str, TCL_GLOBAL_ONLY );
891
892
sprintf( str, "%g", camera->LookAtZ );
893
Tcl_SetVar2( TCLInterp, "camera","to_z", str, TCL_GLOBAL_ONLY );
894
895
sprintf( str, "%g", camera->UpX );
896
Tcl_SetVar2( TCLInterp, "camera","up_x", str, TCL_GLOBAL_ONLY );
897
898
sprintf( str, "%g", camera->UpY );
899
Tcl_SetVar2( TCLInterp, "camera","up_y", str, TCL_GLOBAL_ONLY );
900
901
sprintf( str, "%g", camera->UpZ );
902
Tcl_SetVar2( TCLInterp, "camera","up_z", str, TCL_GLOBAL_ONLY );
903
904
sprintf( str, "%g", camera->FieldAngle );
905
Tcl_SetVar2( TCLInterp, "camera","field_angle", str, TCL_GLOBAL_ONLY );
906
907
sprintf( str, "%g", camera->ClipNear );
908
Tcl_SetVar2( TCLInterp, "camera","near", str, TCL_GLOBAL_ONLY );
909
910
sprintf( str, "%g", camera->ClipFar );
911
Tcl_SetVar2( TCLInterp, "camera","far", str, TCL_GLOBAL_ONLY );
912
913
sprintf( str, "%g", camera->ViewportLowX );
914
Tcl_SetVar2( TCLInterp, "camera","view_low_x", str, TCL_GLOBAL_ONLY );
915
916
sprintf( str, "%g", camera->ViewportLowY );
917
Tcl_SetVar2( TCLInterp, "camera","view_low_y", str, TCL_GLOBAL_ONLY );
918
919
sprintf( str, "%g", camera->ViewportHighX );
920
Tcl_SetVar2( TCLInterp, "camera","view_high_x", str, TCL_GLOBAL_ONLY );
921
922
sprintf( str, "%g", camera->ViewportHighY );
923
Tcl_SetVar2( TCLInterp, "camera","view_high_y", str, TCL_GLOBAL_ONLY );
924
}
925
926
/*******************************************************************************
927
*
928
* Name: cam_load_cameras
929
*
930
* Purpose: Initialize camerass from default cam setting file
931
*
932
* Parameters:
933
*
934
* Input: none
935
*
936
* Output: none
937
*
938
* Return value: New list of (camera_t *)cameras
939
*
940
*******************************************************************************/
941
static camera_t *cam_load_cameras( camera_t *camera,char *FileName )
942
{
943
static char name[200],str[200],variable[64],value[64];
944
FILE *fp = NULL;
945
946
int i;
947
948
float x,y,z,w;
949
950
camera_t *first_cam = camera;
951
952
if ( !FileName || !(fp = fopen( FileName,"r") ) )
953
{
954
sprintf( name, "%s/lib/cameras/default", getenv("ELMER_POST_HOME") );
955
956
if ( !(fp = fopen( name, "r" ) ) )
957
{
958
camera = (camera_t *)cam_add_camera( NULL, "camera1" );
959
if ( !first_cam ) first_cam = camera;
960
961
cam_set_viewport( camera,0.0,0.0,1.0,1.0 );
962
cam_set_look_to( camera,0.0,0.0,0.0,FALSE );
963
cam_set_up_vector( camera,0.0,1.0,0.0 );
964
cam_set_look_from( camera,0.0,0.0,5.0,FALSE );
965
cam_set_clip( camera,1.0,20.0 );
966
cam_set_onoff( camera, TRUE );
967
}
968
}
969
970
971
if ( fp ) {
972
while( fgets( str,100, fp ) )
973
{
974
if ( sscanf( str, "camera %s", name ) == 1 )
975
{
976
camera = (camera_t *)cam_add_camera( camera, name );
977
if ( !first_cam ) first_cam = camera;
978
cam_set_onoff( camera, TRUE );
979
} else if ( sscanf( str, "from %f %f %f", &x,&y,&z ) == 3 )
980
{
981
cam_set_look_from( camera,x,y,z,FALSE );
982
983
} else if ( sscanf( str, "to %f %f %f", &x,&y,&z ) == 3)
984
{
985
cam_set_look_to( camera,x,y,z,FALSE );
986
987
} else if ( sscanf( str, "viewport %f %f %f %f", &x,&y,&z,&w ) == 4 )
988
{
989
cam_set_viewport( camera,x,y,z,w );
990
991
} else if ( sscanf( str, "up %f %f %f", &x, &y, &z ) == 3 )
992
{
993
cam_set_up_vector( camera, x,y,z );
994
995
} else if ( sscanf( str, "projection %s", name ) == 1 )
996
{
997
if ( strcmp( name,"perspective" ) == 0 )
998
cam_set_projection( camera, camera_proj_perspective );
999
else
1000
cam_set_projection( camera, camera_proj_ortho );
1001
} else if ( sscanf( str, "field angle %f", &x ) == 1 )
1002
{
1003
cam_set_field_angle( camera, x );
1004
} else if ( sscanf( str, "clip %f %f", &x, &y ) == 2 )
1005
{
1006
cam_set_clip( camera,x,y );
1007
}
1008
}
1009
}
1010
1011
if ( camera ) cam_set_current( camera );
1012
1013
if ( fp )
1014
{
1015
fclose( fp );
1016
}
1017
1018
i = 0;
1019
for( camera=first_cam; camera != NULL; camera=camera->Next,i++ )
1020
{
1021
sprintf( str, "%d", i );
1022
Tcl_SetVar2( TCLInterp, "camera_names",str, camera->Name, TCL_GLOBAL_ONLY );
1023
}
1024
sprintf( str, "%d", i );
1025
Tcl_SetVar( TCLInterp, "camera_n", str, TCL_GLOBAL_ONLY );
1026
1027
return first_cam;
1028
}
1029
1030
1031
static int CurrentCamera(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
1032
{
1033
camera_t *cam;
1034
int i;
1035
1036
if ( argc != 2 )
1037
{
1038
sprintf( interp->result, "camera: wrong number of arguments\n" );
1039
return TCL_ERROR;
1040
}
1041
1042
i = 0;
1043
for( cam=Camera; cam!=NULL; cam=cam->Next,i++ )
1044
{
1045
if ( strcmp( cam->Name, argv[1] ) == 0 )
1046
{
1047
cam_set_current( cam );
1048
sprintf( interp->result, "%d", i );
1049
return TCL_OK;
1050
}
1051
}
1052
1053
return TCL_ERROR;
1054
}
1055
1056
1057
static int SetCamera(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
1058
{
1059
static char str[200];
1060
1061
float x,y,z,w;
1062
1063
camera_t *camera = NULL;
1064
1065
camera = (camera_t *)cam_add_camera( Camera,
1066
(char *)Tcl_GetVar2( TCLInterp,"camera","name", TCL_GLOBAL_ONLY ) );
1067
1068
if ( camera ) {
1069
sscanf( Tcl_GetVar2( TCLInterp, "camera","display", TCL_GLOBAL_ONLY ), "%s", str );
1070
if ( strcmp( str, "off" ) == 0 )
1071
cam_set_onoff( camera, FALSE );
1072
else
1073
cam_set_onoff( camera, TRUE );
1074
1075
sscanf( Tcl_GetVar2( TCLInterp, "camera","from_x", TCL_GLOBAL_ONLY ), "%f", &x );
1076
sscanf( Tcl_GetVar2( TCLInterp, "camera","from_y", TCL_GLOBAL_ONLY ), "%f", &y );
1077
sscanf( Tcl_GetVar2( TCLInterp, "camera","from_z", TCL_GLOBAL_ONLY ), "%f", &z );
1078
cam_set_look_from( camera,x,y,z,FALSE );
1079
1080
sscanf( Tcl_GetVar2( TCLInterp, "camera","to_x", TCL_GLOBAL_ONLY ), "%f", &x );
1081
sscanf( Tcl_GetVar2( TCLInterp, "camera","to_y", TCL_GLOBAL_ONLY ), "%f", &y );
1082
sscanf( Tcl_GetVar2( TCLInterp, "camera","to_z", TCL_GLOBAL_ONLY ), "%f", &z );
1083
cam_set_look_to( camera,x,y,z,FALSE );
1084
1085
sscanf( Tcl_GetVar2( TCLInterp, "camera","up_x", TCL_GLOBAL_ONLY ), "%f", &x );
1086
sscanf( Tcl_GetVar2( TCLInterp, "camera","up_y", TCL_GLOBAL_ONLY ), "%f", &y );
1087
sscanf( Tcl_GetVar2( TCLInterp, "camera","up_z", TCL_GLOBAL_ONLY ), "%f", &z );
1088
cam_set_up_vector( camera,x,y,z );
1089
1090
sscanf( Tcl_GetVar2( TCLInterp, "camera","view_low_x", TCL_GLOBAL_ONLY ), "%f", &x );
1091
sscanf( Tcl_GetVar2( TCLInterp, "camera","view_low_y", TCL_GLOBAL_ONLY ), "%f", &y );
1092
sscanf( Tcl_GetVar2( TCLInterp, "camera","view_high_x", TCL_GLOBAL_ONLY ), "%f", &z );
1093
sscanf( Tcl_GetVar2( TCLInterp, "camera","view_high_y", TCL_GLOBAL_ONLY ), "%f", &w );
1094
cam_set_viewport( camera,x,y,z,w );
1095
1096
sscanf( Tcl_GetVar2( TCLInterp,"camera","projection", TCL_GLOBAL_ONLY ), "%s", str );
1097
if ( strcmp( str,"perspective" ) == 0 )
1098
cam_set_projection( camera, camera_proj_perspective );
1099
else
1100
cam_set_projection( camera, camera_proj_ortho );
1101
1102
sscanf( Tcl_GetVar2( TCLInterp,"camera","field_angle", TCL_GLOBAL_ONLY ), "%f", &x );
1103
cam_set_field_angle( camera, x );
1104
1105
sscanf( Tcl_GetVar2( TCLInterp,"camera","near", TCL_GLOBAL_ONLY ), "%f", &x );
1106
sscanf( Tcl_GetVar2( TCLInterp,"camera","far", TCL_GLOBAL_ONLY ), "%f", &y );
1107
cam_set_clip( camera, x,y );
1108
}
1109
1110
DrawItSomeTimeWhenIdle();
1111
1112
return TCL_OK;
1113
}
1114
1115
1116
static int LoadCamera(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
1117
{
1118
if ( argc != 2 )
1119
{
1120
fprintf( stderr, "camera: wrong number of arguments\n" );
1121
return TCL_ERROR;
1122
}
1123
1124
cam_delete_list( Camera );
1125
Camera = (camera_t *)cam_load_cameras( NULL,argv[1] );
1126
1127
DrawItSomeTimeWhenIdle();
1128
1129
return TCL_OK;
1130
}
1131
1132
static int GroupDisplay(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
1133
{
1134
int i,gid,groupid;
1135
group_t *group;
1136
1137
if ( argc > 1 )
1138
{
1139
if ( strcmp( argv[2],"on" ) == 0 )
1140
{
1141
for( group=CurrentObject->ElementModel->Groups; group!=NULL; group=group->Next )
1142
if ( strcmp( argv[1],group->Name ) == 0 ) {
1143
group->status = 1;
1144
break;
1145
}
1146
} else {
1147
for( group=CurrentObject->ElementModel->Groups; group!=NULL; group=group->Next )
1148
if ( strcmp( argv[1],group->Name ) == 0 ) {
1149
group->status = 0;
1150
break;
1151
}
1152
1153
}
1154
}
1155
1156
for( i=0; i<CurrentObject->ElementModel->NofElements; i++ )
1157
{
1158
CurrentObject->ElementModel->Elements[i].DisplayFlag = FALSE;
1159
for ( gid=0; gid<MAX_GROUP_IDS; gid++ )
1160
{
1161
groupid = 0;
1162
for( group=CurrentObject->ElementModel->Groups; group!=NULL; group=group->Next,groupid++ )
1163
if ( groupid==CurrentObject->ElementModel->Elements[i].GroupIds[gid] ) break;
1164
1165
if ( group ) CurrentObject->ElementModel->Elements[i].DisplayFlag |= group->status;
1166
}
1167
}
1168
1169
return TCL_OK;
1170
}
1171
1172
char *mtc_domath( char * );
1173
1174
static int MathCommand(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
1175
{
1176
VARIABLE *var;
1177
LIST *lst;
1178
1179
static char name[256],value[256],*result;
1180
1181
int i,j,k,NodesChanged;
1182
1183
element_model_t *ElementModel = CurrentObject->ElementModel;
1184
1185
void var_reset_status();
1186
int var_get_status();
1187
1188
/*
1189
* do the given math command first ...
1190
*
1191
*/
1192
var_reset_status( "nodes" );
1193
1194
result = (char *)mtc_domath( argv[1] );
1195
1196
NodesChanged = var_get_status( "nodes" );
1197
1198
1199
/*
1200
* then check the variables which are good for then
1201
* element model...
1202
*
1203
*/
1204
if ( result && strncmp( result, "MATC ERROR: ", 12 ) == 0 )
1205
{
1206
Tcl_SetResult( interp, result, TCL_STATIC );
1207
return TCL_ERROR;
1208
}
1209
1210
1211
/*
1212
* if empty list return.
1213
*/
1214
if ( listheaders[VARIABLES].next == (LIST *)NULL )
1215
{
1216
Tcl_SetResult( interp, result, TCL_STATIC );
1217
return TCL_OK;
1218
}
1219
1220
i = j = k = 0;
1221
for( lst = listheaders[VARIABLES].next; lst; lst = NEXT(lst))
1222
{
1223
var = (VARIABLE *)lst;
1224
if ( !NAME(var)) continue;
1225
1226
if ( NROW(var) == 5 )
1227
{
1228
sprintf( name, "%d", k++ );
1229
sprintf( value, "%s", NAME(var) );
1230
Tcl_SetVar2( TCLInterp,"ParticleVariableNames", name, value, TCL_GLOBAL_ONLY );
1231
}
1232
1233
if ( !ElementModel ) continue;
1234
1235
if ( NROW(var) == 3 )
1236
{
1237
if ( !(NCOL(var) % ElementModel->NofNodes) )
1238
{
1239
sprintf( name, "%d", i++ );
1240
sprintf( value, "%s_x", NAME(var) );
1241
Tcl_SetVar2( TCLInterp, "ScalarVariableNames", name, value, TCL_GLOBAL_ONLY );
1242
1243
sprintf( name, "%d", i++ );
1244
sprintf( value, "%s_y", NAME(var) );
1245
Tcl_SetVar2( TCLInterp, "ScalarVariableNames", name, value, TCL_GLOBAL_ONLY );
1246
1247
sprintf( name, "%d", i++ );
1248
sprintf( value, "%s_z", NAME(var) );
1249
Tcl_SetVar2( TCLInterp, "ScalarVariableNames", name, value, TCL_GLOBAL_ONLY );
1250
1251
sprintf( name, "%d", j++ );
1252
sprintf( value, "%s", NAME(var) );
1253
Tcl_SetVar2( TCLInterp, "VectorVariableNames", name, value, TCL_GLOBAL_ONLY );
1254
}
1255
}
1256
else if ( NROW(var) == 1 && !(NCOL(var) % ElementModel->NofNodes) )
1257
{
1258
sprintf( name, "%d", i++ );
1259
Tcl_SetVar2( TCLInterp, "ScalarVariableNames", name, NAME(var), TCL_GLOBAL_ONLY );
1260
}
1261
}
1262
1263
1264
NumberOfScalarVariables = i;
1265
NumberOfVectorVariables = j;
1266
NumberOfParticleVariables = k;
1267
1268
1269
/*
1270
* check if scaling required...
1271
*/
1272
if ( ElementModel && NodesChanged )
1273
{
1274
static vertex_t *vertex;
1275
static double s;
1276
1277
vertex = CurrentObject->Geometry->Vertices;
1278
1279
if ( !KeepScale )
1280
{
1281
xmin = ymin = zmin = 1.0e20;
1282
xmax = ymax = zmax = -1.0e20;
1283
1284
for( i=0; i<ElementModel->NofNodes; i++ )
1285
{
1286
xmin = MIN( xmin,ElementModel->NodeArray[i] );
1287
ymin = MIN( ymin,ElementModel->NodeArray[ElementModel->NofNodes+i] );
1288
zmin = MIN( zmin,ElementModel->NodeArray[2*ElementModel->NofNodes+i] );
1289
1290
xmax = MAX( xmax,ElementModel->NodeArray[i] );
1291
ymax = MAX( ymax,ElementModel->NodeArray[ElementModel->NofNodes+i] );
1292
zmax = MAX( zmax,ElementModel->NodeArray[2*ElementModel->NofNodes+i] );
1293
}
1294
s = MAX(MAX(xmax-xmin,ymax-ymin),zmax-zmin);
1295
1296
CurrentObject->Geometry->Scale = s;
1297
CurrentObject->Geometry->MinMax[0].x[0] = xmin;
1298
CurrentObject->Geometry->MinMax[0].x[1] = ymin;
1299
CurrentObject->Geometry->MinMax[0].x[2] = zmin;
1300
1301
CurrentObject->Geometry->MinMax[1].x[0] = xmax;
1302
CurrentObject->Geometry->MinMax[1].x[1] = ymax;
1303
CurrentObject->Geometry->MinMax[1].x[2] = zmax;
1304
1305
} else {
1306
s = CurrentObject->Geometry->Scale;
1307
xmin = CurrentObject->Geometry->MinMax[0].x[0];
1308
ymin = CurrentObject->Geometry->MinMax[0].x[1];
1309
zmin = CurrentObject->Geometry->MinMax[0].x[2];
1310
1311
xmax = CurrentObject->Geometry->MinMax[1].x[0];
1312
ymax = CurrentObject->Geometry->MinMax[1].x[1];
1313
zmax = CurrentObject->Geometry->MinMax[1].x[2];
1314
}
1315
1316
for( i=0; i<CurrentObject->ElementModel->NofNodes; i++,vertex++ )
1317
{
1318
vertex->x[0] = (2.0 * (ElementModel->NodeArray[i] - xmin) - (xmax-xmin)) / s;
1319
vertex->x[1] = (2.0 * (ElementModel->NodeArray[ElementModel->NofNodes+i] - ymin) - (ymax-ymin)) / s;
1320
vertex->x[2] = (2.0 * (ElementModel->NodeArray[2*ElementModel->NofNodes+i] - zmin) - (zmax-zmin)) / s;
1321
}
1322
1323
if ( NormalUpdate ) geo_vertex_normals( CurrentObject->Geometry,50.0 );
1324
}
1325
1326
1327
Tcl_SetResult( interp, result, TCL_STATIC );
1328
return TCL_OK;
1329
}
1330
1331
#ifndef MINGW32
1332
#include <GL/glx.h>
1333
#else
1334
#include <winuser.h>
1335
#endif
1336
#include <X11/Xlib.h>
1337
#include <X11/Xutil.h>
1338
1339
static unsigned int FontBase;
1340
1341
Display *tkXDisplay()
1342
{
1343
Display *ptr = NULL;
1344
#ifndef MINGW32
1345
ptr = auxXDisplay();
1346
#endif
1347
return ptr;
1348
}
1349
1350
Window tkXWindow()
1351
{
1352
Window ptr = 0;
1353
1354
#ifdef MINGW32
1355
ptr = auxGetHWND();
1356
#else
1357
ptr = auxXWindow();
1358
#endif
1359
1360
return ptr;
1361
}
1362
1363
1364
static int ActivateGraphicsWindow( ClientData cl,Tcl_Interp *interp,int argc,char **argv )
1365
{
1366
#ifdef MINGW32
1367
ShowWindow( tkXWindow(), SW_SHOWNORMAL );
1368
#endif
1369
return TCL_OK;
1370
}
1371
1372
1373
1374
1375
static GLubyte rasterFont[][13] = {
1376
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1377
{0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18},
1378
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x36, 0x36},
1379
{0x00, 0x00, 0x00, 0x66, 0x66, 0xff, 0x66, 0x66, 0xff, 0x66, 0x66, 0x00, 0x00},
1380
{0x00, 0x00, 0x18, 0x7e, 0xff, 0x1b, 0x1f, 0x7e, 0xf8, 0xd8, 0xff, 0x7e, 0x18},
1381
{0x00, 0x00, 0x0e, 0x1b, 0xdb, 0x6e, 0x30, 0x18, 0x0c, 0x76, 0xdb, 0xd8, 0x70},
1382
{0x00, 0x00, 0x7f, 0xc6, 0xcf, 0xd8, 0x70, 0x70, 0xd8, 0xcc, 0xcc, 0x6c, 0x38},
1383
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1c, 0x0c, 0x0e},
1384
1385
{0x00, 0x00, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c},
1386
{0x00, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x18, 0x30},
1387
{0x00, 0x00, 0x00, 0x00, 0x99, 0x5a, 0x3c, 0xff, 0x3c, 0x5a, 0x99, 0x00, 0x00},
1388
{0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0xff, 0xff, 0x18, 0x18, 0x18, 0x00, 0x00},
1389
{0x00, 0x00, 0x30, 0x18, 0x1c, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1390
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00},
1391
{0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1392
{0x00, 0x60, 0x60, 0x30, 0x30, 0x18, 0x18, 0x0c, 0x0c, 0x06, 0x06, 0x03, 0x03},
1393
{0x00, 0x00, 0x3c, 0x66, 0xc3, 0xe3, 0xf3, 0xdb, 0xcf, 0xc7, 0xc3, 0x66, 0x3c},
1394
{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78, 0x38, 0x18},
1395
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0xe7, 0x7e},
1396
{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0x07, 0x03, 0x03, 0xe7, 0x7e},
1397
{0x00, 0x00, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0xff, 0xcc, 0x6c, 0x3c, 0x1c, 0x0c},
1398
{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xff},
1399
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e},
1400
{0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x03, 0x03, 0xff},
1401
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e},
1402
{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x03, 0x7f, 0xe7, 0xc3, 0xc3, 0xe7, 0x7e},
1403
{0x00, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x38, 0x38, 0x00, 0x00, 0x00, 0x00},
1404
{0x00, 0x00, 0x30, 0x18, 0x1c, 0x1c, 0x00, 0x00, 0x1c, 0x1c, 0x00, 0x00, 0x00},
1405
{0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x60, 0x30, 0x18, 0x0c, 0x06},
1406
{0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00},
1407
{0x00, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60},
1408
{0x00, 0x00, 0x18, 0x00, 0x00, 0x18, 0x18, 0x0c, 0x06, 0x03, 0xc3, 0xc3, 0x7e},
1409
{0x00, 0x00, 0x3f, 0x60, 0xcf, 0xdb, 0xd3, 0xdd, 0xc3, 0x7e, 0x00, 0x00, 0x00},
1410
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0x66, 0x3c, 0x18},
1411
{0x00, 0x00, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe},
1412
{0x00, 0x00, 0x7e, 0xe7, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e},
1413
{0x00, 0x00, 0xfc, 0xce, 0xc7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc7, 0xce, 0xfc},
1414
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xc0, 0xff},
1415
{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfc, 0xc0, 0xc0, 0xc0, 0xff},
1416
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xcf, 0xc0, 0xc0, 0xc0, 0xc0, 0xe7, 0x7e},
1417
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
1418
{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e},
1419
{0x00, 0x00, 0x7c, 0xee, 0xc6, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06},
1420
{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xe0, 0xf0, 0xd8, 0xcc, 0xc6, 0xc3},
1421
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0},
1422
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xdb, 0xff, 0xff, 0xe7, 0xc3},
1423
{0x00, 0x00, 0xc7, 0xc7, 0xcf, 0xcf, 0xdf, 0xdb, 0xfb, 0xf3, 0xf3, 0xe3, 0xe3},
1424
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xe7, 0x7e},
1425
{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe},
1426
{0x00, 0x00, 0x3f, 0x6e, 0xdf, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0x66, 0x3c},
1427
{0x00, 0x00, 0xc3, 0xc6, 0xcc, 0xd8, 0xf0, 0xfe, 0xc7, 0xc3, 0xc3, 0xc7, 0xfe},
1428
{0x00, 0x00, 0x7e, 0xe7, 0x03, 0x03, 0x07, 0x7e, 0xe0, 0xc0, 0xc0, 0xe7, 0x7e},
1429
{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xff},
1430
{0x00, 0x00, 0x7e, 0xe7, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
1431
{0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
1432
{0x00, 0x00, 0xc3, 0xe7, 0xff, 0xff, 0xdb, 0xdb, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3},
1433
{0x00, 0x00, 0xc3, 0x66, 0x66, 0x3c, 0x3c, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3},
1434
{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3},
1435
{0x00, 0x00, 0xff, 0xc0, 0xc0, 0x60, 0x30, 0x7e, 0x0c, 0x06, 0x03, 0x03, 0xff},
1436
{0x00, 0x00, 0x3c, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3c},
1437
{0x00, 0x03, 0x03, 0x06, 0x06, 0x0c, 0x0c, 0x18, 0x18, 0x30, 0x30, 0x60, 0x60},
1438
{0x00, 0x00, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x3c},
1439
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18},
1440
{0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
1441
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x38, 0x30, 0x70},
1442
{0x00, 0x00, 0x7f, 0xc3, 0xc3, 0x7f, 0x03, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00},
1443
{0x00, 0x00, 0xfe, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0},
1444
{0x00, 0x00, 0x7e, 0xc3, 0xc0, 0xc0, 0xc0, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00},
1445
{0x00, 0x00, 0x7f, 0xc3, 0xc3, 0xc3, 0xc3, 0x7f, 0x03, 0x03, 0x03, 0x03, 0x03},
1446
{0x00, 0x00, 0x7f, 0xc0, 0xc0, 0xfe, 0xc3, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00},
1447
{0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x33, 0x1e},
1448
{0x7e, 0xc3, 0x03, 0x03, 0x7f, 0xc3, 0xc3, 0xc3, 0x7e, 0x00, 0x00, 0x00, 0x00},
1449
{0x00, 0x00, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0xc0, 0xc0, 0xc0, 0xc0},
1450
{0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x18, 0x00},
1451
{0x38, 0x6c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x00},
1452
{0x00, 0x00, 0xc6, 0xcc, 0xf8, 0xf0, 0xd8, 0xcc, 0xc6, 0xc0, 0xc0, 0xc0, 0xc0},
1453
{0x00, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x78},
1454
{0x00, 0x00, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0xdb, 0xfe, 0x00, 0x00, 0x00, 0x00},
1455
{0x00, 0x00, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xfc, 0x00, 0x00, 0x00, 0x00},
1456
{0x00, 0x00, 0x7c, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x7c, 0x00, 0x00, 0x00, 0x00},
1457
{0xc0, 0xc0, 0xc0, 0xfe, 0xc3, 0xc3, 0xc3, 0xc3, 0xfe, 0x00, 0x00, 0x00, 0x00},
1458
{0x03, 0x03, 0x03, 0x7f, 0xc3, 0xc3, 0xc3, 0xc3, 0x7f, 0x00, 0x00, 0x00, 0x00},
1459
{0x00, 0x00, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xe0, 0xfe, 0x00, 0x00, 0x00, 0x00},
1460
{0x00, 0x00, 0xfe, 0x03, 0x03, 0x7e, 0xc0, 0xc0, 0x7f, 0x00, 0x00, 0x00, 0x00},
1461
{0x00, 0x00, 0x1c, 0x36, 0x30, 0x30, 0x30, 0x30, 0xfc, 0x30, 0x30, 0x30, 0x00},
1462
{0x00, 0x00, 0x7e, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0xc6, 0x00, 0x00, 0x00, 0x00},
1463
{0x00, 0x00, 0x18, 0x3c, 0x3c, 0x66, 0x66, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00},
1464
{0x00, 0x00, 0xc3, 0xe7, 0xff, 0xdb, 0xc3, 0xc3, 0xc3, 0x00, 0x00, 0x00, 0x00},
1465
{0x00, 0x00, 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00},
1466
{0xc0, 0x60, 0x60, 0x30, 0x18, 0x3c, 0x66, 0x66, 0xc3, 0x00, 0x00, 0x00, 0x00},
1467
{0x00, 0x00, 0xff, 0x60, 0x30, 0x18, 0x0c, 0x06, 0xff, 0x00, 0x00, 0x00, 0x00},
1468
{0x00, 0x00, 0x0f, 0x18, 0x18, 0x18, 0x38, 0xf0, 0x38, 0x18, 0x18, 0x18, 0x0f},
1469
{0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18},
1470
{0x00, 0x00, 0xf0, 0x18, 0x18, 0x18, 0x1c, 0x0f, 0x1c, 0x18, 0x18, 0x18, 0xf0},
1471
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x8f, 0xf1, 0x60, 0x00, 0x00, 0x00}
1472
};
1473
1474
void MakeRasterFontDefault()
1475
{
1476
GLuint i;
1477
1478
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
1479
1480
FontBase = glGenLists(128);
1481
for (i = 32; i < 127; i++) {
1482
glNewList( i+FontBase, GL_COMPILE );
1483
glBitmap( 8, 13, 0.0f, 2.0f, 10.0f, 0.0f, rasterFont[i-32] );
1484
glEndList();
1485
}
1486
}
1487
1488
1489
#ifndef MINGW32
1490
1491
void InitializeXFonts()
1492
{
1493
static char str[32], here = 0;
1494
int i,n;
1495
char **FontNames;
1496
1497
FontNames = XListFonts( tkXDisplay(), "*", 10000, &n );
1498
1499
for( i=0; i<n; i++ )
1500
{
1501
sprintf( str, "%d", i );
1502
Tcl_SetVar2( TCLInterp, "FontNames", str,FontNames[i], TCL_GLOBAL_ONLY );
1503
}
1504
1505
sprintf( str, "%d", i );
1506
Tcl_SetVar( TCLInterp, "NumberOfFonts", str, TCL_GLOBAL_ONLY );
1507
1508
MakeRasterFontDefault();
1509
}
1510
1511
1512
void MakeRasterFont( char *name )
1513
{
1514
unsigned int first, last;
1515
1516
XFontStruct *fontInfo;
1517
static char str[32], here = 0;
1518
1519
CurrentXFont = fontInfo = XLoadQueryFont( tkXDisplay(),name );
1520
fprintf( stdout, "Font: [%s] %x\n", name, CurrentXFont );
1521
if ( fontInfo == NULL )
1522
{
1523
fprintf( stderr, "Can not find font: [%s]\n", name );
1524
return;
1525
}
1526
1527
first = fontInfo->min_char_or_byte2;
1528
last = fontInfo->max_char_or_byte2;
1529
ColorScaleFontSize = fontInfo->max_bounds.rbearing - fontInfo->min_bounds.lbearing;
1530
1531
FontBase = glGenLists( last + 1 );
1532
glXUseXFont( fontInfo->fid,first,last-first+1,FontBase+first );
1533
}
1534
#endif
1535
1536
void PrintString( char *s )
1537
{
1538
double param[4],rgba[4];
1539
void OutputPSString();
1540
1541
if ( GlobalOptions.OutputPS ) {
1542
glGetDoublev( GL_CURRENT_COLOR, rgba );
1543
glGetDoublev( GL_CURRENT_RASTER_POSITION, param );
1544
OutputPSString( param[0],param[1],ColorScaleFontSize, rgba[0],rgba[1],rgba[2], s );
1545
} else {
1546
glDisable( GL_LIGHTING );
1547
glDisable( GL_TEXTURE_1D );
1548
glPushAttrib( GL_LIST_BIT );
1549
glListBase( FontBase );
1550
glCallLists( strlen(s),GL_UNSIGNED_BYTE,(unsigned char *)s );
1551
glPopAttrib();
1552
glEnable( GL_TEXTURE_1D );
1553
glEnable( GL_LIGHTING );
1554
}
1555
}
1556
1557
static int ShowString( ClientData cl,Tcl_Interp *interp,int argc,char **argv )
1558
{
1559
float x,y,z;
1560
1561
if ( argc < 5 )
1562
{
1563
sprintf( interp->result, "string: Wrong number of arguments.\n" );
1564
return TCL_ERROR;
1565
}
1566
1567
glMatrixMode( GL_PROJECTION );
1568
glLoadIdentity();
1569
1570
glMatrixMode( GL_MODELVIEW );
1571
glPushMatrix();
1572
glLoadIdentity();
1573
1574
glDisable( GL_TEXTURE_1D );
1575
glDisable( GL_DEPTH_TEST );
1576
glDrawBuffer( GL_FRONT_AND_BACK );
1577
1578
glColor3f( 1.0,1.0,1.0 );
1579
1580
x = atof( argv[1] );
1581
y = atof( argv[2] );
1582
z = atof( argv[3] );
1583
1584
glRasterPos3f( x,y,z );
1585
1586
// if ( argc >= 6 ) MakeRasterFont( argv[5] );
1587
PrintString( argv[4] );
1588
1589
glPopMatrix();
1590
1591
epSwapBuffers();
1592
1593
return TCL_OK;
1594
}
1595
1596
1597
static int SetFont( ClientData cl,Tcl_Interp *interp,int argc,char **argv )
1598
{
1599
int i;
1600
if ( argc < 1 )
1601
{
1602
sprintf( interp->result, "Set font: Wrong number of arguments.\n" );
1603
return TCL_ERROR;
1604
}
1605
1606
#ifdef MINGW32
1607
MakeRasterFontDefault();
1608
#else
1609
MakeRasterFont( argv[1] );
1610
#endif
1611
1612
return TCL_OK;
1613
}
1614
1615
1616
void UpdateObject( ClientData cl,Tcl_Interp *interp,int argc,char **argv)
1617
{
1618
static double L[1024],I[256];
1619
int i;
1620
1621
element_model_t *model;
1622
1623
char *str;
1624
1625
model = CurrentObject->ElementModel;
1626
if ( !model ) return;
1627
1628
vis_delete_visual( CurrentObject->VisualList );
1629
CurrentObject->VisualList = NULL;
1630
1631
if ( ShowMeshLines )
1632
{
1633
visual_t *VL = NULL;
1634
1635
if ( !VL )
1636
{
1637
VL = (visual_t *)vis_new_visual( "Mesh" );
1638
} else VL->Next = NULL;
1639
CurrentObject->VisualList = (visual_t *)vis_link_visual( CurrentObject->VisualList,VL );
1640
1641
vis_set_param( VL, "ColorMap", 0, 0.0, MeshColorMap );
1642
vis_set_param( VL, "Material", 0, 0.0, MeshMaterial );
1643
vis_set_param( VL, "ColorData", 0, 0.0, NULL );
1644
vis_set_param( VL, "Style", mesh_style_line, 0.0, NULL );
1645
vis_set_param( VL, "LineStyle", line_style_line, 0.0, NULL );
1646
vis_set_param( VL, "LineQuality", 1, 0.0, NULL );
1647
vis_set_param( VL, "EdgeStyle", edge_style_all, 0.0, NULL );
1648
}
1649
1650
if ( ShowParticles )
1651
{
1652
visual_t *VL = CurrentObject->VisualList;
1653
1654
if ( !VL )
1655
{
1656
VL = (visual_t *)vis_new_visual( "Particles" );
1657
1658
} else VL->Next = NULL;
1659
CurrentObject->VisualList = (visual_t *)vis_link_visual( CurrentObject->VisualList,VL );
1660
1661
GetScalarVariable( &ParticleColor, (char *)Tcl_GetVar( TCLInterp,
1662
"ParticleColor",TCL_GLOBAL_ONLY ), model, 1, TRUE );
1663
GetVectorVariable( ParticleVelocity, (char *)Tcl_GetVar( TCLInterp,
1664
"ParticleVelocity",TCL_GLOBAL_ONLY ),model, 1 );
1665
GetParticleVariable( ParticleParticle, (char *)Tcl_GetVar( TCLInterp,
1666
"ParticleParticle",TCL_GLOBAL_ONLY ) );
1667
1668
vis_set_param( VL, "Style", ParticleStyle, 0.0, NULL );
1669
1670
vis_set_param( VL, "VectorData1", 0, 0.0, &ParticleVelocity[1] );
1671
vis_set_param( VL, "VectorData2", 0, 0.0, &ParticleVelocity[2] );
1672
vis_set_param( VL, "VectorData3", 0, 0.0, &ParticleVelocity[3] );
1673
1674
vis_set_param( VL, "ParticleDataX", 0, 0.0, &ParticleParticle[0] );
1675
vis_set_param( VL, "ParticleDataY", 0, 0.0, &ParticleParticle[1] );
1676
vis_set_param( VL, "ParticleDataZ", 0, 0.0, &ParticleParticle[2] );
1677
vis_set_param( VL, "ParticleDataC", 0, 0.0, &ParticleParticle[3] );
1678
vis_set_param( VL, "ParticleDataI", 0, 0.0, &ParticleParticle[4] );
1679
1680
vis_set_param( VL, "ColorData", 0, 0.0, &ParticleColor );
1681
1682
vis_set_param( VL, "LineStyle", ParticleLineStyle, 0.0, NULL );
1683
vis_set_param( VL, "LineQuality", ParticleQuality, 0.0, NULL );
1684
vis_set_param( VL, "LineWidth", 0, ParticleRadius, NULL );
1685
vis_set_param( VL, "ArrowStyle", ParticleArrowStyle, 0.0, NULL );
1686
vis_set_param( VL, "OutDT", 0, ParticleOutDT, NULL );
1687
vis_set_param( VL, "MaxDT", 0, ParticleMaxDT, NULL );
1688
vis_set_param( VL, "Tolerance", 0, ParticleTolerance, NULL );
1689
vis_set_param( VL, "NofParticles", ParticleNofParticles, 0.0, NULL );
1690
vis_set_param( VL, "ColorMap", 0, 0.0, ParticleColorMap );
1691
vis_set_param( VL, "Material", 0, 0.0, ParticleMaterial );
1692
1693
vis_set_param( VL, "Advance", ParticleAdvance, 0.0, NULL );
1694
vis_set_param( VL, "IntegMethod", ParticleIntegMethod, 0.0, NULL );
1695
vis_set_param( VL, "IntegPolicy", ParticleIntegPolicy, 0.0, NULL );
1696
ParticleAdvance = FALSE;
1697
}
1698
1699
if ( ShowVectors )
1700
{
1701
visual_t *VL = NULL;
1702
1703
if ( !VL )
1704
{
1705
VL = (visual_t *)vis_new_visual( "Arrows" );
1706
} else VL->Next = NULL;
1707
CurrentObject->VisualList = (visual_t *)vis_link_visual( CurrentObject->VisualList,VL );
1708
1709
GetScalarVariable( &VectorColor, (char *)Tcl_GetVar( TCLInterp,"VectorColor",TCL_GLOBAL_ONLY ),model, 0, TRUE );
1710
GetScalarVariable( &VectorLength, (char *)Tcl_GetVar( TCLInterp,"VectorLength",TCL_GLOBAL_ONLY ),model, 0, TRUE );
1711
GetScalarVariable( &VectorThreshold, (char *)Tcl_GetVar( TCLInterp,"VectorThreshold",TCL_GLOBAL_ONLY ),model, 0, TRUE );
1712
GetVectorVariable( VectorArrow, (char *)Tcl_GetVar( TCLInterp,"VectorArrow",TCL_GLOBAL_ONLY ),model, 0 );
1713
1714
vis_set_param( VL, "VectorData0", 0, 0.0, &VectorLength );
1715
vis_set_param( VL, "VectorData1", 0, 0.0, &VectorArrow[1] );
1716
vis_set_param( VL, "VectorData2", 0, 0.0, &VectorArrow[2] );
1717
vis_set_param( VL, "VectorData3", 0, 0.0, &VectorArrow[3] );
1718
1719
1720
vis_set_param( VL, "ColorData", 0, 0.0, &VectorColor );
1721
vis_set_param( VL, "LengthData", 0, 0.0, &VectorLength );
1722
1723
vis_set_param( VL, "ThresholdData", 0, 0.0, &VectorThreshold );
1724
vis_set_param( VL, "Ceiling", 0, VectorCeiling, NULL );
1725
vis_set_param( VL, "Floor", 0, VectorFloor, NULL );
1726
1727
vis_set_param( VL, "LineStyle", VectorLineStyle, 0.0, NULL );
1728
1729
vis_set_param( VL, "LengthScale", 0, VectorLengthScale, NULL );
1730
1731
vis_set_param( VL, "EqualLength", FALSE, 0.0, NULL );
1732
1733
vis_set_param( VL, "LineQuality", VectorQuality, 0.0, NULL );
1734
vis_set_param( VL, "ColorMap", 0, 0.0, ArrowColorMap );
1735
vis_set_param( VL, "Material", 0, 0.0, ArrowMaterial );
1736
}
1737
1738
if ( ShowContours )
1739
{
1740
visual_t *VL = NULL;
1741
1742
if ( !VL )
1743
{
1744
VL = (visual_t *)vis_new_visual( "Contour Lines" );
1745
} else VL->Next = NULL;
1746
CurrentObject->VisualList = (visual_t *)vis_link_visual( CurrentObject->VisualList,VL );
1747
1748
GetScalarVariable( &ContourColor[CurrentObject->Id], (char *)Tcl_GetVar( TCLInterp,"ContourColor",
1749
TCL_GLOBAL_ONLY ),model, 0, !ContourColorSetMinMax );
1750
1751
vis_set_param( VL, "ColorData", 0, 0.0, &ContourColor[CurrentObject->Id] );
1752
vis_set_param( VL, "ContourData", 0, 0.0, &ContourColor[CurrentObject->Id] );
1753
vis_set_param( VL, "LineWidth", 0, ContourRadius, NULL );
1754
vis_set_param( VL, "LineStyle", ContourLineStyle, 0.0, NULL );
1755
vis_set_param( VL, "LineQuality", ContourQuality, 0.0, NULL );
1756
1757
for( i=0; i<ContourLines; i++ )
1758
{
1759
static char name[32];
1760
1761
sprintf( name, "%d", i );
1762
str = (char *)Tcl_GetVar2( TCLInterp, "ContourValues",name, TCL_GLOBAL_ONLY );
1763
if ( str ) sscanf( str, "%lf", &L[i] );
1764
}
1765
1766
vis_set_param( VL, "Levels",0,0.0,L );
1767
vis_set_param( VL, "NofLevels",ContourLines,0.0,NULL );
1768
vis_set_param( VL, "ColorMap", 0, 0.0, ContourColorMap );
1769
vis_set_param( VL, "Material", 0, 0.0, ContourMaterial );
1770
}
1771
1772
if ( ShowIsosurfaces )
1773
{
1774
visual_t *VL = NULL;
1775
1776
if ( !VL )
1777
{
1778
VL = (visual_t *)vis_new_visual( "Isosurfaces" );
1779
} else VL->Next = NULL;
1780
CurrentObject->VisualList = (visual_t *)vis_link_visual( CurrentObject->VisualList,VL );
1781
1782
GetScalarVariable( &IsosurfaceColor, (char *)Tcl_GetVar( TCLInterp,"IsosurfaceColor",
1783
TCL_GLOBAL_ONLY ),model, 0, !IsosurfaceColorSetMinMax );
1784
1785
GetScalarVariable( &IsosurfaceContour, (char *)Tcl_GetVar( TCLInterp,"IsosurfaceContour",
1786
TCL_GLOBAL_ONLY ),model, 0, !IsosurfaceContourSetMinMax );
1787
1788
GetVectorVariable( IsosurfaceNormal, (char *)Tcl_GetVar( TCLInterp,
1789
"IsosurfaceNormal",TCL_GLOBAL_ONLY ),model, 0 );
1790
vis_set_param( VL, "Style", IsosurfaceStyle+1, 0.0, NULL );
1791
vis_set_param( VL, "ColorData", 0, 0.0, &IsosurfaceColor );
1792
vis_set_param( VL, "ContourData", 0, 0.0, &IsosurfaceContour );
1793
vis_set_param( VL, "NormalData0", 0, 0.0, &IsosurfaceNormal[1] );
1794
vis_set_param( VL, "NormalData1", 0, 0.0, &IsosurfaceNormal[2] );
1795
vis_set_param( VL, "NormalData2", 0, 0.0, &IsosurfaceNormal[3] );
1796
vis_set_param( VL, "LineWidth", 0, IsosurfaceRadius, NULL );
1797
vis_set_param( VL, "LineStyle", IsosurfaceLineStyle, 0.0, NULL );
1798
vis_set_param( VL, "LineQuality", IsosurfaceQuality, 0.0, NULL );
1799
1800
vis_set_param( VL, "Recompute", IsosurfaceRecompute, 0.0, NULL );
1801
IsosurfaceRecompute = FALSE;
1802
1803
for( i=0; i<IsosurfaceContours; i++ )
1804
{
1805
static char name[32];
1806
1807
sprintf( name, "%d", i );
1808
sscanf( Tcl_GetVar2( TCLInterp, "IsosurfaceValues",name, TCL_GLOBAL_ONLY ), "%lf", &I[i] );
1809
}
1810
1811
vis_set_param( VL, "Levels",0,0.0,I );
1812
vis_set_param( VL, "NofLevels",IsosurfaceContours,0.0,NULL );
1813
vis_set_param( VL, "ColorMap", 0, 0.0, IsoSurfaceColorMap );
1814
vis_set_param( VL, "Material", 0, 0.0, IsoSurfaceMaterial );
1815
}
1816
1817
if ( ShowSpheres )
1818
{
1819
visual_t *VL = NULL;
1820
1821
if ( !VL )
1822
{
1823
VL = (visual_t *)vis_new_visual( "Spheres" );
1824
} else VL->Next = NULL;
1825
CurrentObject->VisualList = (visual_t *)vis_link_visual( CurrentObject->VisualList,VL );
1826
1827
GetScalarVariable( &SphereColor,(char *)Tcl_GetVar(TCLInterp,"SphereColor",TCL_GLOBAL_ONLY),model, 0, TRUE );
1828
GetScalarVariable( &SphereRadius,(char *)Tcl_GetVar(TCLInterp,"SphereRadius",TCL_GLOBAL_ONLY),model, 0, TRUE );
1829
GetScalarVariable( &SphereThreshold,(char *)Tcl_GetVar(TCLInterp,"SphereThreshold",TCL_GLOBAL_ONLY),model, 0, TRUE );
1830
1831
vis_set_param( VL, "ColorMap", 0, 0.0, SphereColorMap );
1832
vis_set_param( VL, "Material", 0, 0.0, SphereMaterial );
1833
1834
vis_set_param( VL, "ColorData", 0, 0.0, &SphereColor );
1835
vis_set_param( VL, "RadiusData", 0, 0.0, &SphereRadius );
1836
vis_set_param( VL, "RadiusScale", 0, SphereRadiusScale, NULL );
1837
vis_set_param( VL, "ThresholdData", 0, 0.0, &SphereThreshold );
1838
vis_set_param( VL, "Floor", 0, SphereFloor, NULL );
1839
vis_set_param( VL, "Ceiling", 0, SphereCeiling, NULL );
1840
vis_set_param( VL, "Quality", SphereQuality, 0.0, NULL );
1841
}
1842
1843
if ( ShowColorMesh )
1844
{
1845
visual_t *VL = NULL;
1846
1847
if ( !VL )
1848
{
1849
VL = (visual_t *)vis_new_visual( "Mesh" );
1850
} else VL->Next = NULL;
1851
CurrentObject->VisualList = (visual_t *)vis_link_visual( CurrentObject->VisualList,VL );
1852
1853
GetScalarVariable( &MeshColor[CurrentObject->Id], (char *)Tcl_GetVar( TCLInterp,"MeshColor",TCL_GLOBAL_ONLY ),
1854
model, 0, !MeshColorSetMinMax );
1855
1856
vis_set_param( VL, "ColorData", 0, 0.0, &MeshColor[CurrentObject->Id] );
1857
vis_set_param( VL, "Style", MeshStyle+1, 0.0, NULL );
1858
vis_set_param( VL, "LineStyle", MeshLineStyle, 0.0, NULL );
1859
vis_set_param( VL, "LineQuality", MeshQuality, 0.0, NULL );
1860
vis_set_param( VL, "LineWidth", 0, MeshRadius, NULL );
1861
vis_set_param( VL, "EdgeStyle", MeshEdgeStyle, 0.0, NULL );
1862
vis_set_param( VL, "NodeNumbers", MeshNodeNumbers,0.0, NULL );
1863
vis_set_param( VL, "ColorMap", 0, 0.0, MeshColorMap );
1864
vis_set_param( VL, "Material", 0, 0.0, MeshMaterial );
1865
vis_set_param( VL, "EdgeMaterial", 0, 0.0, &DefaultEdgeMaterial );
1866
}
1867
1868
if ( ShowColorScale )
1869
{
1870
visual_t *VL = NULL;
1871
1872
if ( !VL )
1873
{
1874
VL = (visual_t *)vis_new_visual( "ColorScale" );
1875
} else VL->Next = NULL;
1876
CurrentObject->VisualList = (visual_t *)vis_link_visual( CurrentObject->VisualList,VL );
1877
1878
GetScalarVariable( &ColorScaleColor, (char *)Tcl_GetVar( TCLInterp,"ColorScaleColor",TCL_GLOBAL_ONLY ),
1879
model, 0, !ColorScaleColorSetMinMax );
1880
1881
vis_set_param( VL, "ColorData", 0, 0.0, &ColorScaleColor );
1882
vis_set_param( VL, "ColorMap", 0, 0.0, &DefaultColorMap );
1883
vis_set_param( VL, "Material", 0, 0.0, &DefaultMaterial );
1884
vis_set_param( VL, "XPosition", 0, ColorScaleX, NULL );
1885
vis_set_param( VL, "YPosition", 0, ColorScaleY, NULL );
1886
vis_set_param( VL, "Length", 0, ColorScaleLength, NULL );
1887
vis_set_param( VL, "Thickness", 0, ColorScaleThickness, NULL );
1888
vis_set_param( VL, "Style", ColorScaleStyle, 0.0, NULL );
1889
vis_set_param( VL, "Font Color",ColorScaleFontColor, 0.0, NULL );
1890
vis_set_param( VL, "Font Size", 0, ColorScaleFontSize, NULL );
1891
vis_set_param( VL, "Entries", ColorScaleEntries, 0.0, NULL );
1892
vis_set_param( VL, "Decimals", ColorScaleDecimals, 0.0, NULL );
1893
}
1894
1895
// return TCL_OK;
1896
}
1897
1898
void opengl_draw()
1899
{
1900
Tcl_Eval( TCLInterp, ".buts.play configure -back red -relief sunken; update" );
1901
1902
glMatrixMode( GL_MODELVIEW );
1903
glLoadIdentity();
1904
1905
glClearColor( br,bg,bb,1.0 );
1906
if ( GraphicsClearOn )
1907
{
1908
glDrawBuffer( GL_BACK );
1909
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
1910
} else {
1911
glDrawBuffer( GL_FRONT_AND_BACK );
1912
}
1913
1914
#if 0
1915
if ( !CurrentObject->Geometry || CurrentObject->Geometry->VertexCount <= 0 ) {
1916
Tcl_Eval( TCLInterp, ".buts.play configure -back green -relief raised; update" );
1917
epSwapBuffers(); return;
1918
}
1919
#endif
1920
1921
if ( epMouseDown && epMouseDownTakesTooLong )
1922
{
1923
glDisable( GL_BLEND );
1924
glDisable( GL_DEPTH_TEST );
1925
} else
1926
{
1927
#if 0
1928
glEnable( GL_BLEND );
1929
#endif
1930
glEnable( GL_DEPTH_TEST );
1931
}
1932
1933
if ( cam_display_list( Camera,&VisualObject ) ) epSwapBuffers();
1934
1935
Tcl_Eval( TCLInterp, ".buts.play configure -back green -relief raised; update" );
1936
}
1937
1938
1939
void Reshape( GLsizei x,GLsizei y)
1940
{
1941
GraphicsXSize = x;
1942
GraphicsYSize = y;
1943
GraphicsAspect = (double)x/(double)y;
1944
1945
DrawItSomeTimeWhenIdle();
1946
}
1947
1948
void CompRot( matrix_t M ) {
1949
static double bx, by, bz;
1950
1951
bx = M[0][0]*ax + M[1][0]*ay + M[2][0]*az;
1952
by = M[0][1]*ax + M[1][1]*ay + M[2][1]*az;
1953
bz = M[0][2]*ax + M[1][2]*ay + M[2][2]*az;
1954
1955
ax = bx;
1956
ay = by;
1957
az = bz;
1958
}
1959
1960
void epMouseDownProc(int Xpos, int Ypos)
1961
{
1962
int x,y,x_root,y_root;
1963
Window root,child;
1964
static GLint viewport[4];
1965
transform_t *transform;
1966
double scale;
1967
1968
#ifndef MINGW32
1969
XQueryPointer( tkXDisplay(),tkXWindow(),&root,&child,&x_root,&y_root,&x,&y,&epMouseDown );
1970
epMouseDown &= (ShiftMask | Button1Mask | Button2Mask);
1971
#else
1972
auxGetMouseLoc( &x, &y );
1973
1974
epMouseDown = 0;
1975
if ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 ) epMouseDown |= Button1Mask;
1976
if ( GetAsyncKeyState( VK_MBUTTON ) & 0x8000 ) epMouseDown |= Button2Mask;
1977
if ( GetAsyncKeyState( VK_RBUTTON ) & 0x8000 ) epMouseDown |= Button2Mask;
1978
if ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) epMouseDown |= ShiftMask;
1979
#endif
1980
1981
epMouseDownTakesTooLong = FALSE;
1982
1983
while( epMouseDown )
1984
{
1985
if ( epMouseDown & Button2Mask )
1986
{
1987
ax = ay = az = 0.0;
1988
sx = sy = sz = 0.0;
1989
1990
if ( epMouseDown & Button1Mask )
1991
{
1992
if ( ABS(Ypos-y) > ABS(Xpos-x) )
1993
{
1994
sx = 0.025*(Ypos-y);
1995
sy = 0.025*(Ypos-y);
1996
sz = 0.025*(Ypos-y);
1997
} else
1998
{
1999
sx = 0.025*(x-Xpos);
2000
sy = 0.025*(x-Xpos);
2001
sz = 0.025*(x-Xpos);
2002
}
2003
2004
obj_scale( CurrentObject,sx,sy,sz,'a',TRUE );
2005
} else
2006
{
2007
// scale = 0.4;
2008
glGetIntegerv(GL_VIEWPORT, viewport);
2009
transform = &CurrentObject->Transform;
2010
scale=180.0/(double)(viewport[3]+1)/transform->SclZ;
2011
2012
if ( epMouseDown & ShiftMask )
2013
{
2014
if ( ABS(Ypos-y) > ABS(Xpos-x) )
2015
az = scale*(y-Ypos);
2016
else
2017
az = scale*(Xpos-x);
2018
} else {
2019
if ( ABS(y-Ypos) > ABS(x-Xpos) )
2020
ax = scale*(y-Ypos);
2021
else
2022
ay = scale*(x-Xpos);
2023
2024
// Compensate for rotation matrix:
2025
//--------------------------------
2026
CompRot( transform->RotMatrix );
2027
2028
}
2029
2030
obj_rotate( CurrentObject,ax,ay,az,'a',TRUE );
2031
}
2032
}
2033
else if ( epMouseDown & Button1Mask )
2034
{
2035
tx = ty = tz = 0;
2036
if ( epMouseDown & ShiftMask )
2037
{
2038
if ( ABS(Ypos-y) > ABS(Xpos-x) )
2039
tz = 0.03*(Ypos-y);
2040
else
2041
tz = 0.03*(x-Xpos);
2042
} else {
2043
// scale = 0.01;
2044
glGetIntegerv(GL_VIEWPORT, viewport);
2045
transform = &CurrentObject->Transform;
2046
scale = 2.0/(double)(viewport[3]+1)/transform->SclZ;
2047
2048
tx = scale*(x-Xpos);
2049
ty = scale*(Ypos-y);
2050
}
2051
obj_translate( CurrentObject,tx,ty,tz,'a',TRUE );
2052
}
2053
2054
Xpos = x;
2055
Ypos = y;
2056
2057
opengl_draw();
2058
2059
#ifndef MINGW32
2060
XQueryPointer( tkXDisplay(),tkXWindow(),&root,&child,&x_root,&y_root,&x,&y,&epMouseDown );
2061
epMouseDown &= (ShiftMask | Button1Mask | Button2Mask);
2062
#else
2063
epMouseDown = 0;
2064
if ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 ) epMouseDown |= Button1Mask;
2065
if ( GetAsyncKeyState( VK_MBUTTON ) & 0x8000 ) epMouseDown |= Button2Mask;
2066
if ( GetAsyncKeyState( VK_RBUTTON ) & 0x8000 ) epMouseDown |= Button2Mask;
2067
if ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) epMouseDown |= ShiftMask;
2068
2069
auxGetMouseLoc( &x, &y );
2070
#endif
2071
}
2072
2073
epMouseDown = FALSE;
2074
if ( epMouseDownTakesTooLong ) { opengl_draw(); }
2075
}
2076
2077
#ifndef MINGW32
2078
void Mouse( AUX_EVENTREC *event )
2079
{
2080
int MouseXPosition = event->data[AUX_MOUSEX];
2081
int MouseYPosition = event->data[AUX_MOUSEY];
2082
int MouseStatus = event->data[AUX_MOUSESTATUS];
2083
2084
if ( event->event == AUX_MOUSEDOWN )
2085
{
2086
if ( MouseXPosition >= 0 && MouseXPosition < GraphicsXSize &&
2087
MouseYPosition >= 0 && MouseYPosition < GraphicsYSize )
2088
{
2089
epMouseDownProc( MouseXPosition, MouseYPosition );
2090
}
2091
}
2092
}
2093
#else
2094
void Mouse( )
2095
{
2096
int MouseXPosition;
2097
int MouseYPosition;
2098
2099
2100
if ( GetFocus() != tkXWindow() ) return;
2101
2102
2103
auxGetMouseLoc( &MouseXPosition, &MouseYPosition );
2104
2105
if ( MouseXPosition >= 0 && MouseXPosition < GraphicsXSize &&
2106
MouseYPosition >= 0 && MouseYPosition < GraphicsYSize )
2107
{
2108
epMouseDownProc( MouseXPosition, MouseYPosition );
2109
}
2110
}
2111
#endif
2112
2113
static int UpdateDisplay(ClientData cl,Tcl_Interp *interp,int argc,char **argv)
2114
{
2115
int x,y,x_root,y_root;
2116
Window root,child;
2117
2118
2119
#ifndef MINGW32
2120
XQueryPointer( tkXDisplay(),tkXWindow(),&root,&child,&x_root,&y_root,&x,&y,&epMouseDown );
2121
epMouseDown &= (ShiftMask | Button1Mask | Button2Mask);
2122
#else
2123
auxGetMouseLoc( &x, &y );
2124
2125
epMouseDown = 0;
2126
if ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 ) epMouseDown |= Button1Mask;
2127
if ( GetAsyncKeyState( VK_MBUTTON ) & 0x8000 ) epMouseDown |= Button2Mask;
2128
if ( GetAsyncKeyState( VK_RBUTTON ) & 0x8000 ) epMouseDown |= Button2Mask;
2129
if ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) epMouseDown |= ShiftMask;
2130
#endif
2131
2132
if ( epMouseDown ) epMouseDownProc( x,y );
2133
2134
#ifdef USE_TK
2135
tkExec( 0 );
2136
#endif
2137
return TCL_OK;
2138
}
2139
2140
2141
void TestTkEvent()
2142
{
2143
BreakLoop = FALSE;
2144
2145
while( Tcl_DoOneEvent(TCL_DONT_WAIT) );
2146
#ifdef MINGW32
2147
if ( GetKeyState( VK_LBUTTON ) & 0x8000 ) Mouse();
2148
if ( GetKeyState( VK_MBUTTON ) & 0x8000 ) Mouse();
2149
if ( GetKeyState( VK_RBUTTON ) & 0x8000 ) Mouse();
2150
#endif
2151
Tk_Sleep(100);
2152
}
2153
2154
static int WindowSize( ClientData cl,Tcl_Interp *interp,int argc,char **argv )
2155
{
2156
unsigned int width, height;
2157
int dx, dy, ox, oy, nx, ny, viewp[4];
2158
2159
2160
if ( argc < 3 ) {
2161
sprintf( interp->result, "Usage: winsize width height" );
2162
return TCL_ERROR;
2163
}
2164
2165
width = atoi( *++argv );
2166
height = atoi( *++argv );
2167
2168
#ifdef MINGW32
2169
SetWindowPos( auxGetHWND(), HWND_TOP, 0, 0, width, height, SWP_NOMOVE | SWP_NOACTIVATE );
2170
2171
// Measure the viewport size and make corrections winsize if necessary:
2172
//---------------------------------------------------------------------
2173
opengl_draw();
2174
glGetIntegerv( GL_VIEWPORT, viewp );
2175
2176
ox = viewp[0];
2177
oy = viewp[1];
2178
nx = viewp[2]+1;
2179
ny = viewp[3]+1;
2180
2181
dx = width - nx;
2182
dy = height -ny;
2183
2184
width += dx;
2185
height += dy;
2186
2187
SetWindowPos( auxGetHWND(), HWND_TOP, 0, 0, width, height, SWP_NOMOVE | SWP_NOACTIVATE );
2188
2189
#else
2190
XResizeWindow( tkXDisplay(), tkXWindow(), width, height );
2191
#endif
2192
2193
return TCL_OK;
2194
}
2195
2196
static int WindowPosition( ClientData cl,Tcl_Interp *interp,int argc,char **argv )
2197
{
2198
if ( argc < 3 ) {
2199
sprintf( interp->result, "Usage: winpos xpos ypos" );
2200
return TCL_ERROR;
2201
}
2202
2203
int ox = atoi( *++argv );
2204
int oy = atoi( *++argv );
2205
2206
#ifdef MINGW32
2207
SetWindowPos( auxGetHWND(), HWND_TOP, ox, oy, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE );
2208
#else
2209
XMoveWindow( (Display *)tkXDisplay(), tkXWindow(), ox, oy );
2210
#endif
2211
2212
return TCL_OK;
2213
}
2214
2215
2216
static int MPlayer( ClientData cl, Tcl_Interp *interp, int argc, char **argv )
2217
{
2218
#if defined(MINGW32)
2219
2220
return TCL_OK;
2221
2222
#else
2223
2224
if( argc < 2 ) {
2225
sprintf( interp->result, "Usage: mplayer filename");
2226
return TCL_ERROR;
2227
}
2228
2229
// File name:
2230
char *fileName = *++argv;
2231
2232
// Get Window Id:
2233
GLXDrawable drawable = glXGetCurrentDrawable();
2234
int winId = (int)drawable;
2235
2236
// Player command:
2237
char playCmd[1024];
2238
sprintf( playCmd, "mplayer -wid %d %s", winId, fileName );
2239
2240
// Call mplayer:
2241
system( playCmd );
2242
2243
return TCL_OK;
2244
2245
#endif
2246
}
2247
2248
2249
int main(int argc,char **argv)
2250
{
2251
static char init[1024],initcommands[1024],tmp[1024],ephome[512];
2252
int i,size[4];
2253
2254
/* For MinGW */
2255
static char szAppPath[512] = "";
2256
static char szAppDirectory[512] = "";
2257
char *exeName;
2258
2259
void mtc_init(), Misc_Init(), Transforms_Init(), Readfile_Init(), Matctcl_Init();
2260
2261
if((argc > 1) && (!strcmp(argv[1], "-v"))) {
2262
fprintf(stdout, "ElmerPost v.5.4\n");
2263
return 0;
2264
}
2265
2266
if ( getenv("ELMER_POST_HOME") == NULL )
2267
{
2268
/* use default installation directory just if nothing is set */
2269
#if defined(MINGW32)
2270
GetModuleFileName(NULL, szAppPath, 512);
2271
exeName = strrchr(szAppPath, '\\');
2272
i = (int)(exeName-szAppPath);
2273
if(i < 0) i = 0;
2274
if(i > 512) i = 512;
2275
strncpy(szAppDirectory, szAppPath, i);
2276
2277
_snprintf(ephome, 512,
2278
"ELMER_POST_HOME=%s\\..\\share\\elmerpost",
2279
szAppDirectory);
2280
2281
printf("%s\n", ephome);
2282
#else
2283
snprintf( ephome, 512, "ELMER_POST_HOME=%s", ELMER_POST_HOME );
2284
#endif
2285
2286
putenv( ephome );
2287
}
2288
2289
2290
Tcl_FindExecutable( *argv++ );
2291
TCLInterp = Tcl_CreateInterp();
2292
2293
auxInitDisplayMode( AUX_DOUBLE | AUX_RGB | AUX_DEPTH | AUX_DIRECT );
2294
auxInitPosition( 0, 0, 500, 500 );
2295
auxInitWindow( "ELMER POST GRAPHICS" );
2296
2297
strcpy( initcommands, "" );
2298
2299
while ( *argv ) {
2300
2301
if ( strcmp( *argv, "-id" ) == 0 ) {
2302
if ( *++argv )
2303
{
2304
Tcl_SetVar( TCLInterp, "elmerpost_id", *argv++,
2305
TCL_GLOBAL_ONLY );
2306
}
2307
2308
} else if ( strcmp( *argv, "-file" ) == 0 ) {
2309
if ( *++argv )
2310
{
2311
strcat( initcommands, "readfile " );
2312
2313
/* Quote filename if not already quoted */
2314
if ( (*argv)[strlen(*argv) - 1] != '\"' )
2315
strcat( initcommands, "\"" );
2316
2317
strcat( initcommands, *argv );
2318
2319
if ( (*argv)[strlen(*argv) - 1] != '\"' )
2320
strcat( initcommands, "\"" );
2321
2322
strcat( initcommands, " " );
2323
++argv;
2324
}
2325
2326
} else if ( 1020 - strlen(initcommands) > strlen( *argv ) ) {
2327
strcat( initcommands, *argv++ );
2328
strcat( initcommands, " " );
2329
2330
} else break;
2331
}
2332
2333
Tcl_SetVar( TCLInterp, "argv", "-name \"ELMER POST PROCESSING\"",
2334
TCL_GLOBAL_ONLY );
2335
2336
Tcl_Init( TCLInterp );
2337
Tk_Init( TCLInterp );
2338
2339
Tcl_StaticPackage(TCLInterp, "Tk", Tk_Init, Tk_SafeInit);
2340
2341
Tcl_CreateCommand( TCLInterp, "GetInterpolate", (Tcl_CmdProc *)GetInterpolate,
2342
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2343
2344
Tcl_CreateCommand( TCLInterp, "GetColorMap", (Tcl_CmdProc *)GetColorMap,
2345
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2346
2347
Tcl_CreateCommand( TCLInterp, "StopProcessing", (Tcl_CmdProc *)StopProcessing,
2348
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2349
2350
Tcl_CreateCommand( TCLInterp, "UpdateBackColor", (Tcl_CmdProc *)UpdateBackColor,
2351
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2352
2353
Tcl_CreateCommand( TCLInterp, "UpdateColor", (Tcl_CmdProc *)UpdateColor,
2354
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2355
2356
Tcl_CreateCommand( TCLInterp, "UpdateEdgeColor", (Tcl_CmdProc *)UpdateEdgeColor,
2357
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2358
2359
Tcl_CreateCommand( TCLInterp, "UpdateVariable", (Tcl_CmdProc *)UpdateVariable,
2360
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2361
2362
Tcl_CreateCommand( TCLInterp, "c_TimeStep", (Tcl_CmdProc *)TimeStep,
2363
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2364
2365
Tcl_CreateCommand( TCLInterp, "c_LoadCamera", (Tcl_CmdProc *)LoadCamera,
2366
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2367
2368
Tcl_CreateCommand( TCLInterp, "c_CurrentCamera", (Tcl_CmdProc *)CurrentCamera,
2369
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2370
2371
Tcl_CreateCommand( TCLInterp, "c_SetCamera", (Tcl_CmdProc *)SetCamera,
2372
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2373
2374
Tcl_CreateCommand( TCLInterp, "UpdateDisplay", (Tcl_CmdProc *)UpdateDisplay,
2375
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2376
2377
Tcl_CreateCommand( TCLInterp, "c_MathCommand", (Tcl_CmdProc *)MathCommand,
2378
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2379
2380
Tcl_CreateCommand( TCLInterp, "UpdateObject", (Tcl_CmdProc *)UpdateObject,
2381
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2382
2383
Tcl_CreateCommand( TCLInterp, "group", (Tcl_CmdProc *)GroupDisplay,
2384
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2385
2386
Tcl_CreateCommand( TCLInterp, "setfont", (Tcl_CmdProc *)SetFont,
2387
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2388
2389
Tcl_CreateCommand( TCLInterp, "object", (Tcl_CmdProc *)SetObject,
2390
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2391
2392
Tcl_CreateCommand( TCLInterp, "parent", (Tcl_CmdProc *)SetParentObject,
2393
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2394
2395
Tcl_CreateCommand( TCLInterp, "normals", (Tcl_CmdProc *)RecomputeNormals,
2396
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2397
2398
Tcl_CreateCommand( TCLInterp, "clip", (Tcl_CmdProc *)ClipPlane,
2399
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2400
2401
Tcl_CreateCommand( TCLInterp, "ActivateGraphicsWindow", (Tcl_CmdProc *)ActivateGraphicsWindow,
2402
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2403
2404
Tcl_CreateCommand( TCLInterp, "winsize", (Tcl_CmdProc *)WindowSize,
2405
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2406
2407
Tcl_CreateCommand( TCLInterp, "winpos", (Tcl_CmdProc *)WindowPosition,
2408
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2409
2410
#if defined(HAVE_FTGL_NEW) || defined(HAVE_FTGL_OLD)
2411
Tcl_CreateCommand( TCLInterp, "fttext", (Tcl_CmdProc *)FtText,
2412
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2413
2414
Tcl_CreateCommand( TCLInterp, "ftfont", (Tcl_CmdProc *)FtFont,
2415
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2416
#endif
2417
2418
Tcl_CreateCommand( TCLInterp, "mplayer", (Tcl_CmdProc *)MPlayer,
2419
(ClientData)NULL, (Tcl_CmdDeleteProc *)NULL );
2420
2421
CurrentObject = &VisualObject;
2422
CurrentObject->Name = strcpy( malloc(strlen("default")+1), "default" );
2423
2424
obj_object_initialize( CurrentObject );
2425
2426
Tcl_LinkVar( TCLInterp, "BreakLoop", (char *)&BreakLoop, TCL_LINK_INT );
2427
2428
if ( !(Camera = (camera_t *)cam_load_cameras( Camera,NULL ) ) )
2429
{
2430
fprintf( stderr, "ElmerPost: Can't initialize default camera. "
2431
"Something is definitely wrong here...\n" );
2432
exit( 0 );
2433
}
2434
2435
if ( !vis_initialize_visual_types() )
2436
{
2437
fprintf( stderr, "ElmerPost: Can't initialize visual types. "
2438
"Something is definitely wrong here...\n" );
2439
exit( 0 );
2440
}
2441
2442
if ( !elm_initialize_element_types() )
2443
{
2444
fprintf( stderr, "ElmerPost: Can't initialize element types. "
2445
"Something is definitely wrong here...\n" );
2446
exit( 0 );
2447
}
2448
2449
mtc_init( NULL, stdout, stderr );
2450
2451
Tcl_LinkVar( TCLInterp, "NumberOfTimesteps", (char *)&ElementModel.NofTimesteps, TCL_LINK_INT );
2452
2453
Tcl_LinkVar( TCLInterp, "NumberOfScalarVariables", (char *)&NumberOfScalarVariables, TCL_LINK_INT );
2454
Tcl_LinkVar( TCLInterp, "NumberOfVectorVariables", (char *)&NumberOfVectorVariables, TCL_LINK_INT );
2455
Tcl_LinkVar( TCLInterp, "NumberOfParticleVariables", (char *)&NumberOfParticleVariables, TCL_LINK_INT );
2456
2457
strcpy( tmp , "DisplayStyle(Vectors)" );
2458
Tcl_LinkVar( TCLInterp, tmp, (char *)&ShowVectors, TCL_LINK_INT );
2459
strcpy( tmp , "DisplayStyle(Contours)" );
2460
Tcl_LinkVar( TCLInterp, tmp, (char *)&ShowContours, TCL_LINK_INT );
2461
strcpy( tmp , "DisplayStyle(MeshLines)" );
2462
Tcl_LinkVar( TCLInterp, tmp, (char *)&ShowMeshLines, TCL_LINK_INT );
2463
strcpy( tmp , "DisplayStyle(ColorMesh)" );
2464
Tcl_LinkVar( TCLInterp, tmp, (char *)&ShowColorMesh, TCL_LINK_INT );
2465
strcpy( tmp , "DisplayStyle(Spheres)" );
2466
Tcl_LinkVar( TCLInterp, tmp, (char *)&ShowSpheres, TCL_LINK_INT );
2467
strcpy( tmp , "DisplayStyle(Isosurfaces)" );
2468
Tcl_LinkVar( TCLInterp, tmp, (char *)&ShowIsosurfaces, TCL_LINK_INT );
2469
strcpy( tmp , "DisplayStyle(Particles)" );
2470
Tcl_LinkVar( TCLInterp, tmp, (char *)&ShowParticles, TCL_LINK_INT );
2471
strcpy( tmp , "DisplayStyle(ColorScale)" );
2472
Tcl_LinkVar( TCLInterp, tmp, (char *)&ShowColorScale, TCL_LINK_INT );
2473
2474
Tcl_LinkVar( TCLInterp, "MeshStyle", (char *)&MeshStyle, TCL_LINK_INT );
2475
Tcl_LinkVar( TCLInterp, "MeshLineStyle", (char *)&MeshLineStyle, TCL_LINK_INT );
2476
Tcl_LinkVar( TCLInterp, "MeshEdgeStyle", (char *)&MeshEdgeStyle, TCL_LINK_INT );
2477
Tcl_LinkVar( TCLInterp, "MeshQuality", (char *)&MeshQuality, TCL_LINK_INT );
2478
Tcl_LinkVar( TCLInterp, "MeshRadius", (char *)&MeshRadius, TCL_LINK_DOUBLE );
2479
Tcl_LinkVar( TCLInterp, "MeshNodeNumbers", (char *)&MeshNodeNumbers, TCL_LINK_INT );
2480
Tcl_LinkVar( TCLInterp, "MeshColorMin", (char *)&MeshColor[0].min, TCL_LINK_DOUBLE );
2481
Tcl_LinkVar( TCLInterp, "MeshColorMax", (char *)&MeshColor[0].max, TCL_LINK_DOUBLE );
2482
Tcl_LinkVar( TCLInterp, "MeshColorSetMinMax", (char *)&MeshColorSetMinMax, TCL_LINK_INT );
2483
2484
Tcl_LinkVar( TCLInterp, "ContourLines", (char *)&ContourLines, TCL_LINK_INT );
2485
Tcl_LinkVar( TCLInterp, "ContourLineStyle", (char *)&ContourLineStyle, TCL_LINK_INT );
2486
Tcl_LinkVar( TCLInterp, "ContourQuality", (char *)&ContourQuality, TCL_LINK_INT );
2487
Tcl_LinkVar( TCLInterp, "ContourRadius", (char *)&ContourRadius, TCL_LINK_DOUBLE );
2488
2489
Tcl_LinkVar( TCLInterp, "ContourColorMin", (char *)&ContourColor[0].min, TCL_LINK_DOUBLE );
2490
Tcl_LinkVar( TCLInterp, "ContourColorMax", (char *)&ContourColor[0].max, TCL_LINK_DOUBLE );
2491
Tcl_LinkVar( TCLInterp, "ContourColorSetMinMax", (char *)&ContourColorSetMinMax, TCL_LINK_INT );
2492
2493
Tcl_LinkVar( TCLInterp, "VectorLineStyle", (char *)&VectorLineStyle, TCL_LINK_INT );
2494
Tcl_LinkVar( TCLInterp, "VectorQuality", (char *)&VectorQuality, TCL_LINK_INT );
2495
Tcl_LinkVar( TCLInterp, "VectorRadius", (char *)&VectorRadius, TCL_LINK_DOUBLE );
2496
Tcl_LinkVar( TCLInterp, "VectorLengthScale", (char *)&VectorLengthScale, TCL_LINK_DOUBLE );
2497
2498
Tcl_LinkVar( TCLInterp, "VectorCeiling", (char *)&VectorCeiling, TCL_LINK_DOUBLE );
2499
Tcl_LinkVar( TCLInterp, "VectorFloor", (char *)&VectorFloor, TCL_LINK_DOUBLE );
2500
2501
Tcl_LinkVar( TCLInterp, "VectorThresholdMin", (char *)&VectorThreshold.min, TCL_LINK_DOUBLE );
2502
Tcl_LinkVar( TCLInterp, "VectorThresholdMax", (char *)&VectorThreshold.max, TCL_LINK_DOUBLE );
2503
2504
Tcl_LinkVar( TCLInterp, "IsosurfaceStyle", (char *)&IsosurfaceStyle, TCL_LINK_INT );
2505
Tcl_LinkVar( TCLInterp, "IsosurfaceContours", (char *)&IsosurfaceContours, TCL_LINK_INT );
2506
Tcl_LinkVar( TCLInterp, "IsosurfaceLineStyle", (char *)&IsosurfaceLineStyle, TCL_LINK_INT );
2507
Tcl_LinkVar( TCLInterp, "IsosurfaceQuality", (char *)&IsosurfaceQuality, TCL_LINK_INT );
2508
Tcl_LinkVar( TCLInterp, "IsosurfaceRadius", (char *)&IsosurfaceRadius, TCL_LINK_DOUBLE );
2509
Tcl_LinkVar( TCLInterp, "IsosurfaceRecompute", (char *)&IsosurfaceRecompute, TCL_LINK_INT );
2510
Tcl_LinkVar( TCLInterp, "IsosurfaceColorMin", (char *)&IsosurfaceColor.min, TCL_LINK_DOUBLE );
2511
Tcl_LinkVar( TCLInterp, "IsosurfaceColorMax", (char *)&IsosurfaceColor.max, TCL_LINK_DOUBLE );
2512
Tcl_LinkVar( TCLInterp, "IsosurfaceColorSetMinMax", (char *)&IsosurfaceColorSetMinMax, TCL_LINK_INT );
2513
2514
Tcl_LinkVar( TCLInterp, "IsosurfaceContourSetMinMax", (char *)&IsosurfaceContourSetMinMax, TCL_LINK_INT );
2515
Tcl_LinkVar( TCLInterp, "IsosurfaceContourMin", (char *)&IsosurfaceContour.min, TCL_LINK_DOUBLE );
2516
Tcl_LinkVar( TCLInterp, "IsosurfaceContourMax", (char *)&IsosurfaceContour.max, TCL_LINK_DOUBLE );
2517
2518
Tcl_LinkVar( TCLInterp, "ParticleStyle", (char *)&ParticleStyle, TCL_LINK_INT );
2519
Tcl_LinkVar( TCLInterp, "ParticleLineStyle", (char *)&ParticleLineStyle, TCL_LINK_INT );
2520
Tcl_LinkVar( TCLInterp, "ParticleArrowStyle", (char *)&ParticleArrowStyle, TCL_LINK_INT );
2521
Tcl_LinkVar( TCLInterp, "ParticleQuality", (char *)&ParticleQuality, TCL_LINK_INT );
2522
Tcl_LinkVar( TCLInterp, "ParticleRadius", (char *)&ParticleRadius, TCL_LINK_DOUBLE );
2523
Tcl_LinkVar( TCLInterp, "ParticleOutDT", (char *)&ParticleOutDT, TCL_LINK_DOUBLE );
2524
Tcl_LinkVar( TCLInterp, "ParticleMaxDT", (char *)&ParticleMaxDT, TCL_LINK_DOUBLE );
2525
Tcl_LinkVar( TCLInterp, "ParticleTolerance", (char *)&ParticleTolerance, TCL_LINK_DOUBLE );
2526
Tcl_LinkVar( TCLInterp, "ParticleNofParticles", (char *)&ParticleNofParticles, TCL_LINK_INT );
2527
Tcl_LinkVar( TCLInterp, "ParticleAdvance", (char *)&ParticleAdvance, TCL_LINK_INT );
2528
Tcl_LinkVar( TCLInterp, "ParticleIntegMethod", (char *)&ParticleIntegMethod, TCL_LINK_INT );
2529
Tcl_LinkVar( TCLInterp, "ParticleIntegPolicy", (char *)&ParticleIntegPolicy, TCL_LINK_INT );
2530
2531
Tcl_LinkVar( TCLInterp, "SphereQuality", (char *)&SphereQuality, TCL_LINK_INT );
2532
Tcl_LinkVar( TCLInterp, "SphereRadiusScale", (char *)&SphereRadiusScale, TCL_LINK_DOUBLE );
2533
Tcl_LinkVar( TCLInterp, "SphereFloor", (char *)&SphereFloor, TCL_LINK_DOUBLE );
2534
Tcl_LinkVar( TCLInterp, "SphereCeiling", (char *)&SphereCeiling, TCL_LINK_DOUBLE );
2535
Tcl_LinkVar( TCLInterp, "SphereThresholdMin", (char *)&SphereThreshold.min, TCL_LINK_DOUBLE );
2536
Tcl_LinkVar( TCLInterp, "SphereThresholdMax", (char *)&SphereThreshold.max, TCL_LINK_DOUBLE );
2537
2538
Tcl_LinkVar( TCLInterp, "ColorScaleStyle", (char *)&ColorScaleStyle, TCL_LINK_INT );
2539
Tcl_LinkVar( TCLInterp, "ColorScaleEntries", (char *)&ColorScaleEntries, TCL_LINK_INT );
2540
Tcl_LinkVar( TCLInterp, "ColorScaleDecimals", (char *)&ColorScaleDecimals, TCL_LINK_INT );
2541
Tcl_LinkVar( TCLInterp, "ColorScaleX", (char *)&ColorScaleX, TCL_LINK_DOUBLE );
2542
Tcl_LinkVar( TCLInterp, "ColorScaleY", (char *)&ColorScaleY, TCL_LINK_DOUBLE );
2543
Tcl_LinkVar( TCLInterp, "ColorScaleThickness", (char *)&ColorScaleThickness, TCL_LINK_DOUBLE );
2544
Tcl_LinkVar( TCLInterp, "ColorScaleLength", (char *)&ColorScaleLength, TCL_LINK_DOUBLE );
2545
Tcl_LinkVar( TCLInterp, "ColorScaleFontColor", (char *)&ColorScaleFontColor, TCL_LINK_INT );
2546
2547
Tcl_LinkVar( TCLInterp, "ColorScaleColorMin", (char *)&ColorScaleColor.min, TCL_LINK_DOUBLE );
2548
Tcl_LinkVar( TCLInterp, "ColorScaleColorMax", (char *)&ColorScaleColor.max, TCL_LINK_DOUBLE );
2549
Tcl_LinkVar( TCLInterp, "ColorScaleColorSetMinMax", (char *)&ColorScaleColorSetMinMax, TCL_LINK_INT );
2550
2551
2552
Tcl_LinkVar( TCLInterp, "GraphicsClearOn", (char *)&GraphicsClearOn, TCL_LINK_INT );
2553
2554
2555
Tcl_LinkVar( TCLInterp, "KeepScale", (char *)&KeepScale, TCL_LINK_INT );
2556
2557
Tcl_LinkVar( TCLInterp, "NormalUpdate", (char *)&NormalUpdate, TCL_LINK_INT );
2558
2559
strcpy( tmp , "GlobalOptions(SurfaceSides)" );
2560
Tcl_LinkVar( TCLInterp, tmp, (char *)&GlobalOptions.SurfaceSides, TCL_LINK_INT );
2561
2562
strcpy( tmp , "GlobalOptions(VolumeSides)" );
2563
Tcl_LinkVar( TCLInterp, tmp, (char *)&GlobalOptions.VolumeSides, TCL_LINK_INT );
2564
2565
strcpy( tmp , "GlobalOptions(VolumeEdges)" );
2566
Tcl_LinkVar( TCLInterp, tmp, (char *)&GlobalOptions.VolumeEdges, TCL_LINK_INT );
2567
2568
strcpy( tmp , "GlobalOptions(StereoMode)" );
2569
Tcl_LinkVar( TCLInterp, tmp, (char *)&GlobalOptions.StereoMode, TCL_LINK_INT );
2570
strcpy( tmp , "GlobalOptions(StereoTran)" );
2571
Tcl_LinkVar( TCLInterp, tmp, (char *)&GlobalOptions.StereoTran, TCL_LINK_DOUBLE );
2572
strcpy( tmp , "GlobalOptions(StereoRot)" );
2573
Tcl_LinkVar( TCLInterp, tmp, (char *)&GlobalOptions.StereoRot, TCL_LINK_DOUBLE );
2574
2575
strcpy( tmp , "GlobalOptions(OutputPS)" );
2576
Tcl_LinkVar( TCLInterp, tmp, (char *)&GlobalOptions.OutputPS, TCL_LINK_INT );
2577
strcpy( tmp , "GlobalOptions(FitToPagePS)" );
2578
Tcl_LinkVar( TCLInterp, tmp, (char *)&GlobalOptions.FitToPagePS, TCL_LINK_INT );
2579
2580
Misc_Init( TCLInterp );
2581
Transforms_Init( TCLInterp );
2582
Readfile_Init( TCLInterp );
2583
Matctcl_Init( TCLInterp );
2584
2585
2586
signal( SIGFPE, SIG_IGN );
2587
signal( SIGINT, int_sig );
2588
2589
2590
*init = '\0';
2591
if ( getenv("ELMER_POST_HOME") )
2592
{
2593
strncat( init,getenv("ELMER_POST_HOME"),511);
2594
strncat( init,"/",511 );
2595
}
2596
strncat( init,"tcl/init.tcl",511 );
2597
fprintf( stdout, "Initialization File: [%s]\n", init );
2598
fflush(stdout);
2599
Tcl_EvalFile( TCLInterp,init );
2600
2601
while( Tk_DoOneEvent(TCL_DONT_WAIT) );
2602
2603
#ifdef MINGW32
2604
auxReshapeFunc( (AUXRESHAPEPROC)Reshape );
2605
auxExposeFunc( (AUXEXPOSEPROC)Reshape );
2606
auxIdleFunc( (AUXIDLEPROC)TestTkEvent );
2607
#else
2608
auxReshapeFunc( Reshape );
2609
auxExposeFunc( Reshape );
2610
auxIdleFunc( TestTkEvent );
2611
auxMouseFunc( AUX_LEFTBUTTON, AUX_MOUSEDOWN, Mouse );
2612
auxMouseFunc( AUX_MIDDLEBUTTON, AUX_MOUSEDOWN, Mouse );
2613
#endif
2614
2615
2616
gra_init();
2617
2618
#ifndef MINGW32
2619
InitializeXFonts();
2620
#else
2621
MakeRasterFontDefault();
2622
#endif
2623
2624
{
2625
Tcl_DString dstring;
2626
char *buf;
2627
2628
buf = Tcl_ExternalToUtfDString( NULL, initcommands,strlen(initcommands),&dstring);
2629
Tcl_Eval( TCLInterp, buf );
2630
Tcl_DStringFree( &dstring );
2631
}
2632
2633
if ( getenv("ELMER_POST_INIT") )
2634
{
2635
*init = '\0';
2636
strncat( init,getenv("ELMER_POST_INIT"),511);
2637
fprintf( stdout, "User initialization file: [%s]\n", init );
2638
fflush(stdout);
2639
Tcl_EvalFile( TCLInterp,init );
2640
while( Tk_DoOneEvent(TCL_DONT_WAIT) );
2641
}
2642
2643
#ifdef MINGW32
2644
auxMainLoop( (AUXMAINPROC)DrawItSomeTimeWhenIdle );
2645
#else
2646
auxMainLoop(TestTkEvent);
2647
#endif
2648
}
2649
2650