static COMMAND_FUNC( do_gen_xpose ) { Data_Obj *dp; int d1,d2; dp = pick_obj(""); d1=(int)how_many("dimension index #1"); d2=(int)how_many("dimension index #2"); if( dp == NULL ) return; gen_xpose(dp,d1,d2); }
static COMMAND_FUNC( do_create_area ) { const char *area_name; long n; long siz; area_name = NAMEOF("name for this area"); siz = (long) how_many("size of data area in bytes"); n = (long) how_many("maximum number of data objects for this area"); INSIST_POSITIVE_NUM(siz,"number of bytes","create_area"); INSIST_POSITIVE_NUM(n,"maximum number of objects","create_area"); curr_ap=new_area(area_name, (dimension_t) siz,(unsigned int)n); // do_create_area }
static COMMAND_FUNC( do_set_ncomps ) { int nc; nc=(int)how_many("number of image components"); set_ncomps(nc); }
static COMMAND_FUNC( do_lvlspercomp ) { int n; n=(int)how_many("number of levels per component"); set_lvls_per_comp(n); }
int _get_strings(QSP_ARG_DECL Screen_Obj *sop,const char ***sss) { const char **string_arr; int i; int n; n=(int)how_many("number of items"); if( n < 0 ){ SET_SOB_N_SELECTORS(sop,0); sprintf(ERROR_STRING,"get_strings: number of selectors must be non-negative!?"); WARN(ERROR_STRING); return -1; } // do this after returning //SET_SOB_N_SELECTORS(sop,n); /* so_action_text is set to some garbage */ if( n > 0 ){ string_arr = (const char **)getbuf( n * sizeof(char *) ); // do this after returning // SET_SOB_SELECTORS(sop,string_arr); for(i=0;i<n;i++){ string_arr[i]=savestr(nameof("selector text") ); } *sss = string_arr; } else { *sss = NULL; } return(n); }
static COMMAND_FUNC( do_get_align ) { int a; a=(int)how_many("alignment (in bytes, negative to disable)"); set_dp_alignment(a); }
static COMMAND_FUNC( new_obj_list ) { int n; const char *s; List *lp; Node *np; s=NAMEOF("object name"); n=how_many("number of objects in this list"); lp=new_list(); while(n--){ Data_Obj *dp; dp = pick_obj(""); if( dp != NULL ){ np=mk_node(dp); addTail(lp,np); } } if( make_obj_list(s,lp) == NULL ){ sprintf(ERROR_STRING,"error making object list %s"); warn(ERROR_STRING); } }
static COMMAND_FUNC( do_sine_mod ) { int nf,per; int nc; float phase[8]; const char *s; int i; nf=(int)how_many("number of frames"); per=(int)how_many("period in frames"); s=nameof("lut buffer name stem"); nc=get_ncomps(); for(i=0;i<nc;i++) phase[i] = (float)(i*2*atan(1)); sine_mod_amp(nf,phase,per,(float *)NULL,s); }
static COMMAND_FUNC( do_set_n_linear ) { int n; n=(int)how_many("number of linearization table entries"); set_n_linear(n); CHECK_DPYP("do_set_n_linear") #ifdef HAVE_X11 lin_setup(DPA_LINTBL_OBJ(current_dpyp),crt_gamma,crt_vzero); #endif /* HAVE_X11 */ }
static COMMAND_FUNC( do_set_base ) { int i; i=(int)how_many("index of base color"); if( i< 0 || i > (N_COLORS-1) ){ warn("invalid base index"); return; } set_base_index(i); }
static COMMAND_FUNC( do_bitplanes ) { int nplanes; int i; float amplist[MAX_BIT_PLANES]; nplanes = (int)how_many("number of image components"); for(i=0;i<nplanes;i++) amplist[i]=(float)how_much("vector amplitude"); set_bitplanes(nplanes, amplist); }
static COMMAND_FUNC( new_gen_obj ) { Dimension_Set ds1, *dsp=(&ds1); const char *obj_name; long ns, nf, nr, nc, ncomps; Precision *prec_p; obj_name=NAMEOF("object name"); ns = (long) how_many("number of sequences"); nf = (long) how_many("number of frames"); nr = (long) how_many("number of rows"); nc = (long) how_many("number of columns"); ncomps = (long) how_many("number of components"); prec_p = get_precision(SINGLE_QSP_ARG); if( prec_p == NULL ) return; INSIST_POSITIVE_DIM(ns,"sequence","new_gen_obj"); INSIST_POSITIVE_DIM(nf,"frame","new_gen_obj"); INSIST_POSITIVE_DIM(nr,"row","new_gen_obj"); INSIST_POSITIVE_DIM(nc,"column","new_gen_obj"); INSIST_POSITIVE_DIM(ncomps,"component","new_gen_obj"); SET_DIMENSION(dsp,4,ns); SET_DIMENSION(dsp,3,nf); SET_DIMENSION(dsp,2,nr); SET_DIMENSION(dsp,1,nc); SET_DIMENSION(dsp,0,ncomps); if( *obj_name == 0 ){ warn("new_gen_obj: Null object name!?"); return; // shouldn't happen, but can - HOW??? // If it can, then should move this check to finish_obj??? } finish_obj(obj_name,dsp,prec_p,AUTO_SHAPE); }
static COMMAND_FUNC( mksubstring ) { const char *obj_name; Data_Obj *dp, *newdp; long len; long sos; obj_name=NAMEOF("name for substring"); dp=pick_obj(PARENT_PROMPT); len=(long) how_many("number of characters"); sos=(index_t)how_many("offset"); if( dp==NULL ) return; INSIST_POSITIVE_DIM(len,"character","mksubstring") INSIST_NONNEGATIVE(sos,"x offset","mksubstring") newdp=mk_substring(dp,(index_t)sos,obj_name,(dimension_t)len); if( newdp == NULL ) warn("couldn't create substring"); }
static COMMAND_FUNC( mksubscalar ) { const char *obj_name; Data_Obj *dp, *newdp; index_t offsets[N_DIMENSIONS]; Dimension_Set ds1, *dsp=(&ds1); long ncomps, comp_offset; obj_name=NAMEOF("name for subscalar"); dp=pick_obj(PARENT_PROMPT); ncomps = (long) how_many("number of components"); comp_offset = (long) how_many("component offset"); if( dp==NULL ) return; INSIST_POSITIVE_DIM(ncomps,"component","mksubscalar"); INSIST_NONNEGATIVE(comp_offset,"component offset","mksubscalar"); SET_DIMENSION(dsp,0,ncomps); SET_DIMENSION(dsp,1,1); SET_DIMENSION(dsp,2,1); SET_DIMENSION(dsp,3,1); SET_DIMENSION(dsp,4,1); offsets[0]=(index_t)comp_offset; offsets[1]=0; offsets[2]=0; offsets[3]=0; offsets[4]=0; newdp=mk_subseq(obj_name,dp,offsets,dsp); if( newdp == NULL ) warn("couldn't create subscalar"); }
static COMMAND_FUNC( mksubsequence ) { const char *obj_name; Data_Obj *dp, *newdp; index_t offsets[N_DIMENSIONS]; Dimension_Set ds1, *dsp=(&ds1); long x_offset, y_offset, t_offset; long nr,nc,nf; obj_name=NAMEOF("name for subsequence"); dp=pick_obj(PARENT_PROMPT); nc = (long) how_many("number of columns"); nr = (long) how_many("number of rows"); nf = (long) how_many("number of frames"); x_offset=(long) how_many("x offset"); y_offset=(long) how_many("y offset"); t_offset=(long) how_many("t offset"); if( dp==NULL ) return; INSIST_POSITIVE_DIM(nc,"column","mksubsequence"); INSIST_POSITIVE_DIM(nr,"row","mksubsequence"); INSIST_POSITIVE_DIM(nf,"frame","mksubsequence"); INSIST_NONNEGATIVE(x_offset,"x offset","mksubsequence"); INSIST_NONNEGATIVE(y_offset,"y offset","mksubsequence"); INSIST_NONNEGATIVE(t_offset,"t offset","mksubsequence"); offsets[0]=0; offsets[1]=(index_t)x_offset; offsets[2]=(index_t)y_offset; offsets[3]=(index_t)t_offset; offsets[4]=0; SET_DIMENSION(dsp,0,OBJ_COMPS(dp)); SET_DIMENSION(dsp,1,nc); SET_DIMENSION(dsp,2,nr); SET_DIMENSION(dsp,3,nf); SET_DIMENSION(dsp,4,1); newdp=mk_subseq(obj_name,dp,offsets,dsp); if( newdp == NULL ) warn("couldn't create subimage"); }
static COMMAND_FUNC( new_scalar ) { Dimension_Set ds1; Dimension_Set *dsp=(&ds1); const char *obj_name; long ncomps; Precision *prec_p; obj_name=NAMEOF("object name"); ncomps = (long) how_many("number of components"); prec_p = get_precision(SINGLE_QSP_ARG); if( prec_p == NULL ) return; INSIST_POSITIVE_DIM(ncomps,"component","new_scalar"); SET_DIMENSION(dsp,4,1); SET_DIMENSION(dsp,3,1); SET_DIMENSION(dsp,2,1); SET_DIMENSION(dsp,1,1); SET_DIMENSION(dsp,0,ncomps); finish_obj(obj_name,dsp,prec_p,DT_SCALAR); }
static int tiff_tilesdown(TIFF *tif) { int h = tiff_imagelength(tif); int th = tiff_tilelength(tif); return how_many(h, th); }
static COMMAND_FUNC( do_drift_plane ) { int k; struct drift_plane dp; float vectbl[MAX_BIT_PLANES][3]; /* Sets base_index */ do_set_base(); /* Set white point r,g,b */ do_setwhite(); dp.ndirections = how_many("number of directions"); if (dp.ndirections > MAX_DIRECTIONS) { sprintf(w.w_str,"ndirections set to max value of %d", MAX_DIRECTIONS); warn(w.w_str); dp.ndirections = MAX_DIRECTIONS; } for (k=0; k<dp.ndirections; k++) { advise(""); sprintf(w.w_str,"For direction #%d enter:",k); advise(w.w_str); dp.direction[k] = (float)how_much("direction"); dp.segprefix[k] = savestr(nameof( "direction segment buffer name (sans extension)")); } advise(""); dp.ngratings = how_many("number of gratings"); dp.nplanes = 2 * dp.ngratings; for(k=0;k<dp.nplanes;k++) { vectbl[k][0] = (float)(white_point[0] / sqrt(2.0)); vectbl[k][1] = (float)(white_point[1] / sqrt(2.0)); vectbl[k][2] = (float)(white_point[2] / sqrt(2.0)); } set_bit_vecs(dp.nplanes,vectbl); dp.rduration = how_many("ramp duration (time in frames)"); dp.pduration = how_many("peek duration (time in frames)"); dp.nrefresh = how_many("number of refreshes (vblanks, delays)"); if (dp.nplanes > MAX_BIT_PLANES) { sprintf(w.w_str, "nplanes set to max value of %d", MAX_BIT_PLANES); warn(w.w_str); dp.nplanes = MAX_BIT_PLANES; } for (k=0; k<dp.ngratings; k++) { advise(""); sprintf(w.w_str,"For grating #%d enter:",k); advise(w.w_str); dp.period[k] = how_many("period of grating in frames"); dp.contrast[k] = (float)how_much("amplitude contrast"); dp.start_phase[k] = (float)how_much("start phase in degs."); } make_drift_plane(&dp); for (k=0; k<dp.ndirections; k++) givbuf((char *)dp.segprefix[k]); }
static COMMAND_FUNC( mk_subsample ) { const char *obj_name; Data_Obj *dp; Dimension_Set ds1, *dsp=(&ds1); index_t offsets[N_DIMENSIONS]; long l_offset[N_DIMENSIONS]; incr_t incrs[N_DIMENSIONS]; long size[N_DIMENSIONS]; char pmpt[MAX_PMPT_LEN]; int i; obj_name=NAMEOF("name for subsample object"); dp=pick_obj(PARENT_PROMPT); /* We violate the rule of returning before getting * all arguments, because the fields of dp are needed * to determine what to prompt for! */ if( dp==NULL ) return; for(i=0;i<N_DIMENSIONS;i++){ /* BUG? should we prompt for all dimensions, instead of just those > 1 ? * If we did, then we could defer the return above... */ if( OBJ_TYPE_DIM(dp,i) > 1 ){ if( i < (N_DIMENSIONS-1) ) // BUG check length sprintf(pmpt,"number of %ss per %s",dimension_name[i], dimension_name[i+1]); else sprintf(pmpt,"number of %ss",dimension_name[i]); size[i]=(long) how_many(pmpt); sprintf(pmpt,"%s offset",dimension_name[i]); l_offset[i] = (long) how_many(pmpt); sprintf(pmpt,"%s increment",dimension_name[i]); incrs[i] =(incr_t)how_many(pmpt); // this can be negative... } else { size[i] = 1; l_offset[i]=0; incrs[i]=1; } } for(i=0;i<N_DIMENSIONS;i++){ char offset_descr[LLEN]; INSIST_POSITIVE_DIM(size[i],dimension_name[i],"mk_subsample"); sprintf(offset_descr,"%s offset",dimension_name[i]); INSIST_NONNEGATIVE(l_offset[i],offset_descr,"mk_subsample"); } for(i=0;i<N_DIMENSIONS;i++){ SET_DIMENSION(dsp,i,size[i]); offsets[i] = (index_t) l_offset[i]; } // make_subsamp checks the increments... if( make_subsamp(obj_name,dp,dsp,offsets,incrs) == NULL ) warn("error making subsamp object"); }
void _get_min_max_val(QSP_ARG_DECL int *minp,int *maxp,int *valp) { *minp=(int)how_many("min value"); *maxp=(int)how_many("max value"); *valp=(int)how_many("initial value"); }
void _get_so_width(QSP_ARG_DECL int *widthp) { *widthp=(int)how_many("width"); }
static int tiff_tilesacross(TIFF *tif) { int w = tiff_imagewidth(tif); int tw = tiff_tilewidth(tif); return how_many(w, tw); }