Newer
Older
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
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
# include "winjunk.h"
#endif
#include <GL/gl.h>
#include "geometry.h"
#include "shmem.h"
#include <string.h>
#include <stdarg.h>
#include <math.h>
#include <errno.h>
#include <signal.h>
#if unix
# include <GL/glx.h> /* for try_stereo() */
# include <FL/x.H>
#endif
#include "specks.h"
#include "partiview.H"
#include "partiviewc.h"
#include <ctype.h>
#undef isspace /* hack for irix 6.5 */
extern "C" {
/* Handle pick results */
void specks_picker( Fl_Gview *gview, int nhits, int nents, GLuint *hitbuf, void *vview )
{
Fl_Gview *view = (Fl_Gview *)vview;
struct stuff *st;
unsigned int bestz = ~0u;
struct stuff *bestst = NULL;
struct specklist *bestsl;
int bestspeckno;
int id, bestid = -1;
Point bestpos, wpos;
int centerit = Fl::event_state(FL_SHIFT);
for(id = 0; id < MAXSTUFF; id++) {
if((st = stuffs[id]) == NULL) continue;
if(specks_partial_pick_decode( st, id, nhits, nents, hitbuf,
&bestz, &bestsl, &bestspeckno, &bestpos )) {
bestst = st;
bestid = id;
}
}
if(bestst) {
char fmt[1024], wpostr[80];
vtfmpoint( &wpos, &bestpos, view->To2w( bestid ) );
if(memcmp( &wpos, &bestpos, sizeof(wpos) )) {
sprintf(wpostr, " (w%g %g %g)", wpos.x[0],wpos.x[1],wpos.x[2]);
} else {
wpostr[0] = '\0';
}
strcpy(fmt, bestsl->bytesperspeck < sizeof(struct speck)
? "[g%d]%sPicked %g %g %g%s%.0s (of %d)"
: "[g%d]%sPicked %g %g %g%s \"%s\" (of %d)");
if(bestsl->text == NULL && bestst->vdesc[bestst->curdata][0].name[0] != '\0') {
strcat(fmt, ";");
for(int i = 0; i < MAXVAL && bestst->vdesc[bestst->curdata][i].name[0]; i++)
sprintf(fmt+strlen(fmt), " %.9s %%g", bestst->vdesc[bestst->curdata][i].name);
}
struct speck *sp = NextSpeck( bestsl->specks, bestsl, bestspeckno);
msg(fmt, bestid, centerit?"*":"",
bestpos.x[0],bestpos.x[1],bestpos.x[2], wpostr,
bestsl->text ? bestsl->text : sp->title, nhits,
sp->val[0],sp->val[1],sp->val[2],sp->val[3],sp->val[4],
sp->val[5],sp->val[6],sp->val[7],sp->val[8],sp->val[9]);
if(centerit) {
gview->center( &wpos );
if(ppui.censize > 0) gview->redraw();
}
} else {
msg("Picked nothing (%d hits)", nhits);
}
}
void draw_specks( Fl_Gview *view, void *vst, void *junk ) {
struct stuff *st = (struct stuff *)vst;
specks_current_frame( st, st->sl );
st->inpick = view->inpick();
drawspecks( st );
st->inpick = 0;
}
void parti_allobjs( int argc, char *argv[] ) {
for(int i = 0; i < MAXSTUFF; i++) {
struct stuff *st = stuffs[i];
if(st)
specks_parse_args( &st, argc, argv );
}
}
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
void parti_redraw() {
if(ppui.view) ppui.view->redraw();
}
void parti_update() {
if(ppui.view)
while(ppui.view->damage())
Fl::wait(.1);
}
void parti_censize( float newsize ) {
if(newsize != ppui.censize) ppui.view->redraw();
ppui.censize = newsize;
}
float parti_getcensize() {
return ppui.censize;
}
char *parti_bgcolor( const char *rgb ) {
static char bgc[16];
Point bgcolor;
bgcolor = *ppui.view->bgcolor();
if(rgb) {
if(1 == sscanf(rgb, "%f%*c%f%*c%f", &bgcolor.x[0], &bgcolor.x[1], &bgcolor.x[2]))
bgcolor.x[1] = bgcolor.x[2] = bgcolor.x[0];
ppui.view->bgcolor( &bgcolor );
}
sprintf(bgc, "%.3f %.3f %.3f", bgcolor.x[0],bgcolor.x[1],bgcolor.x[2]);
return bgc;
}
int *try_quad_stereo()
{
#if unix
static int attrs[] = {
#ifdef GLX_SAMPLE_BUFFERS_SGIS
GLX_SAMPLE_BUFFERS_SGIS, 1,
GLX_SAMPLES_SGIS, 4,
#endif
GLX_STEREO,
GLX_RGBA,
GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DEPTH_SIZE, 1,
None
};
int *ap = attrs;
#ifdef GLX_SAMPLE_BUFFERS_SGIS
if(Fl_Gl_Window::can_do( ap )) return ap;
ap += 4;
#endif
/* When our view window(s) are created, make sure they ask for the
* same set of values.
*/
if(Fl_Gl_Window::can_do( ap ))
return ap;
return NULL;
#else /* win32 */
return NULL;
#endif
}
char *parti_stereo( const char *ster )
{
static char rslt[28];
static enum Gv_Stereo stereotype = GV_MONO;
static int *quadmode = NULL;
static char *sternames[] = { "mono", "redcyan", "crosseyed", "glasses" };
int smode = -1;
if(stereotype == GV_MONO) {
quadmode = try_quad_stereo();
stereotype = (quadmode!=NULL) ? GV_QUADBUFFERED : GV_REDCYAN;
}
if(ster) {
float v;
if(sscanf(ster, "%f", &v)) {
ppui.view->stereosep(v);
smode = stereotype;
}
if(strstr(ster,"on"))
smode = stereotype;
if(strstr(ster,"off"))
smode = GV_MONO;
if(strstr(ster, "red"))
smode = stereotype = GV_REDCYAN;
if(strstr(ster, "quad") || strstr(ster, "gla") ||
strstr(ster, "hard") || strstr(ster, "hw")) {
if(quadmode != NULL) {
smode = stereotype = GV_QUADBUFFERED;
} else {
msg("Can't do quadbuffered/hardware stereo");
smode = GV_MONO;
}
}
if(smode < 0) {
msg("stereo: [on|off|redcyan|glasses] [stereosep]");
msg(" Try stereosep values from 0.02 to 0.1, or -.02 .. -.1 to swap eyes");
}
}
if(smode >= 0) {
if(smode == (int)GV_QUADBUFFERED)
ppui.view->mode( quadmode );
else
ppui.view->mode( FL_RGB | FL_DOUBLE | FL_DEPTH | FL_MULTISAMPLE );
ppui.view->stereo( (enum Gv_Stereo)smode );
}
smode = ppui.view->stereo();
sprintf(rslt, "%g %s",
ppui.view->stereosep(),
(smode<=0||smode>=COUNT(sternames)) ? "off" : sternames[smode]);
return rslt;
}
char *parti_clip( const char *nearclip, const char *farclip ) {
float n, f;
if(nearclip != NULL && sscanf(nearclip, "%f", &n) > 0)
ppui.view->nearclip( n );
if(farclip != NULL && sscanf(farclip, "%f", &f) > 0)
ppui.view->farclip( f );
static char why[16];
sprintf(why, "clip %.4g %.4g", ppui.view->nearclip(), ppui.view->farclip());
return why;
}
int parti_move( const char *onoffobj, struct stuff **newst ) {
int objno = -1;
if(onoffobj) {
if(!strcmp(onoffobj, "off"))
ppui.view->movingtarget(0);
else if(!strcmp(onoffobj, "on"))
ppui.view->movingtarget(1);
else if(sscanf(onoffobj, "g%d", &objno) > 0 ||
sscanf(onoffobj, "%d", &objno) > 0) {
ppui.view->movingtarget(1);
objno = parti_object( onoffobj, newst );
} else {
msg("move {on|off|g<N>} -- select whether navigation can move sub-objects");
}
}
return ppui.view->movingtarget() ? ppui.view->target() : -1;
}
int parti_snapset( char *fname, char *frameno )
{
int len;
static char suf[] = ".%03d.ppm.gz";
int needsuf;
if(fname) {
len = strlen(fname);
needsuf = (0==strchr(fname, '%')) ? 0 : sizeof(suf)-1;
if(ppui.snapfmt) Free(ppui.snapfmt);
ppui.snapfmt = NewN(char, len+needsuf+1);
sprintf(ppui.snapfmt, needsuf ? "%s" : "%s%s", fname, suf);
frameno = 0;
}
if(frameno)
sscanf(frameno, "%d", &ppui.snapfno);
return ppui.snapfno;
}
int parti_snapshot( char *snapinfo )
{
char tfcmd[10240], *tftail;
int fail;
#if !WIN32 /* if unix */
static char defsnap[] = "snap.%03d.tif";
static char prefix[] = "|convert ppm:- ";
#else
static char defsnap[] = "snap.%03d.ppm";
static char prefix[] = "";
#endif
if(snapinfo) snapinfo[0] = '\0';
if(ppui.snapfmt == NULL) {
ppui.snapfmt = NewN(char, sizeof(defsnap));
strcpy(ppui.snapfmt, defsnap);
}
tftail = tfcmd;
if(ppui.snapfmt[0] != '|') {
strcpy(tfcmd, prefix);
tftail = tfcmd+sizeof(prefix)-1;
}
sprintf(tftail, ppui.snapfmt, ppui.snapfno);
if(!ppui.view || !ppui.view->visible_r()) {
msg("snapshot: no visible graphics window?");
return -2;
}
Fl_Widget *pa;
for(pa = ppui.view; pa->parent(); pa = pa->parent()) ;
pa->show(); // raise window
// Ensure window's image is up-to-date
parti_update();
int y, h = ppui.view->h(), w = ppui.view->w();
char *buf = (char *)malloc(w*h*3);
if(!ppui.view->snapshot( 0, 0, w, h, buf )) {
free(buf);
msg("snapshot: couldn't read from graphics window?");
return -2;
}
#if !WIN32
void (*oldpipe)(int) = signal(SIGPIPE, SIG_IGN);
FILE *p = popen(tfcmd+1, "w");
#else /* WIN32 */
FILE *p = fopen(tfcmd, "w");
#endif
fprintf(p, "P6\n%d %d\n255\n", w, h);
for(y = h; --y >= 0 && fwrite(&buf[w*3*y], w*3, 1, p) > 0; )
;
free(buf);
fflush(p);
fail = ferror(p);
#if !WIN32
pclose(p); /* unix */
signal(SIGPIPE, oldpipe);
#else
fclose(p); /* win32 */
#endif
if(y >= 0 || fail) {
msg("snapshot: Error writing to %s", tfcmd);
return -1;
}
if(snapinfo)
sprintf(snapinfo, "%.1000s [%dx%d]", tftail, w, h);
return ppui.snapfno++;
}
/*
* This is how new objects get created -- via "object g<N>" command.
*/
int parti_object( const char *objname, struct stuff **newst ) {
int i;
if(newst)
*newst = ppui.st;
if(objname == NULL) {
for(i = 1; i < MAXSTUFF; i++)
if(ppui.st == stuffs[i]) return i;
return -1;
}
if(ppui.view == NULL)
return -1;
if(!strcmp(objname, "c") || !strcmp(objname, "c0")) {
ppui.view->target( GV_ID_CAMERA );
return -1;
}
if((sscanf(objname, "g%d", &i) > 0 || sscanf(objname, "%d", &i) > 0
|| sscanf(objname, "[g%d]", &i) > 0)
&& i >= 0 && i < MAXSTUFF) {
if(stuffs[i] == NULL) {
stuffs[i] = specks_init( 0, NULL );
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
ppui.view->add_drawer( draw_specks, stuffs[i], NULL, NULL, i );
ppui.view->picker( specks_picker, ppui.view );
ppui.view->picksize( 4.0, 4.0 );
char tname[12];
sprintf(tname, "[g%d]", i);
int me = ppui.obj->add( strdup(tname) );
((Fl_Menu_Item *)ppui.obj->menu())[me].labelcolor( ppui.obj->labelcolor() );
}
ppui.st = stuffs[i];
ppui.view->target( i );
ppui_refresh( ppui.st );
if(newst) *newst = stuffs[i];
return i;
}
msg("Don't understand object name \"%s\"", objname);
return -1;
}
float parti_focal( char *newfocal ) {
float focallen;
if(newfocal && sscanf(newfocal, "%f", &focallen) > 0)
ppui.view->focallen( focallen );
return ppui.view->focallen();
}
float parti_fovy( char *newfovy ) {
float fovy;
if(newfovy && sscanf(newfovy, "%f", &fovy) > 0)
if(ppui.view->perspective())
ppui.view->angyfov( fovy );
else
ppui.view->halfyfov( 2*fovy );
return ppui.view->perspective() ? ppui.view->angyfov()
: 2 * ppui.view->halfyfov();
}
void parti_getc2w( Matrix *c2w ) {
if(ppui.view && c2w)
*c2w = *ppui.view->Tc2w();
}
void parti_setc2w( const Matrix *c2w ) {
ppui.view->Tc2w( c2w );
}
void parti_seto2w( struct stuff *, int objno, const Matrix *o2w ) {
ppui.view->To2w( objno, o2w );
}
void parti_geto2w( struct stuff *, int objno, Matrix *o2w ) {
*o2w = *ppui.view->To2w( objno );
}
void parti_nudge_camera( Point *disp ) {
Matrix Tc2w, Tdisp, Tnewc2w;
if(ppui.view) {
Tc2w = *ppui.view->Tc2w();
mtranslation( &Tdisp, disp->x[0], disp->x[1], disp->x[2] );
mmmul( &Tnewc2w, &Tc2w,&Tdisp );
ppui.view->Tc2w( &Tnewc2w );
}
}
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
void parti_setpath( struct stuff *st, int nframes, struct wfframe *frames, float fps = 30 ) {
struct wfpath *path = &ppui.path;
if(path->frames != NULL)
free(path->frames);
path->frames = NULL;
path->fps = (fps <= 0 ? 30.0 : fps);
path->nframes = nframes;
path->frame0 = 1;
path->curframe = path->frame0;
if(nframes > 0) {
path->frames = NewN( struct wfframe, nframes );
memcpy( path->frames, frames, nframes*sizeof(struct wfframe) );
}
if(ppui.playframe) {
ppui.playframe->minimum( path->frame0 );
ppui.playframe->maximum( path->frame0 + path->nframes - 1 );
ppui.playframe->value( path->frame0 );
ppui.playtime->step( 1, 100 );
ppui.playtime->minimum( 0.0 );
ppui.playtime->maximum( path->nframes / path->fps );
ppui.playtime->value( 0.0 );
}
}
int parti_readpath( struct stuff *st, const char *fname ) {
int nframes, room;
struct wfframe *fr, *cf;
FILE *f;
char line[256], *cp;
int lno = 0;
if(fname == NULL || (f = fopen(fname, "r")) == NULL) {
msg("readpath: %.200s: cannot open: %s", fname, strerror(errno));
return 0;
}
nframes = 0;
room = 2000;
fr = NewA( struct wfframe, room );
while(fgets(line, sizeof(line), f) != NULL) {
lno++;
for(cp = line; isspace(*cp); cp++)
;
if(*cp == '#' || *cp == '\0') continue;
if(nframes >= room) {
struct wfframe *nfr;
room *= 3;
nfr = NewA( struct wfframe, room );
memcpy( nfr, fr, nframes * sizeof(struct wfframe) );
fr = nfr;
}
cf = &fr[nframes];
if(sscanf(cp, "%f%f%f%f%f%f%f",
&cf->tx,&cf->ty,&cf->tz, &cf->rx,&cf->ry,&cf->rz, &cf->fovy) < 7) {
msg( "readpath: %.200s line %d: expected tx ty tz rx ry rz fovy, got: %.100s",
fname, lno, line);
fclose(f);
return 0;
}
nframes++;
}
fclose(f);
parti_setpath( st, nframes, fr );
parti_setframe( st, 1 );
msg("%d frames in %.200s", nframes, fname);
return 1;
}
static void fd_got_data( int fd, void * ) {
specks_check_async( &ppui.st );
}
void parti_asyncfd(int fd) { Fl::add_fd( fd, fd_got_data ); }
void parti_unasyncfd(int fd) { Fl::remove_fd(fd); }
static void playidle( void * ) {
struct stuff *st = ppui.st;
struct wfpath *path = &ppui.path;
if(!ppui.playing) {
Fl::remove_idle( playidle, st );
ppui.playidling = 0;
return;
}
if(ppui.playspeed == 0)
ppui.playspeed = 1;
int frame = ppui.framebase;
if(ppui.playevery) {
frame += (int) ((ppui.playspeed < 0) /* round away from zero */
? ppui.playspeed - .999f
: ppui.playspeed + .999f);
ppui.framebase = frame;
}
if(frame < path->frame0 || frame >= path->frame0 + path->nframes) {
frame = (frame < path->frame0)
? path->frame0
: path->frame0 + path->nframes-1;
switch(ppui.playloop) {
case 0: /* Not looping; just stop at end. */
Fl::remove_idle( playidle, st );
ppui.playidling = 0;
parti_play( st, "0" );
break;
case -1: /* Bounce: stick at same end of range, change direction */
ppui.playspeed = -ppui.playspeed;
break;
case 1: /* Loop: jump to other end of range */
frame = (frame == path->frame0)
? path->frame0 + path->nframes-1
: path->frame0;
}
ppui.framebase = frame;
parti_setframe( st, frame );
return;
}
/*
* Cases:
* - we're displaying frames slower than real time.
* => use an idle function.
* - we're displaying frames faster than real time.
* => use a timeout.
*/
int needidle = ppui.playidling;
float dt = 0;
if(frame != path->curframe) {
parti_setframe( st, frame );
needidle = 1;
} else {
frame += (ppui.playspeed > 0) ? 1 : -1;
dt = (frame - ppui.framebase) / (ppui.playspeed * path->fps)
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
needidle = (dt < .05);
}
if(needidle && !ppui.playidling) {
Fl::add_idle( playidle, st );
}
if(!needidle && ppui.playidling) {
Fl::remove_idle( playidle, st );
}
ppui.playidling = needidle;
if(!needidle) {
fprintf(stderr, "<%.3f>", dt);
Fl::add_timeout( dt, playidle, st );
}
}
void parti_play( struct stuff *st, const char *rate ) {
struct wfpath *path = &ppui.path;
int playnow = 1;
if(rate != NULL) {
char *ep;
float sp = strtod(rate, &ep);
if(strchr(ep, 's')) playnow = 0;
if(strchr(ep, 'l')) ppui.playloop = 1;
else if(strchr(ep, 'k')) ppui.playloop = -1; /* rock */
else if(strchr(ep, 'f') || strchr(ep, 'e')) ppui.playevery = 1;
else if(strchr(ep, 'r') || strchr(ep, 't')) ppui.playevery = 0;
if(ep != rate) {
if(sp == 0) playnow = 0;
else ppui.playspeed = sp;
}
}
/* Always stop any ongoing timers */
Fl::remove_idle( playidle, st );
Fl::remove_timeout( playidle, st );
ppui.playing = 0;
ppui.playidling = 0;
if(playnow) {
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
ppui.framebase = path->curframe;
if(ppui.playspeed > 0 && path->curframe >= path->frame0+path->nframes-1)
ppui.framebase = path->frame0;
else if(ppui.playspeed < 0 && path->curframe <= path->frame0)
ppui.framebase = path->frame0 + path->nframes - 1;
parti_setframe( st, ppui.framebase );
Fl::add_idle( playidle, st );
ppui.playing = 1;
ppui.playidling = 1;
}
if(ppui.play != NULL) {
ppui.play->label( ppui.playing ? "stop" : "play" );
ppui.play->value( ppui.playing );
ppui.play->redraw();
}
}
void wf2c2w( Matrix *Tcam, const struct wfframe *wf )
{
Matrix Rx, Ry, Rz, T;
mtranslation( &T, wf->tx, wf->ty, wf->tz );
mrotation( &Ry, wf->ry, 'y' );
mrotation( &Rz, wf->rz, 'z' );
mrotation( &Rx, wf->rx, 'x' );
mmmul( Tcam, &Rz, &Rx );
mmmul( Tcam, Tcam, &Ry );
mmmul( Tcam, Tcam, &T ); /* so Tcam = Rz * Rx * Ry * T */
}
int parti_frame( struct stuff *st, CONST char *frameno,
CONST struct wfpath **pp ) {
if(pp != NULL)
*pp = &ppui.path;
if(frameno != NULL)
return parti_setframe( st, atoi(frameno) );
return (ppui.path.frames == NULL || ppui.path.nframes <= 0)
? -1 : ppui.path.curframe;
}
int parti_setframe( struct stuff *st, int fno ) {
struct wfpath *path = &ppui.path;
if(path->frames == NULL || path->nframes <= 0)
return -1;
if(fno < path->frame0)
fno = path->frame0;
else if(fno >= path->frame0 + path->nframes)
fno = path->frame0 + path->nframes - 1;
Matrix Tc2w;
wf2c2w( &Tc2w, &path->frames[fno - path->frame0] );
ppui.view->Tc2w( &Tc2w );
ppui.view->angyfov( path->frames[fno - path->frame0].fovy );
path->curframe = fno;
if(ppui.playframe) {
ppui.playframe->value( fno );
float t = (fno - path->frame0) / path->fps;
if(fabs(t - ppui.playtime->value()) * path->fps > .5)
ppui.playtime->value( t );
}
return fno - path->frame0;
}
void parti_center( const Point *cen )
{
if(ppui.view)
ppui.view->center( cen );
}
void parti_getcenter( Point *cen ) {
if(ppui.view && cen)
*cen = *ppui.view->center();
}
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
void parti_set_speed( struct stuff *st, double speed ) {
ppui.stepspeed->truevalue( speed );
}
void parti_set_timebase( struct stuff *st, double timebase ) {
char str[32];
ppui.timebasetime = timebase;
sprintf(str, "%.16lg", timebase);
ppui.timebase->value( str );
parti_set_timestep( st, clock_time( st->clk ) );
}
void parti_set_timestep( struct stuff *st, double timestep ) {
char str[32];
sprintf(str, "%.16lg", timestep - ppui.timebasetime);
ppui.timestep->value( str );
}
void parti_set_running( struct stuff *st, int running ) {
int fwdbtn = (clock_fwd( st->clk ) > 0);
ppui.runstop[!fwdbtn]->value(0);
ppui.runstop[fwdbtn]->value(running);
clock_set_running( st->clk, running );
}
void parti_set_fwd( struct stuff *st, int fwd ) {
int fwdbtn = (fwd > 0);
ppui.runstop[!fwdbtn]->value(0);
ppui.runstop[fwdbtn]->value( clock_running( st->clk ) );
}