示例#1
0
SectionCreature::SectionCreature( QWidget * parent, const char * name )
	: Section( parent, name )
{
	_race = 0;
	_creature = 0;
	
	QVBoxLayout * layout = new QVBoxLayout( this );
	layout->setMargin( 5 );
	layout->setSpacing( 5 );

	_selectRace = new SelectionWidget( this );
	_selectRace->setTitle( tr( "Race" ) );
	layout->addWidget( _selectRace );

	_nameRace = new AskString( tr( "Name: " ), this );
	layout->addWidget( _nameRace );
	
	_selectCreature = new SelectionWidget( this );
	_selectCreature->setTitle( tr( " Creature " ) );
	layout->addWidget( _selectCreature );
	
	_editCreature = new EditCreature( this );
	layout->addWidget( _editCreature );
		
	layout->addStretch( 1 );
	
	layout->activate();
	
	connect( _selectRace, SIGNAL( sig_first() ), SLOT( slot_firstRace() ) );
	connect( _selectRace, SIGNAL( sig_previous() ), SLOT( slot_previousRace() ) );
	connect( _selectRace, SIGNAL( sig_next() ), SLOT( slot_nextRace() ) );
	connect( _selectRace, SIGNAL( sig_last() ), SLOT( slot_lastRace() ) );
	connect( _selectRace, SIGNAL( sig_new() ), SLOT( slot_newRace() ) );
	connect( _selectRace, SIGNAL( sig_del() ), SLOT( slot_delRace() ) );
	
	connect( _selectCreature, SIGNAL( sig_first() ), SLOT( slot_firstCreature() ) );
	connect( _selectCreature, SIGNAL( sig_previous() ), SLOT( slot_previousCreature() ) );
	connect( _selectCreature, SIGNAL( sig_next() ), SLOT( slot_nextCreature() ) );
	connect( _selectCreature, SIGNAL( sig_last() ), SLOT( slot_lastCreature() ) );
	connect( _selectCreature, SIGNAL( sig_new() ), SLOT( slot_newCreature() ) );
	connect( _selectCreature, SIGNAL( sig_del() ), SLOT( slot_delCreature() ) );
	
	init();
}
示例#2
0
SelectionWidget::SelectionWidget( QWidget * parent, const char * /*name*/ )
	: QFrame( parent )
{	
	QHBoxLayout * layout = new QHBoxLayout( this );
	setFrameStyle( QFrame::Box | QFrame::Raised );
	
	layout->addSpacing( 5 );
	
	QPushButton * butFirst = new QPushButton( "|<", this );
	FIXEDSIZE( butFirst );
	layout->addWidget( butFirst );
	
	QPushButton * butPrevious = new QPushButton( "<", this );
	FIXEDSIZE( butPrevious );
	layout->addWidget( butPrevious );
	layout->addSpacing( 5 );
	
	_labTitle = new QLabel( tr( "None" ), this );
	FIXEDSIZE( _labTitle );
	layout->addWidget( _labTitle );
	layout->addSpacing( 5 );
	
	QPushButton * butNext = new QPushButton( ">", this );
	FIXEDSIZE( butNext );
	layout->addWidget( butNext );

	QPushButton * butLast = new QPushButton( ">|", this );
	FIXEDSIZE( butLast );
	layout->addWidget( butLast );
	
	layout->addSpacing( 5 );
	layout->addStretch( 1 );
	
	QPushButton * butNew = new QPushButton( "New" , this );
	FIXEDSIZE( butNew );
	layout->addWidget( butNew );
	layout->addSpacing( 5 );
	
	QPushButton * butDel = new QPushButton( "Del", this );
	FIXEDSIZE( butDel );
	layout->addWidget( butDel );
	
	layout->addSpacing( 5 );
	layout->activate();
	
	setMinimumHeight( 40 );
	
	connect( butFirst, SIGNAL( clicked() ), SIGNAL( sig_first() ) );
	connect( butPrevious, SIGNAL( clicked() ), SIGNAL( sig_previous() ) );
	connect( butNext, SIGNAL( clicked() ), SIGNAL( sig_next() ) );
	connect( butLast, SIGNAL( clicked() ), SIGNAL( sig_last() ) );
	connect( butNew, SIGNAL( clicked() ), SIGNAL( sig_new() ) );
	connect( butDel, SIGNAL( clicked() ), SIGNAL( sig_del() ) );
}
示例#3
0
SectionDecoration::SectionDecoration( QWidget * parent , const char * name )
	: GenericSection( parent, name )
{
	_num = 1;
	_numItem = 0;
	
	setTitle( tr( "Decoration group" ) );

	QVBoxLayout * layout = new QVBoxLayout( _mainWidget );
	layout->setMargin( 5 );
	layout->setSpacing( 5 );

	_name = new AskString( tr( "Name: " ), _mainWidget );
	layout->addWidget( _name );

	_info = new AskString( tr( "Info: " ), _mainWidget );
	layout->addWidget( _info );
	
	_decorationEffect = new DecorationEffect( _mainWidget );
	layout->addWidget( _decorationEffect );

	_selectItem = new SelectionWidget( _mainWidget );
	_selectItem->setTitle( tr( "Decoration item" ) );
	layout->addWidget( _selectItem );
	
	_image = new AskPixmap( true, "", tr( "Image: " ), _mainWidget );
	layout->addWidget( _image );
	
	_dispo = new MapDispositionEditor( _mainWidget );
	layout->addWidget( _dispo );

	layout->addStretch( 1 );
	layout->activate();
	
	connect( _selectItem, SIGNAL( sig_first() ), SLOT( slot_firstItem() ) );
	connect( _selectItem, SIGNAL( sig_previous() ), SLOT( slot_previousItem() ) );
	connect( _selectItem, SIGNAL( sig_next() ), SLOT( slot_nextItem() ) );
	connect( _selectItem, SIGNAL( sig_last() ), SLOT( slot_lastItem() ) );
	connect( _selectItem, SIGNAL( sig_new() ), SLOT( slot_newItem() ) );
	connect( _selectItem, SIGNAL( sig_del() ), SLOT( slot_delItem() ) );
	
	init();
}
示例#4
0
GenericSection::GenericSection( QWidget * parent, const char * name )
	: Section( parent, name )
{
	QVBoxLayout * layout = new QVBoxLayout( this );
	
	_select = new SelectionWidget( this, "select" );
	layout->addWidget( _select );
	layout->addSpacing( 5 );
	
	_mainWidget = new QWidget( this );
	_mainWidget->setWindowTitle( "main widget" );
	layout->addWidget( _mainWidget, 1 );
	layout->addSpacing( 5 );
	
	layout->activate();
	
	connect( _select, SIGNAL( sig_first() ), SLOT( slot_first() ) );
	connect( _select, SIGNAL( sig_previous() ), SLOT( slot_previous() ) );
	connect( _select, SIGNAL( sig_next() ), SLOT( slot_next() ) );
	connect( _select, SIGNAL( sig_last() ), SLOT( slot_last() ) );
	connect( _select, SIGNAL( sig_new() ), SLOT( slot_new() ) ); 
	connect( _select, SIGNAL( sig_del() ), SLOT( slot_del() ) );
}
示例#5
0
int
main(int argc, char **argv)
{
  int optch = -1;
  struct sig_context *scp = NULL;
  struct xcl_context *xcp = NULL;
  const char *sigs_opt = NULL;

  f_log = stderr;
  lem_do_wrapup = 1;

  if (verbose)
    ng_debug = 1;

  scp = sig_context_init();

  while (-1 != (optch = getopt(argc, argv, "c:dino::ps:tvx:")))
    {
      switch (optch)
	{
	case 'c':
	  config_file = optarg;
	  break;
	case 'd':
	  sig_dump = 1;
	  break;
	case 'i':
	  inplace = 1;
	  break;
	case 'n':
	  new_lem = 1;
	  break;
	case 'o':
	  if (optarg)
	    {
	      if ((outfp = fopen(optarg,"wb")))
		out_file = optarg;
	      else
		{
		  fprintf(stderr, "lemmer: can't write to `%s'\n", optarg);
		  exit(1);
		}
	    }
	  else
	    outfp = stdout;
	  break;
	case 'p':
	  psu = 1;
	  break;
	case 's':
	  sigs_opt = optarg;
	  break;
	case 't':
	  textmode = 1;
	  break;
	case 'x':
	  xcl_file = optarg;
	  break;
	case 'v':
	  ++verbose;
	  break;
	case 'w':
	  lem_do_wrapup = 0;
	  break;
	default:
	  break;
	}
    }

  nl_init();
  ngramify_init();

  if (textmode)
    {
      char buf[128];
      while (NULL != fgets(buf, 128, stdin))
	{
	  if ('\n' == buf[strlen(buf)-1])
	    {
	      
	    }
	  else
	    {
	      fprintf(stderr, "lemmer: buf overflow at %s\n", buf);
	      exit(1);
	    }
	}
    }
  else if (xcl_file)
    {
      xcp = xcl_load(xcl_file, XCL_LOAD_SANS_SIGSETS);
      xcp->sigs = scp;
      scp->xcp = xcp;
      textid = xcp->textid;
      scp->xpd = xpd_init(xcp->project,xcp->pool);

      if (sigs_opt)
	sig_context_register(scp,sigs_opt,NULL,0);
      else
	sig_context_langs(scp,xcp->langs);

      if (new_lem)
	sig_new(xcp);
      else
	sig_check(xcp);

      if (psu)
	{
	  xcp->linkbase = new_linkbase();
	  xcp->linkbase->textid = textid;
	  psus2(xcp);
	}

      if (lem_do_wrapup)
	xcl_map(xcp,NULL,NULL,NULL,ilem_wrapup);

      if (outfp)
	{
	  x2_serialize(xcp,outfp,1);
	  fclose(outfp);
	}
      xcl_destroy(&xcp);
    }

  sig_context_term();
  xcl_final_term();

  return 0;
}
示例#6
0
static int
_bic_Cmd_ (ClientData clientData,
	   Tcl_Interp *interp,
	   int        argc,
	   char       **argv)      

{

  /* Command line definition */
  char * options[] = {
    "SSSs",
    "-fit","S",
    NULL
  };

  char * helpMsg = {
    (
     "  Fit the data by with a bic model (correlation functions of fractionnal brownian).\n"
     " y=s^2*pow(fabs(x+d),2.*h)+pow(fabs(x-d),2.*h)-2.*pow(fabs(x),2.*h)/2.\n"
     "\n"
     "Arguments :\n"
     "  3 signals - signal to fit, \n"
     "              signal containing the incertaity for each point, \n"
     "              signal containing the initial values (s,h,d).\n"
     "  string    - name of the result (s,h,d,chisq,goodness,covar --> size=14)\n."
     "\n"
     "Options :\n"
     "   -fit   : signal containing the x-value (REALY)\n" 
     "            --> return the bic fit in this signal (REALXY).\n"
     )
  };

  Signal *datasignal,*sigmasignal, *valsignal;
  Signal *result, *xsignal = NULL;
  char   *resultName;
  int i,j,size;
  
  real *X;
  int ma;
  int *ia;
  real *a,**covar,**alpha;
  real chisq;
  
  int u;

  if (arg_init(interp, argc, argv, options, helpMsg))
    return TCL_OK;
  
  if (arg_get(0, &datasignal, &sigmasignal, &valsignal, &resultName) == TCL_ERROR)
    return TCL_ERROR;

  if (arg_get(1, &xsignal) == TCL_ERROR)
    return TCL_ERROR;

  size = datasignal->size;
  if(sigmasignal->size != size) {
    Tcl_AppendResult (interp,
		      "The sigma signal should be of the same size as the input signal.",
		      (char *) NULL);
    return TCL_ERROR;
  }
  
  if (datasignal->type == REALY) 
    {
      X = (float *) malloc(sizeof(float)*size);
      for(i=0;i<size;i++) 
	X[i] = datasignal->x0 + i*datasignal->dx;
    }
  else if (datasignal->type == REALXY)
    {
      X = (float *) malloc(sizeof(float)*size);
      for(i=0;i<size;i++) 
	X[i] = datasignal->dataX[i]; 
    }
  else {
        Tcl_AppendResult (interp,
		      "Bad type for the signal (only REALY or REALXY).",
		      (char *) NULL);
    return TCL_ERROR;
  }

  ma = valsignal->size;
  if (ma != 3) {
    Tcl_AppendResult (interp,
		      "Bad number of initial value (we need 3 values s,h and d).",
		      (char *) NULL);
    return TCL_ERROR;
  }
  NonLinFitInit(&a,&ia,ma,&covar,&alpha);
  for(i=0;i<valsignal->size;i++)
	{
	  a[i+1]=valsignal->dataY[i];
	  ia[i+1] = 1;
	}
  NonLinFit(X-1,datasignal->dataY-1,sigmasignal->dataY-1,size,a,ia,ma,covar,alpha,
		&chisq,&BrowIncrCorr);


  result = sig_new (REALY, 0, ma+ma*ma+1);
  result->x0 = 0.0;
  result->dx = 1;
  u =0;
  for(i=1;i<=ma;i++) {
    result->dataY[u]=a[i];
    u=u+1;
  }
  result->dataY[u++]=chisq;
  result->dataY[u++]=NonLinFitConfidence(chisq,size,ma);
  for(i=1;i<=ma;i++) {
    	  for(j=1;j<=ma;j++)
	    {	      
	      result->dataY[u++]=covar[i][j];
	    }
  }


  if (!result)
    return TCL_ERROR;
  
  store_signal_in_dictionary(resultName, result);
  
  if (arg_present(1)) {
    if (xsignal->type != REALY) {
      Tcl_AppendResult (interp,
			"Type for xsignal must be REALY!!",
			(char *) NULL);
      return TCL_ERROR;
    }
    else {
      sig_realy2realxy(xsignal);
      sig_put_y_in_x(xsignal);
      for (i=0;i<xsignal->size;i++) 
	BrowIncrCorr(xsignal->dataX[i],a,&(xsignal->dataY[i]),NULL,ma);

    }


  }

  NonLinFitDelete(a,ia,ma,covar,alpha);

  return TCL_OK;

}
示例#7
0
static int
_mwc_Cmd_ (ClientData clientData,
	   Tcl_Interp *interp,
	   int        argc,
	   char       **argv)      

{

  /* Command line definition */
  char * options[] = {
    "SSSs",
    "-fit","S",
    NULL
  };

  char * helpMsg = {
    (
     "  Fit the data by with a mwc model (model for tensio-actif membrane).\n"
     "  (y=f0*prefactor*(85*(h0/x-0.5 +0.1 -x^5/(h0^5*320)- 0.5 + x^2/(h0^2*8.))\n"
     " + 0.5*(h0-x/2.+h0*log(2.*h0/x)) - (h0-x/2.)/10. + (64.*h0^6 - x^6)/(3840.*h0^5)\n"
     " + (h0-x/2.)/2. - (8*h0^3-x^3)/(48*h0^2)).\n"
     "\n"
     "Arguments :\n"
     "  3 signals - signal to fit, \n"
     "              signal containing the incertaity for each point, \n"
     "              signal containing the initial values (h0,f0).\n"
     "  string    - name of the result (h0,f0,chisq,goodness,covar --> size=8)\n."
     "\n"
     "Options :\n"
     "   -fit   : signal containing the x-value (REALY)\n" 
     "            --> return the mwc fit in this signal (REALXY).\n"
     )
  };

  Signal *datasignal,*sigmasignal, *valsignal;
  Signal *result, *xsignal = NULL;
  char   *resultName;
  int i,j,size;
  
  real *X;
  int ma;
  int *ia;
  real *a,**covar,**alpha;
  real chisq;
  
  int u;

  if (arg_init(interp, argc, argv, options, helpMsg))
    return TCL_OK;
  
  if (arg_get(0, &datasignal, &sigmasignal, &valsignal, &resultName) == TCL_ERROR)
    return TCL_ERROR;

  if (arg_get(1, &xsignal) == TCL_ERROR)
    return TCL_ERROR;

  size = datasignal->size;
  if(sigmasignal->size != size) {
    Tcl_AppendResult (interp,
		      "The sigma signal should be of the same size as the input signal.",
		      (char *) NULL);
    return TCL_ERROR;
  }
  
  if (datasignal->type == REALY) 
    {
      X = (float *) malloc(sizeof(float)*size);
      for(i=0;i<size;i++) 
	X[i] = datasignal->x0 + i*datasignal->dx;
    }
  else if (datasignal->type == REALXY)
    {
      X = (float *) malloc(sizeof(float)*size);
      for(i=0;i<size;i++) 
	X[i] = datasignal->dataX[i]; 
    }
  else {
        Tcl_AppendResult (interp,
		      "Bad type for the signal (only REALY or REALXY).",
		      (char *) NULL);
    return TCL_ERROR;
  }

  ma = valsignal->size;
  if (ma != 2) {
    Tcl_AppendResult (interp,
		      "Bad number of initial value (we need 2 values h0 and f0).",
		      (char *) NULL);
    return TCL_ERROR;
  }
  NonLinFitInit(&a,&ia,ma,&covar,&alpha);
  for(i=0;i<valsignal->size;i++)
	{
	  a[i+1]=valsignal->dataY[i];
	  ia[i+1] = 1;
	}
  NonLinFit(X-1,datasignal->dataY-1,sigmasignal->dataY-1,size,a,ia,ma,covar,alpha,
		&chisq,&MWC);


  result = sig_new (REALY, 0, ma+ma*ma+1);
  result->x0 = 0.0;
  result->dx = 1;
  u =0;
  for(i=1;i<=ma;i++) {
    result->dataY[u]=a[i];
    u=u+1;
  }
  result->dataY[u++]=chisq;
  result->dataY[u++]=NonLinFitConfidence(chisq,size,ma);
  for(i=1;i<=ma;i++) {
    	  for(j=1;j<=ma;j++)
	    {	      
	      result->dataY[u++]=covar[i][j];
	    }
  }


  if (!result)
    return TCL_ERROR;
  
  store_signal_in_dictionary(resultName, result);
  
  if (arg_present(1)) {
    if (xsignal->type != REALY) {
      Tcl_AppendResult (interp,
			"Type for xsignal must be REALY!!",
			(char *) NULL);
      return TCL_ERROR;
    }
    else {
      sig_realy2realxy(xsignal);
      sig_put_y_in_x(xsignal);
      for (i=0;i<xsignal->size;i++) 
	MWC(xsignal->dataX[i],a,&(xsignal->dataY[i]),NULL,ma);

    }


  }

  NonLinFitDelete(a,ia,ma,covar,alpha);

  return TCL_OK;

}
示例#8
0
static int
_lf_Cmd_ (ClientData clientData,
	   Tcl_Interp *interp,
	   int        argc,
	   char       **argv)      
{
  /* Command line definition */
  char * options[] = {
    "Ss",
    "-x","ff",
    "-sigma","S",
    "-fit","S",
    NULL
  };

  char * helpMsg = {
    (
     "  Fit the data by a straight line (y=ax+b)."
     "\n"
     "Arguments :\n"
     "  1 signal - signal to fit.\n"
     "  string    - name of the result (a, b,siga,sigb,chi2,goodness-of-fit)\n."
     "\n"
     "Options :\n"
     "   -x     : domain to fit.\n"
     "   -sigma : signal containing the dy of each points of the signal to fit.\n"
     "   -fit   : signal containing the x-value (REALY)\n"
     "            --> return y=ax+b in this signal (REALXY).\n"
     )
  };

  /* Command's parameters */
  Signal *datasignal,*sigmasignal =  NULL, *result, *xsignal = NULL;
  char   *resultName;
  real   xMin,xMax;
  int flagWithWeight=0;
  int size,i;
  real *X, *sigmaY;
  real a,b,siga,sigb,chi2,q;
  int iMin, iMax;


  xMin=1.0;
  xMax=-1.0;

  if (arg_init(interp, argc, argv, options, helpMsg))
    return TCL_OK;
  
  if (arg_get(0, &datasignal, &resultName) == TCL_ERROR)
    return TCL_ERROR;

  if (arg_get(1, &xMin, &xMax) == TCL_ERROR)
    return TCL_ERROR;

  if (arg_get(2, &sigmasignal) == TCL_ERROR)
    return TCL_ERROR;

  if (arg_get(3, &xsignal) == TCL_ERROR)
    return TCL_ERROR;

  if ((arg_present(2) && (datasignal->size != sigmasignal ->size))) {
    Tcl_AppendResult (interp,
		      "The sigma signal should be of the same size as the input signal.",
		      (char *) NULL);
    return TCL_ERROR;
  }


  size = datasignal->size;

  if (datasignal->type == REALY) 
    {
      X = (float *) malloc(sizeof(float)*size);
      for(i=0;i<size;i++) { 
	X[i] = datasignal->x0 + i*datasignal->dx;
      }
    }
  else if (datasignal->type == REALXY)
    {
      X = (float *) malloc(sizeof(float)*size);
      for(i=0;i<size;i++) { 
	X[i] = datasignal->dataX[i];
      }
    }
  else {
        Tcl_AppendResult (interp,
		      "Bad type for the signal (only REALY or REALXY).",
		      (char *) NULL);
    return TCL_ERROR;
  }
    
  if (arg_present(2))
    {
      sigmaY = sigmasignal->dataY - 1;
      flagWithWeight = 1;
    }
  else
    {
      sigmaY = NULL;
      flagWithWeight = 0;
    }

    
  iMin =0;
  iMax = size -1;

  if (arg_present(1)) {
    if (xMin >= xMax) {
      Tcl_AppendResult (interp,
			"xmin should be smaller than xmax",
			(char *) NULL);
      return TCL_ERROR;
    }
    iMin = IsigCeil(datasignal,xMin);
    iMax = IsigFloor(datasignal,xMax);
  }

  size = iMax - iMin + 1;
  printf("imin=%d %d\n",iMin,iMax);
  
  if(size <= 1) {
    Tcl_AppendResult (interp,
		      "Can't fit on less than two points!!",
		      (char *) NULL);
    return TCL_ERROR;
  }

  fit(X-1+iMin,datasignal->dataY-1+iMin,size,
      ((sigmaY == NULL) ? sigmaY : sigmaY + iMin),
      flagWithWeight,&a,&b,&siga,&sigb,&chi2,&q);
 
  free(X);

  result = sig_new (REALY, 0, 5);
  result->x0 = 0.0;
  result->dx = 1;
  result->dataY[0]=a;
  result->dataY[1]=b;
  result->dataY[2]=siga;
  result->dataY[3]=sigb;
  result->dataY[4]=chi2;
  result->dataY[5]=q;
  if (!result)
    return TCL_ERROR;
  
  store_signal_in_dictionary(resultName, result);
  
  if (arg_present(3)) {
    if (xsignal->type != REALY) {
      Tcl_AppendResult (interp,
			"Type for xsignal must be REALY!!",
			(char *) NULL);
      return TCL_ERROR;
    }
    else {
      /*    DEMAIN REGARDER COMMENT CHANGER REALY EN REALXY
	    size=xsignal->size;
    X = (float *) malloc(sizeof(float)*size);      
    X = xsignal->dataY;
    sig_free(xsignal);
    */
    }


  }
  return TCL_OK;
}