Exemplo n.º 1
0
void 
logfileC(FL_OBJECT *obj, long val) 

{
  char *format = "Can't open file '%s!";
  char *mes;

  if (state.logfile && strlen(state.logfile) < strlen(fl_get_input(obj))) {
    free(state.logfile);
  }
  state.logfile = strdup((char *) fl_get_input(obj)); 
  trim_spaces(state.logfile);
  if (state.logfp != stdout) {
    fclose(state.logfp);
  }
  state.logfp = fopen(state.logfile, "a");
  if (state.logfp == NULL) {
    mes = (char *) myalloc(sizeof(char) * 
			   (strlen(state.logfile) + strlen(format) + 1),
			   "logfileC", "mes");
    sprintf(mes, format, state.logfile);
    fl_show_message(mes, "Output is redirected to stdout again.", "");
    fl_set_input(obj, "");
    free((void *) mes);
    state.logfp = stdout;
  }
}
Exemplo n.º 2
0
const char *
fl_show_simple_input( const char * str1,
                      const char * defstr )
{
    if ( fd_input )
    {
        fl_hide_form( fd_input->form );
        fl_free_form( fd_input->form );
        fli_safe_free( fd_input );
    }
    else
        fl_deactivate_all_forms( );

    fli_safe_free( ret_str );

    fd_input = create_input( str1, defstr );

    fl_show_form( fd_input->form, FL_PLACE_HOTSPOT, FL_TRANSIENT, "Input" );
    fl_update_display( 0 );

    while ( fl_do_only_forms( ) != fd_input->but )
        /* empty */ ;

    ret_str = fl_strdup( fl_get_input( fd_input->input ) );

    fl_hide_form( fd_input->form );
    fl_free_form( fd_input->form );
    fli_safe_free( fd_input );

    fl_activate_all_forms( );

    return ret_str;
}
Exemplo n.º 3
0
/*** callbacks and freeobj handles for form seti_fft ***/
void adjust_frequency(FL_OBJECT *ob, long data)
{
    char tbuf[50];
    char *p;
    double lo, hi;

    lo = 50.0e6;
    hi = 870.0e6;

    if (getenv ("F_LOW") != NULL)
    {
        lo = atof(getenv("F_LOW"));
        hi = atof(getenv("F_HIGH"));
    }

    strcpy (tbuf, fl_get_input(ob));
    p = strchr(tbuf, '\n');
    if (p != NULL)
    {
        *p = '\0';
    }
    if (check_float(tbuf) < 0)
    {
        fl_set_input (ob, "Format Error");
    }
    else if (atof(tbuf) < lo || atof(tbuf) > hi)
    {
        fl_set_input (ob, "Out of range");
    }
    else
    {
        set_rf_freq (atof(tbuf));
    }
}
Exemplo n.º 4
0
float
proc_min(FL_OBJECT *obj, float min, int nstar)

{
  float max, m;
  char t[80];

  max = 0.5 * (nstar + 1) * nstar;
  m = strtod(fl_get_input(obj), NULL);
  if (m < 5.0) {
    sprintf(t, "I suggest that you enter a number between %.2f and %.2f.", 
	    CONSTMIN, 0.5 * max);
    fl_show_message("Possible wrong input", 
		  "You can enter this number if you really want to\nbut the results will be rather senseless.", t);
  }
  if (m >= max) {
    sprintf(t, "I suggest that you enter a number between %.2f and %.2f.", 
	    CONSTMIN, 0.5 * max);
    fl_show_message("You will never get any match with this value",
		  "because it is too big.", t);
    m = min;
  }
  set_minconst(m, obj);
  return m;
}
Exemplo n.º 5
0
void NeoWindow::HandleOptionsObject( FL_OBJECT *obj ) { // Handle command from form on options dialog
   FD_options *box = options_box;
   if ( obj == box->ok ) {
      fl_hide_form( box->options );
      fl_free_form( box->options );
      Refresh( true );
      options_box = NULL;
   } else if ( obj == box->initial_pop )
      neo->initial_creatures = fl_get_slider_value( obj );
   else if ( obj == box->initial_plant )
      neo->num_initial_food_locs = fl_get_slider_value( obj );
   else if ( obj == box->initial_flesh )
      neo->num_initial_meat_locs = fl_get_slider_value( obj );
   else if ( obj == box->give_head_start )
      neo->bGiveHeadStart = fl_get_button( obj );
   else if ( obj == box->allow_sex )
      neo->bAllowSexual = fl_get_button( obj );
   else if ( obj == box->allow_asex )
      neo->bAllowAsexual = fl_get_button( obj );
   else if ( obj == box->terrain_size )
      neo->terrain_size = atoi( fl_get_choice_text( obj ) );
   else if ( obj == box->scale ) 
      neo->scale = fl_get_slider_value( obj );
   else if ( obj == box->prob_crossover ) 
      neo->prob_crossover = fl_get_slider_value( obj );
   else if ( obj == box->prob_mutation ) 
      neo->prob_mutation = fl_get_slider_value( obj );
   else if ( obj == box->max_pop ) 
      neo->maximum_creatures = fl_get_slider_value( obj );
   else if ( obj == box->min_pop ) 
      neo->nMinimumPopulation = fl_get_slider_value( obj );
   else if ( obj == box->age_factor ) 
      neo->age_factor = fl_get_slider_value( obj );
   else if ( obj == box->carcass_decay_rate ) 
      neo->nCarcassDecayRate = fl_get_slider_value( obj );
   else if ( obj == box->waste_decay_rate ) 
      neo->nWasteDecayRate = fl_get_slider_value( obj );
   else if ( obj == box->poison_decay_rate ) 
      neo->nPoisonDecayRate = fl_get_slider_value( obj );
   else if ( obj == box->give_head_start ) 
      neo->bGiveHeadStart = fl_get_button( obj );
   else if ( obj == box->allow_sex ) 
      neo->bAllowSexual = fl_get_button( obj );
   else if ( obj == box->allow_asex ) 
      neo->bAllowAsexual = fl_get_button( obj );
   else if ( obj == box->maintain_min_pop ) 
      neo->bKeepMinimumPopulation = fl_get_button( obj );
   else if ( obj == box->use_survivor ) 
      neo->bUseSurvivorForMinimum = fl_get_button( obj );
   else if ( obj == box->save_sim ) 
      if ( fl_get_button( obj ) )
	 neo->saveEveryNsteps = fl_get_slider_value( box->save_every );
      else 
	 neo->saveEveryNsteps = -1;
   else if ( obj == box->file_name )
      strcpy( neo->fileName, fl_get_input( obj ) );
}
Exemplo n.º 6
0
void
counter_reread_spec_form( FL_OBJECT * obj )
{
    double r1, r2;

    if (    get_checked_float( fl_get_input( cnt_attrib->minval ), &r1 )
         && get_checked_float( fl_get_input( cnt_attrib->maxval ), &r2 ) )
        fl_set_counter_bounds( obj, r1, r2 );

    if ( get_checked_float( fl_get_input( cnt_attrib->initialval ), &r1 ) )
         fl_set_counter_value( obj, r1 );

    if (    get_checked_float( fl_get_input( cnt_attrib->step1 ), &r1 )
         && get_checked_float( fl_get_input( cnt_attrib->step2 ), &r2 ) )
        fl_set_counter_step( obj, r1, r2 );

    redraw_the_form( 0 );
}
Exemplo n.º 7
0
void
set_rxb_cor (FL_OBJECT *ob, long data)
{
	const char *p;
	
	p = fl_get_input (ob);
	if (p != NULL && *p != '\0')
	{
		sscanf (p, "%lf", &rxb_cor);
	}
}
Exemplo n.º 8
0
void
dial_reread_spec_form( FL_OBJECT * obj )
{
    double r1, r2;
    int dir = fl_get_choice( dial_attrib->dir ) - 1;

    if (    get_checked_float( fl_get_input( dial_attrib->minval ), &r1 )
         && get_checked_float( fl_get_input( dial_attrib->maxval ), &r2 ) )
         fl_set_dial_bounds( obj, r1, r2 );

    if ( get_checked_float( fl_get_input( dial_attrib->initialval ), &r1 ) )
        fl_set_dial_value( obj, r1 );

    if (    get_checked_float( fl_get_input( dial_attrib->thetai ), &r1 )
         && get_checked_float( fl_get_input( dial_attrib->thetaf ), &r2 ) )
        fl_set_dial_angles( obj, r1, r2 );

    if ( get_checked_float( fl_get_input( dial_attrib->step ), &r1 ) )
        fl_set_dial_step( obj, r1 );

    if ( dir >= 0 )
        fl_set_dial_direction( obj, dial_dir[ dir ].val );

    redraw_the_form( 0 );
}
Exemplo n.º 9
0
int
proc_gridsize(FL_OBJECT *obj, int gridsize)

{
  int gsize;

  gsize = strtol(fl_get_input(obj), NULL, 10);
  if (gsize > 100 || gsize < 10) {
    fl_show_message("Please set this value somewhere",
		  "between 10 and 100.", "");
  }
  set_gridsize(gsize, obj);
  return gsize;
}
Exemplo n.º 10
0
int
proc_firstbright(FL_OBJECT *obj, int firstbright)

{
  int fb;
  fb = strtol(fl_get_input(obj), NULL, 10);
  if (fb < 10 || fb > 100) {
    fl_show_message("You can enter this number if you really want to",
		  "but the results will be rather senseless.",
		  "Please use numbers between 10 and 100");
  }
  set_initconst(fb, obj);
  return fb;
}
Exemplo n.º 11
0
float
proc_maxres(FL_OBJECT *obj, float maxres)

{
  float mr;
  mr = strtod(fl_get_input(obj), NULL);
  if (mr < 0.5 || mr > 3) {
    fl_show_message("You can enter this number if you really want to",
		  "but the results will be rather senseless.",
		  "Please use numbers between 0.5 and 3");
  }
  set_maxres(mr, obj);
  return mr;
}
Exemplo n.º 12
0
float
proc_maxmag(FL_OBJECT *obj, float maxmag, float minmag)

{
  float max;
  max = strtod(fl_get_input(obj), NULL);
  if (minmag >= max) {
    fl_show_message("The lowest magnitude should have lower",
		  "value than the highest magnitude.",
		  "Correct this, please!");
    max = maxmag;
  }
  set_starmaxmag(max, obj);
  return max;
}
Exemplo n.º 13
0
int
proc_nstar(FL_OBJECT *obj, int nstar)

{
  int ns;

  ns = strtol(fl_get_input(obj), NULL, 10);
  if (ns < 6 || ns > 15) {
    fl_show_message("You can enter this number if you really want to",
		  "but the results will be rather senseless.",
		  "Please use numbers between 6 and 15");
  }
  set_starconst(ns, obj);
  return ns;
}
Exemplo n.º 14
0
int
proc_minstar(FL_OBJECT *obj, int minstar)

{
  int mins;

  mins = strtol(fl_get_input(obj), NULL, 10);
  if (mins > 2 || mins < 1) {
    fl_show_message("You can experiment if you really want to,",
		  "but the suggested values are 1 and 2",
		  "");
  }
  set_starminsize(mins, obj);
  return mins;
}
Exemplo n.º 15
0
float
proc_poserrmax(FL_OBJECT *obj, float poserrmax)

{
  float pos;

  pos = strtod(fl_get_input(obj), NULL);
  if (pos < 1 || pos > 10) {
    fl_show_message("You can enter this number if you really want to",
		  "but the results will be rather senseless.",
		  "Please use numbers between 1 and 10");
  }
  set_starerror(pos, obj);
  return pos;
}
Exemplo n.º 16
0
float
proc_sg_num(FL_OBJECT *obj, float sg_num)

{
  float sg;

  sg = strtod(fl_get_input(obj), NULL);
  if (sg <= 0) {
    fl_show_message("Please type in a positive number!",
		  "Typical good values are between 2 and 5.",
		  "");
    sg = sg_num;
  }
  set_countsigma(sg, obj);
  return sg;
}
Exemplo n.º 17
0
float
proc_inner(FL_OBJECT *obj, float inner, float outer)

{
  float inn;
  char a[40];

  inn = strtod(fl_get_input(obj), NULL);
  if (inn < 0.1 || inn >= outer) {
    sprintf(a, "between 0.1 and %.1f", outer);
    fl_show_message("Size of the inner circle radius should be", a, "");
    inn = inner;
  }
  set_inner(inn, obj);
  return inn;
}
Exemplo n.º 18
0
float
proc_outer(FL_OBJECT *obj, float outer, float inner)

{
  float out;
  char a[40];

  out = strtod(fl_get_input(obj), NULL);
  if (out > 20.0 || out <= inner) {
    sprintf(a, "between %.1f and 50.0", inner);
    fl_show_message("Size of the outer circle radius should be", a, "");
    out = outer;
  }
  set_outer(out, obj);
  return out;
}
Exemplo n.º 19
0
int
proc_border(FL_OBJECT *obj, int border)

{
  int b;
  int n = state.control[state.control_num];

  b = strtol(fl_get_input(obj), NULL, 10);
  if (b > frame[n].fits.width / 2 || 
      b > frame[n].fits.height / 2) {
    fl_show_message("With this value you will get",
		  "0 detections.",
		  "");
    b = border;
  }
  set_edgesize(b, obj);
  return b;
}
Exemplo n.º 20
0
void adjust_ra(FL_OBJECT *ob, long data)
{
    char tbuf[50];
    char *p;

    strcpy (tbuf, fl_get_input(ob));
    p = strchr(tbuf, '\n');
    if (p != NULL)
    {
        *p = '\0';
    }
    if (check_float (tbuf) < 0)
    {
        fl_set_input (ob, "Format Error");
    }
    else
    {
        ra = atof(tbuf);
    }
}
Exemplo n.º 21
0
int
proc_minbright(FL_OBJECT *obj, int minbright)

{
  int minb;

  minb = strtol(fl_get_input(obj), NULL, 10);
  if (minb > 200) {
    fl_show_message("Just to let you know that using high",
		  "values of this parameter you may lose",
		  "a lot of good stars.");
  }
  if (minb < 50 ) {
    fl_show_message("You may get a lot of false detections",
		  "if you use this value.",
		  "");
  }
  set_countminval(minb, obj);
  return minb;
}
Exemplo n.º 22
0
void
adjust_sky_frequency (FL_OBJECT *ob, long data)
{
    char *p;
    char tbuf[128];

    p = (char *)fl_get_input (ob);
    strcpy (tbuf, p);
    if ((p = strchr (tbuf, '\n')) != NULL)
    {
        *p = '\0';
    }
    if (strcmp (tbuf, "lock") == 0 ||
            strcmp (tbuf, "locked") == 0 ||
            strcmp (tbuf, "tuner") == 0 ||
            strncmp (tbuf, "----", 4) == 0)
    {
        char d[128];
        sky_locked = 1;
        sky_freq = frequency;
        sprintf (d, "%f", sky_freq);
        fl_set_input (ob, d);
        fl_set_button (fd_receiver_main->sky_lock_button, 1);
    }
    else
    {
        if (check_float (tbuf) < 0)
        {
            fl_set_input (ob, "Format Error");
        }
        else
        {
            sky_freq = atof(tbuf);
            sky_locked = 0;
        }
        write_rcvr_params ("skyfreq", sky_freq);
    }
}
Exemplo n.º 23
0
void adjust_pulsar_rate(FL_OBJECT *ob, long data)
{
    char tbuf[50];
    char *p;
    double real_rate;
    int int_rate;
    double err;
    char str[64];

    strcpy (tbuf, fl_get_input(ob));
    p = strchr(tbuf, '\n');
    if (p != NULL)
    {
        *p = '\0';
    }
    if ((p = strchr(tbuf, '\r')) != NULL)
    {
        *p = '\0';
    }
    if (check_float (tbuf) < 0)
    {
        fl_set_input (ob, "Format Error");
    }
    else
    {
        pulsar_rate = (double)atof(tbuf);

        real_rate = (1.0/pulsar_rate)*(double)psr_rate;
        int_rate = (int)(real_rate);
        err = fabsf(real_rate - int_rate);
        err = err / real_rate;
        sprintf (str, "%8.2f", err*1.0e6);
        fl_set_object_label (fd_receiver_main->phase_display, str);
    }

}
Exemplo n.º 24
0
RNG *CreateRNG() {
  FL_OBJECT *ap = the_gui->AEntry;
  FL_OBJECT *bp = the_gui->BEntry;
  FL_OBJECT *cp = the_gui->DistributionChoice;
  char buf[80];
  char *cdffn;
  double a;
  double b;
  int i;
  RNG *r;

  switch (fl_get_choice(cp)) {
  case Uniform:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new UniformRNG(a,b);
    break;
  case Binomial:
    a = atof(fl_get_input(ap));
    i = atoi(fl_get_input(bp));
    r = new BinomialRNG(a,i);
    break;
  case CDF:
    CDFRNG *cdfr;
    cdffn = (char *)fl_show_input("PDF File Name","wdist.dat");
    if (cdffn == NULL)
      return NULL;
    cdfr = new CDFRNG(cdffn);
    if (cdfr->bad()) {
      fl_show_message("Can't open PDF file",cdffn,"");
      return NULL;
    }
    sprintf(buf,"%f",cdfr->min());
    fl_set_input(ap,buf);
    sprintf(buf,"%f",cdfr->max());
    fl_set_input(bp,buf);
    r = cdfr;
    break;
  case Exponential:	
    r = new ExponentialRNG();
    break;
  case Gamma:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new GammaRNG(a,b);
    break;
  case LogNormal:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new LogNormalRNG(a,b);
    break;
  case LogNormalLog:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new LogNormalLogRNG(a,b);
    break;
  case Normal:
    a = atof(fl_get_input(ap));
    b = atof(fl_get_input(bp));
    r = new NormalRNG(a,b);
    break;
  case Poisson:
    a = atof(fl_get_input(ap));
    r = new PoissonRNG(a);
    break;
  }
  return r;
}
Exemplo n.º 25
0
void PlotButtonCB(FL_OBJECT *p0, long p1) {
  FL_OBJECT *np = the_gui->NEntry;
  FL_OBJECT *sp = the_gui->ProgressSlider;
  FL_OBJECT *cp = the_gui->DistributionChoice;
  FL_OBJECT *xyp = the_gui->xyplot;
  RNG *rng = CreateRNG();
  int n = atoi(fl_get_input(np));
  double r;
  int i, j;
  int distrib[NB];
  float xv[NB];
  float yv[NB];
  int di;
  float dx;
  unsigned long xl;
  double sum, sumsq;
  static char *mstring = new char[80];
  static char *sdstring = new char[80];
  int ymax;
  double xmin, xmax;

  if (rng == NULL)
    return;

  for (i=0; i<NB; i++)
    distrib[i] = 0;
  sum = sumsq = 0.0;
  ymax = 0;
  
  if (n >= PROGRESS_THRESHOLD) {
    di = n/100;			// update slider every 'di' points
    fl_set_slider_value(sp,0.0);
    fl_show_object(sp);
  }
  else
    di = 0;			// n too small; don't draw slider

  xmin = atof(fl_get_input(the_gui->MinEntry));
  xmax = atof(fl_get_input(the_gui->MaxEntry));

  for (i=0; i<n; i++) {
    r = ++(*rng);		// get a sample from current distribution
    sum += r;
    sumsq += r*r;

    j = fl_get_choice(cp);
    if ((j == Binomial) || (j == Poisson))
      r *= 10.0;		// spread out integer values so we can see them
    
    if (j == CDF)		// 'dx' is a value added to each sample
      dx = 0.0005;		// the CDF demo RNG returns values that are exactly
    else			// on the divide between two bins, and roundoff
      dx = 0.0;			// errors lead to funny looking plots....

    j = floor((r+dx-xmin)*NB/(xmax-xmin));
    
    if ((j >= 0) && (j < NB)) {
      distrib[j] += 1;
      if (distrib[j] > ymax)
	ymax = distrib[j];
    }
    if (di && ((i%di)==0))
      fl_set_slider_value(sp,(double)i/(double)n);
  }

  fl_hide_object(sp);		// all done; put away the slider

  // Bins filled; transfer to x and y vectors and plot.  The xyplot
  // widget will scale x and y automatically.

  fl_delete_xyplot_text(xyp,mstring);
  fl_delete_xyplot_text(xyp,sdstring);

  for (i=0; i<NB; i++) {
    xv[i] = (float)i*(xmax-xmin)/NB + xmin;
    yv[i] = (float)distrib[i];
  }

  if (xmin == xmax)
    fl_set_xyplot_xbounds(xyp,xmin+1.0,xmax); 	// auto-scale if min>max
  else
    fl_set_xyplot_xbounds(xyp,xmin,xmax);
  fl_set_xyplot_data(xyp, xv, yv, NB, "", "", "");

  // compute, display sample mean and sample standard deviation

  double dn = double(n);
  double mean = sum/dn;
  double sd = sqrt(dn*((sumsq/dn)-mean*mean)/(dn-1));

  sprintf(mstring,"Sample Mean =  %f",mean);
  sprintf(sdstring,"Standard Dev = %f",sd);

  // The (x,y) coords of the string are defined in terms of scaled plot
  // units.  If the right edge of the x scale is at 100, put the text
  // at 80.  Put the top string near the top of the plot, and the bottom
  // string 10% lower.

  double y1 = double(ymax) - .05*(double(ymax));
  double y2 = double(ymax) - .10*(double(ymax));

  fl_add_xyplot_text(xyp,(xmax-xmin)*0.8+xmin,y1,mstring,FL_ALIGN_CENTER,FL_BLACK);
  fl_add_xyplot_text(xyp,(xmax-xmin)*0.8+xmin,y2,sdstring,FL_ALIGN_CENTER,FL_BLACK);
  
  delete rng;			// some RNGs allocate internal tables....
}
Exemplo n.º 26
0
void uiGetTargetname(char *name) {
  strcpy(name, fl_get_input(TargetInput));
}
Exemplo n.º 27
0
static void CB_nbretract_input(FL_OBJECT *ob, long arg){
  p3d_set_nretract_max(atof(fl_get_input(NBRETRACT_INPUT)) == 0?p3d_get_nretract_max():atof(fl_get_input(NBRETRACT_INPUT)));
}
Exemplo n.º 28
0
void
set_longitude (FL_OBJECT  *ob, long data)
{
	longitude = atof (fl_get_input (ob));
}
Exemplo n.º 29
0
static void CB_plot_all_input(FL_OBJECT *ob, long arg){
  p3d_set_Nstep(atoi(fl_get_input(PLOT_ALL_INPUT)));
}
Exemplo n.º 30
0
void
input_license_key (FL_OBJECT *ob, long data)
{
	strcpy (license_key, fl_get_input (ob));
}