Newer
Older
/*
* Main program for FLTK-based partiview.
* Stuart Levy, slevy@ncsa.uiuc.edu
* National Center for Supercomputing Applications,
* University of Illinois 2001.
* This file is part of partiview, released under the
* Illinois Open Source License; see the file LICENSE.partiview for details.
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#ifdef WIN32
# include "winjunk.h"
#endif
#include "Gview.H"
#include "partiview.H"
#include "shmem.h"
#include <string.h>
#include <stdarg.h>
#include <math.h>
#include <errno.h>
#include "findfile.h"
# include <FL/Fl.H>
# include <FL/fl_draw.H>
# include "genericslider.H" //steven marx: generic slider introduced version 0.7.02
# include <FL/Fl_Tooltip.H> //steven marx: version 0.7.02 now using fltk-1.1.2
# if HAVE_OLD_FILE_CHOOSER_H
# include <FL/fl_file_chooser.H> /* fltk 1.0.* and 1.1.rcX for X<6 */
# else
# include <FL/Fl_File_Chooser.H> /* fltk 1.1.0rc6 and later */
# endif
#include <FL/glut.H> // for GLUT_MULTISAMPLE if fltk knows it
#ifdef EMBEDHACK
# include "pview_funcs.h"
#endif
extern "C" { extern void plugin_init(); }
struct stuff *stuffs[MAXSTUFF];
static int specks_commandstr( struct stuff **stp, const char *str ) {
if(stp == NULL || *stp == NULL || str == NULL)
return 0;
#define MAXARGS 128
char *av[MAXARGS];
int ac;
char *txt = (char *)alloca( strlen(str) + 1 );
char *s = txt;
strcpy(txt, str);
for(ac = 0; ac < MAXARGS-1; ac++) {
av[ac] = strtok(s, " \t\n");
if(av[ac] == NULL) break;
s = NULL;
}
av[ac] = NULL;
return specks_parse_args( stp, ac,av);
}
int specks_commandfmt( struct stuff **stp, const char *fmt, ... ) {
int ok;
va_list args;
va_start(args, fmt);
vsprintf(cmd, fmt, args);
va_end(args);
for(cp = cmd; isspace(*cp); cp++)
;
if(*cp == '\0') return 1; // accept null command implicitly
ok = specks_commandstr( stp, cmd );
if(ok) parti_redraw();
else msg("Unrecognized control command: %s", cmd);
return ok;
}
/* =================================================================== */
void pp_clk_init() {
ppui.clk = NewN( SClock, 1 );
clock_init( ppui.clk );
clock_set_speed( ppui.clk, 1.0 );
ppui.clk->continuous = 1; // is this used?
ppui.clk->walltimed = 1;
}
void pp_ui_postinit() {
parti_set_timebase( ppui.st, 0.0 );
parti_set_timestep( ppui.st, 0.0 );
parti_set_running( ppui.st, 0 );
parti_set_fwd( ppui.st, 1 );
ppui.stepspeed->logstyle( FL_LOG_LINEAR );
ppui.stepspeed->truebounds( 1.0e-6, 10.0 );
ppui.stepspeed->truevalue( clock_speed( ppui.clk ) );
if(ppui.detached) {
char code[2] = { ppui.detached, '\0' };
parti_detachview(code);
}
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
#ifdef FLHACK
void ppui_refresh()
{ }
#else /* !FLHACK */
void pp_nav_init(Fl_Menu_Button *);
int pp_viewevent_cb( Fl_Gview *, int ev );
int gensliderchg = 0; //steven marx: generic slider introduced version 0.7.02
void pp_ui_init() {
pp_nav_init(ppui.nav);
pp_sldtype_init(ppui.sldtype); //steven marx: version 0.7.02
genericslider_initparam(); //steven marx: version 0.7.02
/* ppui.cmd->handle_cb = pp_cmd_handle_cb; No, this doesn't work yet */
ppui.view->eventhook = pp_viewevent_cb;
parti_inertia( 1 );
if(getenv("CMDFONT"))
ppui.cmdhist->scaletext( atoi( getenv("CMDFONT") ) );
ppui.freewin = NULL;
ppui.boundwin = ppui.view;
ppui.detached = 0;
#ifdef DEFAULT_ELUMENS
ppui.detached = 'f';
#endif
}
void pp_cmd_cb( HistInput* inp, void * ) {
if(inp->hist())
inp->hist()->addline( inp->value(), 0 );
const char *cp;
for(cp = inp->value(); isspace(*cp); cp++)
;
if(*cp == '\0')
return; // accept null command implicitly
int ok = specks_commandstr( &ppui.st, inp->value() );
if(!ok)
msg("Unrecognized control command: %s", inp->value());
parti_redraw();
genericslider_setparam(); //steven marx version 0.7.02 update generic slider
}
static enum Gv_Nav codes[] = { GV_FLY, GV_ORBIT, GV_ROTATE, GV_TRANSLATE };
static char *navtitles[] = {"[f]ly","[o]rbit","[r]ot","[t]ran"};
void pp_nav_init(Fl_Menu_Button *m) {
m->add("[f]ly|[o]rbit|[r]ot|[t]ran");
for(int i = m->size(); --i >= 0; )
(((Fl_Menu_Item *)(m->menu()))[i]).labelcolor( m->labelcolor() );
}
void pp_nav_cb(Fl_Menu_Button* m, struct stuff **vst) {
int v = m->value();
if(v >= 0 && v < COUNT(codes))
ppui.view->nav( codes[v] );
}
void pp_obj_cb(Fl_Menu_Button* m, void *) {
Loading
Loading full blame...