Example #1
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolMove::track_obj(){
	if(get_use_sel()){
bGenericGeoElement* o=get_obj();
		bStdToolGeom::track_obj();
		if(_srep){
			if(o!=get_obj()){
				FlushSelection(_gapp);
			}
			if((get_obj())&&(o!=get_obj())){
				get_obj()->setselect(true,true);
			}
		}
	}
}
// ---------------------------------------------------------------------------
// 
// -----------
void bToolJustification::put_value(int fidx, double val){
bGenericGeoElement*	o=get_obj();
	if(o==NULL){
		return;
	}
	o->setValue(fidx,val);
}
Example #3
0
/*
 * Disarm a creature.
 * Caller must check for successful attack.
 */
void disarm( CHAR_DATA *ch, CHAR_DATA *victim )
{
    OBJ_DATA *obj;

    if ( ( obj = get_eq_char( victim, WEAR_WIELD ) ) == NULL )
	return;

    if ( IS_OBJ_STAT(obj,ITEM_NOREMOVE))
    {
	act("$S weapon won't budge!",ch,NULL,victim,TO_CHAR, 1);
	act("$n tries to disarm you, but your weapon won't budge!",
	    ch,NULL,victim,TO_VICT, 0);
	act("$n tries to disarm $N, but fails.",ch,NULL,victim,TO_NOTVICT, 0);
	return;
    }

    act( "$n DISARMS you and sends your weapon flying!",
	 ch, NULL, victim, TO_VICT, 1 );
    act( "You disarm $N!",  ch, NULL, victim, TO_CHAR, 1 );
    act( "$n disarms $N!",  ch, NULL, victim, TO_NOTVICT, 0 );

    obj_from_char( obj );
    if ( IS_OBJ_STAT(obj,ITEM_NODROP) || IS_OBJ_STAT(obj,ITEM_INVENTORY) )
	obj_to_char( obj, victim );
    else
    {
	obj_to_room( obj, victim->in_room );
	if (IS_NPC(victim) && victim->wait == 0 && can_see_obj(victim,obj))
	    get_obj(victim,obj,NULL);
    }

    return;
}
Example #4
0
static char *test_stack_error() {
    Object *obj1 = get_obj(interpreter);
    mu_assert(obj1 == NULL, "Should be nothing on the stack");
    mu_assert(interpreter->error == 1, "Interpreter should have errored");
    interpreter_clear_error(interpreter);

    return 0;
}
// ---------------------------------------------------------------------------
// 
// -----------
void bToolGeomShift::drag(CGPoint pt){
	bStdToolGeom::drag(pt);
	if(!get_obj()||!_vxs){
		return;
	}
	get_dist_to_path();
	report();
}
// tail call
void get_obj(int totval[N+1][Y+1], int index1, int index2, int w[N])
{
  if(index1 < 0)
    {
      printf("end.\n");
      exit(0);
    }
  if(totval[index1][index2] < totval[index1 +1][index2])
    {
      printf("%d\n", index1+1);
      get_obj(totval, index1 -1, index2-w[index1+1], w);
    }
  else
    {
      get_obj(totval, index1 -1, index2, w);
    }
}
// ---------------------------------------------------------------------------
// 
// -----------
void bToolGeomShift::track_obj(){
bArray*				ga;
bGenericStyle*		style;
bGenericGeoElement	*o=NULL,*prev;
bGenericType*		tp;
long				i,n=CountLayers(_gapp);
CGPoint				pt;
	
	get_cur(&pt);
	prev=get_obj();
	for(i=n;i>0;i--){
		style=(bGenericStyle*)GetIndLayer(_gapp,i);
		if(!style){
			continue;
		}
		tp=style->gettype();
		if(tp==NULL){
			continue;
		}
		if(	(tp->kind()!=kBaseKindPolyline)	&&
			(tp->kind()!=kBaseKindPolygon)	&&
			(tp->kind()!=kBaseKindRaster)	){
			continue;
		}
		ga=style->objsatpoint(&pt,false);
		if(!ga){
			continue;
		}
		if(ga->count()>0){
			ga->get(1,&o);
			delete ga;
			if(o!=prev){
				FlushSelection(_gapp);
				set_obj(o);
				get_obj()->setselect(true,true);
			}
			break;
		}
		
		delete ga;
	}
	if(o==NULL){
		FlushSelection(_gapp);
		set_obj(NULL);
	}
}
	shared_ptr<Obstacle> Obstacle::fromJson(mValue data)
	{
		auto height = data.get_obj().at("height").get_int();
		auto width = data.get_obj().at("width").get_int();
		auto location = data.get_obj().at("location");
		auto x = location.get_obj().at("x").get_int();
		auto y = location.get_obj().at("y").get_int();
		return make_shared<Obstacle>(x, y, width, height);
	}
Example #9
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolMove::clic(CGPoint pt, int count){
	bStdToolGeom::clic(pt,count);
bGenericGeoElement* o=get_obj();
	if(!o){
		return;
	}
	set_use_sel(false);
	set_use_drag(true);
}
Example #10
0
static COMMAND_FUNC( do_tellprec )
{
	Data_Obj *dp;
	const char *s;

	dp = get_obj( QSP_ARG NAMEOF("data object") );
	s = NAMEOF("variable name");
	if( dp == NULL ) return;
	assign_var(s,OBJ_PREC_NAME(dp));
}
Example #11
0
t_objs		*get_data(char *str, t_objs *obj, t_env *e)
{
	if (!(get_camera(str, obj)))
		ft_error("Camera description not found. Please add one", 2);
	if (!(obj = get_obj(str, obj)))
		ft_error("No object description found. Please add one", 2);
	get_light(str, e);
	free(str);
	return (obj);
}
Example #12
0
static Data_Obj *dobj_for_frame(QSP_ARG_DECL  dc1394video_frame_t *framep)
{
	Data_Obj *dp;
	char fname[32];

	// For speed, we could keep a table of the dobj's associated with the camera.  BUG
	sprintf(fname,"_frame%d",framep->id);
	dp = get_obj(fname);
	return dp;
}
Example #13
0
struct o32_obj *
get_code(struct LX_module * lx_mod) {
        if(lx_mod->lx_head_e32_exe->e32_startobj == 0) {
                if (options.debugixfmgr) 
                {
                  io_log("Invalid start object for code ==0\n");
                }
                return (struct o32_obj *)0;
        }
        return get_obj(lx_mod, lx_mod->lx_head_e32_exe->e32_startobj);
}
// ---------------------------------------------------------------------------
// 
// -----------
void bToolGeomShift::end_clic(){
	bStdToolGeom::end_clic();
	set_use_drag(false);
	set_use_sel(true);

bGenericGeoElement*	o=get_obj();
	if(!o){
		return;
	}
	if(!_vxs){
		return;
	}

	if(_d==0){
		ivs_free(_vxs);
		return;
	}
ivertices*  out=get_output();
    if(!out){
        ivs_free(_vxs);
        _vxs=NULL;
        _d=0;
        return;
    }
bEventLog	log(_gapp,
				getbundle(),
				kGeomShiftMessageID,
				GetSignature(this));
//    ivs_shift(&out,_d);
//    if(is_modifiers(optionKey)){
//        if(ivs_n_parts(out)==ivs_n_parts(_vxs)){
//i2dvertex   *pout,*pvxs;
//int         nout,nvxs;
//            for(long i=0;i<ivs_n_parts(out);i++){
//                pout=ivs2_part(out,i,&nout);
//                pvxs=ivs2_part(_vxs,i,&nvxs);
//                pout[0]=pvxs[0];
//                pout[nout-1]=pvxs[nvxs-1];
//            }
//        }
//        else{
//            out->vx.vx2[0]=_vxs->vx.vx2[0];
//            out->vx.vx2[out->nv-1]=_vxs->vx.vx2[_vxs->nv-1];
//        }
//    }
	o->setVertices(out);
	log.close();
	
	set_obj(NULL);
    ivs_free(out);
    ivs_free(_vxs);
	_vxs=NULL;
	_d=0;
}
Example #15
0
int	select_obj(t_data *data)
{
  if (check_workspace(data->itfc.mpos, &data->rt)
      && data->click_action && data->rt.select == true)
    {
      data->itfc.obj_selected =
      	get_obj(&data->rt,
      		data->itfc.mpos->x - data->rt.pos.x,
		data->itfc.mpos->y - data->rt.pos.y);
    }
  data->click_action = false;
  return (0);
}
// ---------------------------------------------------------------------------
// 
// -----------
void bToolGeomShift::clic(CGPoint pt, int count){
	bStdToolGeom::clic(pt,count);
bGenericGeoElement* o=get_obj();
	if(!o){
		return;
	}
	_d=0;
	o->getVertices(&_vxs);
	if(ivs2ivs(_vxs,&_vxs)){
		return;
	}
	set_use_sel(false);
	set_use_drag(true);
}
Example #17
0
struct o32_obj *
get_data_stack(struct LX_module * lx_mod) {
        if((lx_mod->lx_head_e32_exe->e32_stackobj == 0) ||
                (lx_mod->lx_head_e32_exe->e32_stackobj > get_obj_num(lx_mod))) {
                if (options.debugixfmgr) 
                {
                  io_log("Invalid data/stack object ==%lu, max=%lu\n",
                                  lx_mod->lx_head_e32_exe->e32_stackobj,
                                  get_obj_num(lx_mod));
                }
                return (struct o32_obj *)0;
        }
        return get_obj(lx_mod, lx_mod->lx_head_e32_exe->e32_stackobj);
}
Example #18
0
Data_Obj * grab_firewire_frame(QSP_ARG_DECL  PGR_Cam * pgcp )
{
	dc1394video_frame_t *framep;
	//dc1394capture_policy_t policy=DC1394_CAPTURE_POLICY_WAIT;
	Data_Obj *dp;
	char fname[TMPSIZE];

	// Before attempting to dequeue, make sure that we have at least one
	// available...  The library seems to hang if we keep
	// grabbing without releasing.

	if( ! ready_to_grab(QSP_ARG  pgcp) )
		return NULL;

	/* POLICY_WAIT waits for the next frame...
	 * POLICY_POLL returns right away if there is no frame available.
	 */
	if ( dc1394_capture_dequeue( pgcp->pc_cam_p, 
		pgcp->pc_policy, &framep ) != DC1394_SUCCESS) {
		fprintf( stderr, "Unable to capture a frame\n" );
		return(NULL);
	}
	if( framep == NULL ){
		if( pgcp->pc_policy != DC1394_CAPTURE_POLICY_POLL )
			WARN("dc1394_capture_dequeue returned a null frame.");
		return NULL;
	}

	pgcp->pc_n_avail--;

	//sprintf(fname,"_frame%d",framep->id);
	snprintf(fname,TMPSIZE,"_frame%d",framep->id);
	dp = get_obj(fname);
	if( dp == NULL ){
		warn("grab_firewire_frame:  unable to create frame object");
		return(NULL);
	}

	assert( OBJ_DATA_PTR(dp) == framep->image );

	/* in the other case, the pointer is likely to be unchanged,
	 * but we don't assume...
	 * We *do* assume that the old size is still ok.
	 */

	note_frame_usage(pgcp,framep);
	return(dp);
} // end grab_firewire_frame
Example #19
0
/**
 * qlist->removeat(): Removes the element at the specified position in
 * this list.
 *
 * @param list   qlist_t container pointer.
 * @param index  index at which the specified element is to be removed.
 *
 * @return a number of removed objects.
 * @retval errno will be set in error condition.
 *  -ERANGE : Index out of range.
 */
bool qlist_removeat(qlist_t *list, int index) {
    qlist_lock(list);

    // get object pointer
    qlist_obj_t *obj = get_obj(list, index);
    if (obj == NULL) {
        qlist_unlock(list);
        return false;
    }

    bool ret = remove_obj(list, obj);

    qlist_unlock(list);

    return ret;
}
// ---------------------------------------------------------------------------
// 
// -----------
void bToolJustification::update(bool global){
	if(!global){
		clearTempPathContext(false);
	}
bGenericGeoElement*	o=get_obj();
	if(o){
		clearTempPathContext(true);
		_gapp->layersMgr()->SwitchContext(kCtxGraphicContext,getTempPathContext());
		_styl->draw(o);
		_gapp->layersMgr()->SwitchContext(kCGGraphicContext,NULL);
		validTempPathContext();
	}
	if(!global){
		validTempPathContext();
	}
}
Example #21
0
void ribo_model::update_profile(const ribo_profile& rprofile, bool ignore_no_map, int nproc)
{
  omp_set_num_threads(nproc);
  #pragma omp parallel for schedule(static)
  for (size_t t=0; t<rprofile.number_of_transcripts(); ++t) {
    if (ignore_no_map and rprofile.get_tot_count(t) == 0) continue;
    tmodel& m = get_model_ref(t);
    if (get_obj(t)<0) continue;
    vector<double> rate_vec(build_rate_vec(t));
    double trate = compute_profile(rate_vec, m.profile);
    if (trate>0)
      set_trate(t, trate);
    else
      compute_translation_rate(t, rate_vec);
    compute_transcript_abundance(t, rprofile.get_read_assignments(t));
  }
}
int main(void)
{
  int w[N+1] = {0,12, 16, 24, 7, 29, 32, 5, 43, 31, 1}, v[N+1] = {0,11,16,15,9,24,25,3,32,41,7};
  int m;  // 背包的重量
  int totval[N+1][Y+1] = {0}; // 在前N种物品中选择所能达到的最高价值
  int i, j, k;
  for (i = 0; i < N+1; i++)
    {
      totval[i][0] = 0;
    }
  for (i = 0; i < Y+1; i++)
    {
      totval[0][i] = 0;
    }
  for (i = 1; i < N + 1; i++)
    {
      m = Y;
      while(m >= 0)
	{
	  if (i == 1)
	    printf("test\n");
	  if ((m >= w[i])&&(totval[i-1][m] > v[i] + totval[i-1][m-w[i]]) || m < w[i])
	    {
	      totval[i][m] = totval[i-1][m];
	    }
	  else 
	    {
	      totval[i][m] = v[i] + totval[i-1][m - w[i]];
	    }
	  m--;
	}
    }
  // 输出所有的total value
  printf("  N----  Y-----  Total value\n");
  for (i = 0; i < N+1; i++)
    for(j = 0; j < Y+1; j++)
      {
	if (totval[i][j] > 0)
	  printf("%3d----%3d-----%3d\n", i, j, totval[i][j]);
      } 
  // 输出最高价值和选择的物品
  printf("the total value of the knapsack is %d\n", totval[N][Y]);
  get_obj(totval, N-1, Y, w);
}
Example #23
0
int		init_scene(t_data *data, char *config_name)
{
  FILE		*fd;

  data->list = NULL;
  data->spot = NULL;
  data->option.first_aa = FIRST_ANTI_ALIASING;
  data->option.final_aa = ANTI_ALIASING;
  if ((fd = fopen(config_name, "r")) == NULL)
    return (error("Sorry, can't open the config\n"));
  if (get_eyes(&(data->scene.eyes), fd) == FAIL)
    return (error("Sorry, can't init eyes\n"));
  if (get_obj(fd, data) == FAIL)
    return (error("Sorry, can't init obj_list\n"));
  fclose(fd);
  if (check_list(data) == FAIL)
    return (FAIL);
  return (SUCCES);
}
Example #24
0
int		main(int ac, char **av)
{
  t_lum		*tab_lum;
  t_pos		test;
  t_win		mlxwin;

  ac != 4 ? exit (1) : 0;
  (mlxwin.mlx = mlx_init()) == NULL ? exit (1) : 0;
  (mlxwin.win = mlx_new_window(mlxwin.mlx, 1000, 1000, "RTV1")) == NULL ?\
    exit (1) : 0;
  (mlxwin.img = mlx_new_image(mlxwin.mlx, 1000, 1000)) == NULL ? exit (1) : 0;
  get_eye(&mlxwin, av[1]);
  mlxwin.tab_obj = get_obj(av[2]);
  mlxwin.tab_lum = get_lum(av[3]);
  remplis_image(&mlxwin);
  mlx_key_hook(mlxwin.win, gere_key, &mlxwin);
  mlx_expose_hook(mlxwin.win, gere_expose, &mlxwin);
  mlx_loop(mlxwin.mlx);
  return (0);
}
Example #25
0
static void *get_at(qlist_t *list, int index, size_t *size, bool newmem,
bool remove) {
    qlist_lock(list);

    // get object pointer
    qlist_obj_t *obj = get_obj(list, index);
    if (obj == NULL) {
        qlist_unlock(list);
        return false;
    }

    // copy data
    void *data;
    if (newmem == true) {
        data = malloc(obj->size);
        if (data == NULL) {
            qlist_unlock(list);
            errno = ENOMEM;
            return false;
        }
        memcpy(data, obj->data, obj->size);
    } else {
        data = obj->data;
    }
    if (size != NULL)
        *size = obj->size;

    // remove if necessary
    if (remove == true) {
        if (remove_obj(list, obj) == false) {
            if (newmem == true)
                free(data);
            data = NULL;
        }
    }

    qlist_unlock(list);

    return data;
}
Example #26
0
File: init.c Project: NegMozzie/42
void			ft_init(t_env *env, char *file)
{
	t_lex		*lex;
	t_lex		*tmp;
	//t_scene		*s = NULL;
	//t_light		*l = NULL;

	lex = get_file(file);
	tmp = lex;
	env->scene = NULL;
	env->light = NULL;
	env->back_color = COLOR_BLUE;
	while (lex)
	{
		if (!ft_strcmp(lex->str, "<GEN>"))
			lex = get_gen(env, lex->next);
		else if (!ft_strcmp(lex->str, "<OBJ>"))
			lex = get_obj(env, lex->next);
		else
		{
			ft_putendl(lex->str);
			init_exit();
		}
		if (lex == tmp)
			break ;
	}
	/*l = env->light;
	while (l)
	{
		sleep(1);
		s = new_scene();
		s->type = SPHERE;
		s->pos = l->pos;
		s->color = new(1, 1, 1);
		s->size = 5;
		s->next = env->scene;
		env->scene = s;
		l = l->next;
	}*/
}
Example #27
0
		void callback() {
			set_processing(true);
			set_result(tTJSVariant());
			{
				tTJSVariant result;
				tTJSVariant param[] = {
					tTJSVariant(control_.get(), control_.get())
				};
				tTJSVariant* p_param[] = {
					param + 0
				};
				sprig::krkr::tjs::FuncObjectCall(
					get_obj().get(),
					&result,
					1,
					p_param,
					get_obj_this().get()
					);
				set_result(result);
			}
			set_processing(false);
		}
Example #28
0
static char *test_stack() {
    Object *push1 = interpreter_stack_push(interpreter,
        object_number(interpreter, 1)
    );
    mu_assert(push1 != NULL, "Failed to push push1 to stack");
    Object *push2 = interpreter_stack_push(interpreter,
        object_number(interpreter, 2)
    );
    mu_assert(push2 != NULL, "Failed to push push2 to stack");
    Object *push3 = interpreter_stack_push(interpreter,
        object_number(interpreter, 3)
    );
    mu_assert(push3 != NULL, "Failed to push push3 to stack");

    Object *obj3 = interpreter_stack_pop(interpreter);
    mu_assert(obj3 != NULL, "Failed to pop obj3 from stack");
    Object *obj2 = interpreter_stack_pop(interpreter);
    mu_assert(obj2 != NULL, "Failed to pop obj2 from stack");
    Object *obj1 = get_obj(interpreter);
    mu_assert(obj1 != NULL, "Failed to pop obj1 from stack");

    return 0;
}
Example #29
0
static t_obj	*get_struct_obj(int fd)
{
	t_var_parser	var;

	var.num_line = 0;
	var.cur_obj = -1;
	var.obj = get_obj();
	while ((var.ret = get_next_line(fd, &(var.line))) > 0)
	{
		if (ft_strlen(var.line) == 0)
		{
			free(var.line);
			continue ;
		}
		(var.num_line) += 1;
		loop_get_struct(&var);
		free(var.line);
	}
	if (var.ret < 0)
		return (NULL);
	free(var.line);
	return (var.obj);
}
Example #30
0
void		put_obj(t_server *server, t_client *client, char *str)
{
  char		*resources;
  int		i;

  resources = split_string(str, ' ', 1);
  if (resources)
    {
      i = 0;
      while (g_str[i] && strcmp(g_str[i], resources) != 0)
	i++;

      if (g_str[i] != NULL)
	get_obj(server, client, i);
      else
	client->messages = append_list(client->messages, strdup("ko\n"));
      free(resources);
    }
  else
    client->messages = append_list(client->messages, strdup("ko\n"));

  client->player->delay_action = (7.f / server->delay) * 1000000;
}