예제 #1
0
static void slab_debug(struct slabinfo *s)
{
	if (strcmp(s->name, "*") == 0)
		return;

	if (sanity && !s->sanity_checks) {
		set_obj(s, "sanity", 1);
	}
	if (!sanity && s->sanity_checks) {
		if (slab_empty(s))
			set_obj(s, "sanity", 0);
		else
			fprintf(stderr, "%s not empty cannot disable sanity checks\n", s->name);
	}
	if (redzone && !s->red_zone) {
		if (slab_empty(s))
			set_obj(s, "red_zone", 1);
		else
			fprintf(stderr, "%s not empty cannot enable redzoning\n", s->name);
	}
	if (!redzone && s->red_zone) {
		if (slab_empty(s))
			set_obj(s, "red_zone", 0);
		else
			fprintf(stderr, "%s not empty cannot disable redzoning\n", s->name);
	}
	if (poison && !s->poison) {
		if (slab_empty(s))
			set_obj(s, "poison", 1);
		else
			fprintf(stderr, "%s not empty cannot enable poisoning\n", s->name);
	}
	if (!poison && s->poison) {
		if (slab_empty(s))
			set_obj(s, "poison", 0);
		else
			fprintf(stderr, "%s not empty cannot disable poisoning\n", s->name);
	}
	if (tracking && !s->store_user) {
		if (slab_empty(s))
			set_obj(s, "store_user", 1);
		else
			fprintf(stderr, "%s not empty cannot enable tracking\n", s->name);
	}
	if (!tracking && s->store_user) {
		if (slab_empty(s))
			set_obj(s, "store_user", 0);
		else
			fprintf(stderr, "%s not empty cannot disable tracking\n", s->name);
	}
	if (tracing && !s->trace) {
		if (slabs == 1)
			set_obj(s, "trace", 1);
		else
			fprintf(stderr, "%s can only enable trace for one slab at a time\n", s->name);
	}
	if (!tracing && s->trace)
		set_obj(s, "trace", 1);
}
예제 #2
0
파일: MKC_var.hpp 프로젝트: coin-or/Bcp
 MKC_var(BCP_buffer& buf) :
   BCP_var_algo(BCP_BinaryVar, 0.0, 0.0, 1.0),
   cost(0.0), entry_num(0), entries(0) {
   buf.unpack(cost).unpack(entries, entry_num)
      .unpack(color[0]).unpack(color[1]);
   set_obj(cost);
 }
예제 #3
0
static void slab_validate(struct slabinfo *s)
{
	if (strcmp(s->name, "*") == 0)
		return;

	set_obj(s, "validate", 1);
}
예제 #4
0
static void slab_shrink(struct slabinfo *s)
{
	if (strcmp(s->name, "*") == 0)
		return;

	set_obj(s, "shrink", 1);
}
예제 #5
0
void DynamicDrawObject::update_model_buffer(){
	if(!model_buffer){
		set_obj(new ModelBuffer(model));
	}else{
		model_buffer->load_model(model);
	}
	model_updated=false;
}
예제 #6
0
 void LP::setObjective(const size_t n, const bool maximize) {
     set_obj(pimpl_->lp_.get(), n+1, 1.0);
     if (maximize)
         set_maxim(pimpl_->lp_.get());
     else
         set_minim(pimpl_->lp_.get());
     maximize_ = maximize;
 }
예제 #7
0
// ---------------------------------------------------------------------------
// 
// -----------
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);
	}
}
예제 #8
0
// ---------------------------------------------------------------------------
// 
// -----------
bool bToolRedraw::set_key(int k){
bool	b=false;
	
	if(_ec>0){
		switch(k){
			case kEnterCharCode:
			case kReturnCharCode:
				clearTempPathContext(true);
				validTempPathContext();
				if(get_locs()->count()>1){
					action(0);
				}
				(void)bToolGeomWithJoin::set_key(k);
				k=0;
				set_use_locs(false);
				set_obj(NULL);
				_ec=0;
				b=true;
				set_curs();
				break;
				
			case kEscapeCharCode:
				clearTempPathContext(true);
				validTempPathContext();				
				(void)bToolGeomWithJoin::set_key(k);
				k=0;
				set_use_locs(false);
				set_obj(NULL);
				b=true;
				_ec=0;
				set_curs();
				break;
			case kBackspaceCharCode:
				(void)bToolGeomWithJoin::set_key(k);
				clearTempPathContext(true);
				update(true);
				validTempPathContext();
				k=0;
				break;
		}
	}
	(void)bToolGeomWithJoin::set_key(k);
	return(b);
}
static int slab_empty(struct slabinfo *s)
{
	if (s->objects > 0)
		return 0;

	if (s->slabs != 0)
		set_obj(s, "shrink", 1);

	return 1;
}
예제 #10
0
// ---------------------------------------------------------------------------
// 
// -----------
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;
}
예제 #11
0
파일: kp_util.c 프로젝트: awreece/ktap
void kp_tab_setvalue(ktap_tab_t *t, const ktap_val_t *key, ktap_val_t *val)
{
	const ktap_val_t *v = kp_tab_get(t, key);

	if (v != niltv) {
		set_obj((ktap_val_t *)v, val);
	} else {
		if (t->freetop == t->node) {
			int size = (t->hmask + 1) * sizeof(ktap_node_t);
			t->node = realloc(t->node, size * 2);
			memset(t->node + t->hmask + 1, 0, size);
			t->freetop = t->node + (t->hmask + 1) * 2;
			t->hmask = (t->hmask + 1) * 2 - 1;
		}

		ktap_node_t *n = --t->freetop;
		set_obj(gkey(n), key);
		set_obj(gval(n), val);
	}
}
예제 #12
0
		bool start(tTJSVariantClosure const& closure) {
			scoped_lock_type lock(mutex_);
			if (get_processing()) {
				return false;
			}
			set_obj(closure.Object);
			set_obj_this(closure.ObjThis);
			cancelled_ = false;
			thread_ = boost::make_shared<boost::thread>(
				boost::lambda::bind(&ThreadTaskImpl::callback, this)
				);
			return true;
		}
예제 #13
0
static int slab_empty(struct slabinfo *s)
{
	if (s->objects > 0)
		return 0;

	/*
	 * We may still have slabs even if there are no objects. Shrinking will
	 * remove them.
	 */
	if (s->slabs != 0)
		set_obj(s, "shrink", 1);

	return 1;
}
예제 #14
0
MCF1_var::MCF1_var(BCP_buffer& buf) :
    // we don't know the onj coeff (weight) yet, so temporarily set it to 0
    BCP_var_algo(BCP_ContinuousVar, 0, 0, 2)
{
    buf.unpack(commodity);
    int numarcs;
    int* ind;
    double* val;
    buf.unpack(ind, numarcs);
    buf.unpack(val, numarcs);
    flow.assignVector(numarcs, ind, val, false /*don't test for duplicates*/);
    buf.unpack(weight);
    set_obj(weight);
}
예제 #15
0
파일: Value.cpp 프로젝트: jiangxilong/yari
void Value::set_immediate_from_static_field(InstanceClass* ic, int offset) {
  TypeArray::Raw f = ic->fields();
  Oop::Raw object;

  for (int index = 0; index < f().length(); index += 5) {
    Field static_field(ic, index);

    if (static_field.offset() == offset) {
      // Note: there may be a non-static field with the same 'offset'
      // as the static field we're trying to find.
      if (static_field.is_final() && static_field.is_static()) {
        switch (static_field.type()) {
          case T_BOOLEAN : // fall-through - stored as 32-bit
          case T_CHAR    : // fall-through - stored as 32-bit
          case T_BYTE    : // fall-through - stored as 32-bit
          case T_SHORT   : // fall-through - stored as 32-bit
          case T_INT     : set_int(ic->int_field(offset));       break;

          case T_ARRAY   : // fall-through
          case T_OBJECT  :
            // Note: if setting immediate for object fields is enabled for cross
            // generator, this reference will be written to the TEXT block as a
            // part of relocation information for the compiled method. The
            // problem is that the referenced object may be put to the HEAP
            // block and it would be impossible to write its reference
            // in the TEXT block. At this point we don't know the block type of
            // the referenced object, so for now we disable setting immediate
            // for cross generator.
            if (!USE_AOT_COMPILATION || !GenerateROMImage) {
              object = ic->obj_field(offset); 
              set_obj(&object);
            }
            break;
#if ENABLE_FLOAT
          case T_FLOAT   : set_float(ic->float_field(offset));   break;
          case T_DOUBLE  : set_double(ic->double_field(offset)); break;
#endif
          case T_LONG    : set_long(ic->long_field(offset));     break;
          default        : SHOULD_NOT_REACH_HERE();              break;
        }
      }
      return;
    }
  }

  // This field is not final and was removed from the fields array
  // during romization
}
예제 #16
0
ktap_closure *kp_load(ktap_state *ks, unsigned char *buff)
{
	struct load_state S;
	ktap_closure *cl;
	int ret, i;

	S.ks = ks;
	S.buff = buff;
	S.pos = 0;

	ret = load_header(&S);
	if (ret)
		return NULL;

	cl = kp_newclosure(ks, 1);
	if (!cl)
		return cl;

	/* put closure on the top, prepare to run with this closure */
	set_closure(ks->top, cl);
	incr_top(ks);

	cl->p = kp_newproto(ks);
	if (load_function(&S, cl->p))
		return NULL;

	if (cl->p->sizeupvalues != 1) {
		ktap_proto *p = cl->p;
		cl = kp_newclosure(ks, cl->p->sizeupvalues);
		cl->p = p;
		set_closure(ks->top - 1, cl);
	}

	for (i = 0; i < cl->nupvalues; i++) {  /* initialize upvalues */
		ktap_upval *up = kp_newupval(ks);
		cl->upvals[i] = up;
	}

	/* set global table as 1st upvalue of 'f' */
	if (cl->nupvalues == 1) {
		ktap_table *reg = hvalue(&G(ks)->registry);
		const ktap_value *gt = kp_table_getint(reg, KTAP_RIDX_GLOBALS);
		set_obj(cl->upvals[0]->v, gt);
	}

	verify_code(&S, cl->p);
	return cl;
}
예제 #17
0
파일: main.c 프로젝트: ChevalCorp/RayTracer
void		init_conf(t_rtv1 *rt, int ac, char **av)
{
  int		fd;
  char		*newline;

  if (ac < 1 && ac > 2)
    exit(1);
  if ((fd = open(av[1], O_RDONLY)) == -1)
    exit(1);
  while ((newline = read_line(fd)))
    {
      if (my_strcmp("##", newline) == 1)
	addlast(rt);
    }
  close(fd);
  if ((fd = open(av[1], O_RDONLY)) == -1)
    exit(1);
  set_obj(rt, fd);
  close(fd);
}
예제 #18
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolCut::track_obj(){
bGenericGeoElement* o=get_obj();
	bToolGeomWithJoin::track_obj();
	if(o!=get_obj()){
		FlushSelection(_gapp);
	}
	if((get_obj())&&(o!=get_obj())){
bGenericType*	tp=_gapp->typesMgr()->get(get_obj()->getType());
		switch(tp->kind()){
			case kBaseKindPolyline:
			case kBaseKindPolygon:
			case kBaseKindRaster:
				get_obj()->setselect(true,true);
				break;
			default:
				set_obj(NULL);
				break;
		}
	}	
}
// ---------------------------------------------------------------------------
//
// -----------
void bToolGeomWithJoin::track_obj(){
// Méthode sans raccourci clavier supplémentaire pour verrouiller sur l'objet sélectionné
bArray*				ga;
bGenericStyle*		style;
bGenericGeoElement	*o=NULL,*prev;
long				i,n=_gapp->layersAccessCtx()->count();
CGPoint				pt;
    
    get_cur(&pt);
    prev=get_obj();
    if(prev!=NULL){
        for(i=n;i>0;i--){
            style=_gapp->layersAccessCtx()->get(i);
            if(!style){
                continue;
            }
            if(!style->gettype()){
                continue;
            }
            if((style->gettype()->kind()==kBaseKindPoint)   ||
               (style->gettype()->kind()==kBaseKindText)    ){
                continue;
            }
            ga=style->objsatpoint(&pt,true);
            if(!ga){
                continue;
            }
            if(_lsi<i){// Pour permettre de sélectionner un objet dans une couche au dessus
                delete ga;
                break;
            }
            for(long j=1;j<=ga->count();j++){
                ga->get(j,&o);
                if(o==prev){// Pour rester vérouillé sur l'objet en cours
                    delete ga;
                    return;
                }
            }
            delete ga;
        }
    }
    
// Pas de précédent retrouvé, on prend la méthode normale
    for(i=n;i>0;i--){
        style=_gapp->layersAccessCtx()->get(i);
        if(!style){
            continue;
        }
        if(!style->gettype()){
            continue;
        }
        if((style->gettype()->kind()==kBaseKindPoint)   ||
           (style->gettype()->kind()==kBaseKindText)    ){
            continue;
        }
        ga=style->objsatpoint(&pt,false);
        if(!ga){
            continue;
        }
        if(ga->count()>0){
            ga->get(1,&o);
            delete ga;
            if(o!=prev){
                set_obj(o);
                _lsi=i;
            }
            break;
        }
        delete ga;
    }
    if(o==NULL){
        _lsi=0;
        set_obj(NULL);
    }
    
// Verrouillage par touche sur la sélection
// pour éviter les changements d'objets intempestifs
//    if((get_obj()!=NULL)&&is_modifiers(controlKey)){
//        return;
//    }
//    bStdTool::track_obj();
}
예제 #20
0
void LoadBalancing::lp_create_model() {
	int Ncol=3*num_using_nodes_+(num_using_nodes_-1)*(num_quantiles_+2);
	int i,j;
	int *colno=(int*)malloc((Ncol+1)*sizeof(int));
	REAL *row=(REAL*)malloc((Ncol+1)*sizeof(REAL));
	int *sosvars=(int*)malloc((num_quantiles_+2)*sizeof(int));
	int ret;

	lp = make_lp(0,Ncol);
	if(lp == NULL) {
		fprintf(stderr, "Unable to create new LP model\n");
//		return(-1);
	}
	resize_lp(lp, 6*num_using_nodes_-3, Ncol);

	//Set objective function
	set_obj(lp,num_using_nodes_+1,1);

	//Add constraints:
	set_add_rowmode(lp, TRUE);

	// D*x + E*ip - t <= -G
	for(i=0;i<num_using_nodes_;i++){
		for(j=0;j<num_using_nodes_;j++){
			colno[j]=POS_Xi(j);
			row[j]=lp_D[i*num_using_nodes_+j];
		}
		colno[j]=POS_IPi(i); //ip(i);
		row[j]=Mopt_*lp_E[i];
		colno[j+1]=POS_T;
		row[j+1]=-1;// -t
		add_constraintex(lp,j+2,row,colno,LE,-lp_G[i]);
	}

	//Increasing constraints, considering the overlap, (x[n]-x[n+1]<=-2*overlap_)
	for(i=0;i<num_using_nodes_-2;i++){
		colno[0]=POS_Xi(i);
		row[0]=1;
		colno[1]=POS_Xi(i+1);
		row[1]=-1;
		add_constraintex(lp,2,row,colno,LE,-2*overlap_);
	}
	colno[0]=POS_Xi(i);
	row[0]=1;
	colno[1]=POS_Xi(i+1);
	row[1]=-1;
	add_constraintex(lp,2,row,colno,LE,-overlap_);


	//And the last cut must be 1: (x[num_using_nodes_]=1)
	colno[0]=POS_Xi(num_using_nodes_-1);
	row[0]=1;
	add_constraintex(lp,1,row,colno,EQ,1);

	//And now we define the number of interest points for each cut (ip1, ip2,...)
	// ip1=f1
	// ip2=f2-f1
	// ip3=f3-f2
	// ipN=1-f3

	//ip1:
	colno[0]=POS_IPi(0); //ip1
	row[0]=-1;
	colno[1]=POS_Fi(0); //f1
	row[1]=1;
	add_constraintex(lp,2,row,colno,EQ,0);

	//ip2 to ip(N-1):
	for(i=1;i<num_using_nodes_-1;i++){
		colno[0]=POS_IPi(i); //ip(i)
		row[0]=-1;
		colno[1]=POS_Fi(i); //f(i)
		row[1]=1;
		colno[2]=POS_Fi(i-1); //f(i-1)
		row[2]=-1;
		add_constraintex(lp,3,row,colno,EQ,0);
	}

	//ipN:
	colno[0]=POS_IPi(num_using_nodes_-1); //ipN
	row[0]=1;
	colno[1]=POS_Fi(num_using_nodes_-2); //f(N-1)
	row[1]=1;
	add_constraintex(lp,2,row,colno,EQ,1);


	//SOS variables:
	// d10+d11+d12+d13+...=1
	for(i=0;i<num_using_nodes_-1;i++){
		for(j=0;j<num_quantiles_+2;j++){
			colno[j]=POS_Dij(i,j);
			row[j]=1;
			sosvars[j]=POS_Dij(i,j);
		}
		char sosName[] = "SOS"; //Gives a warning otherwise...
		add_SOS(lp, sosName, 2, 1, num_quantiles_+2, sosvars, NULL);
		add_constraintex(lp,num_quantiles_+2,row,colno,EQ,1);
	}

	//So now we define the piecewise functions f (number of interest points left of x)
	for(i=0;i<num_using_nodes_-1;i++){
		colno[0]=POS_Fi(i); //fi
		row[0]=-1;
		for(j=0;j<num_quantiles_;j++){
			colno[j+1]=POS_Dij(i,j+1);
			row[j+1]=(j+1.0)/num_quantiles_;
		}
		colno[j+1]=POS_Dij(i,j+1);
		row[j+1]=1;
		add_constraintex(lp,num_quantiles_+2,row,colno,EQ,0);
	}

	// Now x1=q1*d11 + q2*d12 + ...
	for(i=0;i<num_using_nodes_-1;i++){
		colno[0]=POS_Xi(i);
		row[0]=-1;
		for(j=0;j<num_quantiles_;j++){
			colno[j+1]=POS_Dij(i,j+1);
			row[j+1]=(float)IPx_quantile_aprox_.at(j)/width_;
		}
		colno[j+1]=POS_Dij(i,j+1);
		row[j+1]=1;
		add_constraintex(lp,num_quantiles_+2,row,colno,EQ,0);
	}

	set_add_rowmode(lp, FALSE);

	free(colno);
	free(row);
	free(sosvars);
	is_lpmodel_created_=true;
}
예제 #21
0
 oop()                               { set_obj(NULL); }
예제 #22
0
 oop(const oop& o)                   { set_obj(o.obj()); }
예제 #23
0
 oop(const volatile oop& o)          { set_obj(o.obj()); }
예제 #24
0
 oop(const void* p)                  { set_obj(p); }
// ---------------------------------------------------------------------------
// 
// -----------
void bToolJustification::clic(CGPoint pt, int count){
_bTrace_("bToolJustification::clic",true);
	bStdToolPres::clic(pt,count);
	if(count>1){
		return;
	}
	
bArray*					ga;
bArray					runs(sizeof(bGenericXMLBaseElement*));
bGenericXMLBaseElement	*run,*gm,*elt;
bGenericGeoElement*		o=NULL;
int						i,n=_gapp->layersAccessCtx()->count();
CGPoint					p;
	
	set_obj(NULL);
	get_clic(&p);
	
	_fjust=0;
	_ijust=0;
	_fspc=0;
	_ispc=0;

	_styl=NULL;
	
	_curjust=0;
	_curspc=0;
	_pthlen=0;
	_txtwdt=0;
	_compjust=0;
	
	_xpts=NULL;
	_ypts=NULL;
	_offs=NULL;
	_npts=0;
	_noffs=0;
	
	for(i=n;i>0;i--){
		_styl=_gapp->layersAccessCtx()->get(i);
		if(!_styl){
			continue;
		}	
		ga=_styl->objsatpoint(&p,true);
		if(!ga){
			continue;
		}
		if(ga->count()<=0){
			delete ga;
			continue;
		}
		if(ga->count()>1){
			delete ga;
			break;
		}
		ga->get(1,&o);
		delete ga;
		break;
	}
	
	if(!o){
		_styl=NULL;
		return;
	}

bGenericUnit*	scl=_gapp->scaleMgr()->get();

	_styl->get_styleruns(runs,o,scl->coef(),1);

char			val[_values_length_max_];
bGenericType	*tp=_gapp->typesMgr()->get(o->getType());
	
	_jkd=kJustificationKindNone;

	for(int i=1;i<=runs.count();i++){
		runs.get(i,&run);
		_fjust=0;
		_fspc=0;
		gm=_gapp->classMgr()->NthElement(run,1,"polyjustification");
		if(!gm){
			gm=_gapp->classMgr()->NthElement(run,1,"pointjustification");
			if(!gm){
				continue;
			}
			_jkd=kJustificationKindOnPoint;
		}
		else{
			_jkd=kJustificationKindOnPath;
		}
		elt=_gapp->classMgr()->NthElement(gm,1,"field");
		if(!elt){
			continue;
		}
		elt->getvalue(val);
		_fjust=tp->fields()->get_index(val);
		
		if(_jmd==kJustificationMethodGlyphSpace){
			gm=_gapp->classMgr()->NthElement(run,1,"charspacing");
			elt=_gapp->classMgr()->NthElement(gm,1,"field");
			if(!elt){
				_fjust=0;
				continue;
			}
			elt->getvalue(val);
			_fspc=tp->fields()->get_index(val);
		}
		else if(_jmd==kJustificationKindOnWordSpace){
			gm=_gapp->classMgr()->NthElement(run,1,"wordspacing");		
			elt=_gapp->classMgr()->NthElement(gm,1,"field");
			if(!elt){
				_fspc=0;
				continue;
			}
			elt->getvalue(val);
			_fspc=tp->fields()->get_index(val);
		}
		break;
	}

	if(!_fjust){
		_styl=NULL;
_te_("no just field");
		return;
	}
	set_obj(o);

bGenericGraphicContext*	ctx=_styl->get_context_for_object(o,0,false);
bCoreTextInfo*			txt=ctx->getText();
float					*xpts,*ypts;
int						*offs;

	ctx->getGeometry(&xpts,&ypts,&_npts,&offs,&_noffs);
		
	if(	(_jkd==kJustificationKindOnPath)&&
		(_npts<2)						){
		ctx->setGeometry(NULL,NULL,0,NULL,0);
		_styl=NULL;
		_fjust=0;
		_fspc=0;
		_jmd=kJustificationKindNone;
		_umode=kJustificationUserModeStd;
		_jkd=kJustificationKindNone;
_te_("_npts<2");
		return;
	}
	if(	(_jkd==kJustificationKindOnPoint)&&
		(_npts==0)						){
		ctx->setGeometry(NULL,NULL,0,NULL,0);
		_styl=NULL;
		_fjust=0;
		_fspc=0;
		_jmd=kJustificationKindNone;
		_umode=kJustificationUserModeStd;
		_jkd=kJustificationKindNone;
_te_("_npts==0");
		return;
	}
	if(!xpts||!ypts){
		ctx->setGeometry(NULL,NULL,0,NULL,0);
		_styl=NULL;
		_fjust=0;
		_fspc=0;
		_jmd=kJustificationKindNone;
		_umode=kJustificationUserModeStd;
		_jkd=kJustificationKindNone;
_te_("(!_xpts||!_ypts)");
		return;
	}

	_xpts=new float[_npts];
	memmove(_xpts,xpts,_npts*sizeof(float));
	_ypts=new float[_npts];
	memmove(_ypts,ypts,_npts*sizeof(float));
	_offs=new int[_noffs];
	memmove(_offs,offs,_noffs*sizeof(int));

	ctx->setGeometry(NULL,NULL,0,NULL,0);

	_txtwdt=txt->textWidth();
	_pthlen=0;
	o->getValue(_fjust,&_ijust);
	if(_fspc){
		o->getValue(_fspc,&_ispc);
		_curspc=_ispc;
	}
	
CGPoint		cgp=pt;
	if(_jkd==kJustificationKindOnPath){		
float		r;
		for(int i=0;i<_npts-1;i++){
			_pthlen+=XYDist(_xpts[i],_ypts[i],_xpts[i+1],_ypts[i+1]);
		}
		XYProjOnPath(cgp.x,cgp.y,_xpts,_ypts,_npts,&cgp.x,&cgp.y,&_clkidx,&r);
		if((r>0)&&(r<1)){
			_xpts=(float*)realloc(_xpts,(_npts+1)*sizeof(float));
			_ypts=(float*)realloc(_ypts,(_npts+1)*sizeof(float));
			_npts++;
			memmove(&_xpts[_clkidx+1],&_xpts[_clkidx],_npts-_clkidx);
			memmove(&_ypts[_clkidx+1],&_ypts[_clkidx],_npts-_clkidx);
			_xpts[_clkidx]=cgp.x;
			_ypts[_clkidx]=cgp.y;
		}
		set_clic(&cgp);
		_curjust=get_justification_on_path(cgp);
		_compjust=_curjust-_ijust;
		_curjust=_ijust;
	}
	else if(_jkd==kJustificationKindOnPoint){
		_compjust=XYDist(_xpts[0],_ypts[0],cgp.x,cgp.y);
		_curjust=_ijust;
		_pthlen=rad2deg(ctx->getAngle());
	}
	
	set_use_drag(true);
	set_use_track(true);
}
// ---------------------------------------------------------------------------
// 
// -----------
void bToolTextEdition::clic(CGPoint pt, int count){
_bTrace_("bToolTextEdition::clic",true);
	bStdToolPres::clic(pt,count);
	
bArray*					ga;
bArray					runs(sizeof(bGenericXMLBaseElement*));
bGenericXMLBaseElement	*run,*gm,*elt;
bGenericGeoElement*		o=NULL;
int						i,n=_gapp->layersAccessCtx()->count();
CGPoint					p;
bGenericStyle*			_styl;
int						_fld;

	set_obj(NULL);
	get_clic(&p);
	for(i=n;i>0;i--){
		_styl=_gapp->layersAccessCtx()->get(i);
		if(!_styl){
			continue;
		}	
		ga=_styl->objsatpoint(&p,true);
		if(!ga){
			continue;
		}
		if(ga->count()<=0){
			delete ga;
			continue;
		}
		if(ga->count()>1){
			delete ga;
			break;
		}
		ga->get(1,&o);
		delete ga;
		break;
	}
	
	if(!o){
		_styl=NULL;
		return;
	}

bGenericUnit*	scl=_gapp->scaleMgr()->get();

	_styl->get_styleruns(runs,o,scl->coef(),1);

char			val[_values_length_max_];
bGenericType	*tp=_gapp->typesMgr()->get(o->getType());
	_fld=0;

	for(int i=1;i<=runs.count();i++){
		runs.get(i,&run);
		gm=_gapp->classMgr()->NthElement(run,1,"text");
		if(!gm){
			continue;
		}
		elt=_gapp->classMgr()->NthElement(gm,1,"field");
		if(!elt){
			continue;
		}
		elt->getvalue(val);
		_fld=tp->fields()->get_index(val);
		break;
	}

	if(!_fld){
_te_("no text field");
		_styl=NULL;
		return;
	}
	
	set_obj(o);

	o->getValue(_fld,val);
	if(GetAName(val,"",true)){
CGRect	bnds;
		_styl->rect(o,&bnds);
		_gapp->mapIntf()->inval(bnds);		
		
bEventLog	log(_gapp,
				getbundle(),
				kTextEditionMessageID,
				GetSignature(this));
		o->setValue(_fld,&val);	
		log.close();
		_styl->rect(o,&bnds);
		_gapp->mapIntf()->inval(bnds);		
	}
	
	set_obj(NULL);
}
// ---------------------------------------------------------------------------
// 
// -----------
void bToolJustification::end_clic(){
_bTrace_("bToolJustification::end_clic",true);
	bStdToolPres::end_clic();
	for(;;){
		if(!_fjust||!_styl){
_te_("(!_fjust("+_fjust+")||!_styl("+_styl+"))");
			break;
		}

bGenericGeoElement*	o=get_obj();
		if(!o){
_te_("(!o)");
			break;
		}
		
		set_use_drag(false);
		set_use_track(false);

		if(_umode!=kJustificationUserModeSpace){
// Pour avoir la valeur précédente en annulation
			o->setValue(_fjust,&_ijust);
CGRect	bnds;
			_styl->rect(o,&bnds);
			_gapp->mapIntf()->inval(bnds);		
			
// Report de la nouvelle valeur
bEventLog	log(_gapp,
				getbundle(),
				kJustificationMessageID,
				GetSignature(this));
			switch(_umode){
				case kJustificationUserModeRight:
					put_value(_fjust,1);
					break;
				case kJustificationUserModeCenter:
					put_value(_fjust,0.5);
					break;
				case kJustificationUserModeLeft:
					put_value(_fjust,0);
					break;
				case kJustificationUserModeStd:
					put_value(_fjust,_curjust);
					break;
			}
			log.close();
			
			_styl->rect(o,&bnds);
			_gapp->mapIntf()->inval(bnds);		
		}
		else{
// Pour avoir la valeur précédente en annulation
			o->setValue(_fspc,&_ispc);
CGRect	bnds;
			_styl->rect(o,&bnds);
			_gapp->mapIntf()->inval(bnds);		
// Report de la nouvelle valeur
bEventLog	log(_gapp,
				getbundle(),
				kJustificationMessageID,
				GetSignature(this));
			put_value(_fspc,_curspc);
			log.close();
			
			_styl->rect(o,&bnds);
			_gapp->mapIntf()->inval(bnds);		
		}
		break;
	}

	set_use_drag(false);
	set_use_track(false);

	if(_xpts){
		delete _xpts;
	}
	if(_ypts){
		delete _ypts;
	}
	if(_offs){
		delete _offs;
	}
	_xpts=NULL;
	_ypts=NULL;
	_offs=NULL;
	_npts=0;
	_noffs=0;
	set_obj(NULL);
	
	/**/
	_fjust=0;
	_fspc=0;
	_styl=NULL;
	/**/
	
	_umode=kJustificationUserModeStd;
	_jkd=kJustificationKindNone;
}
예제 #28
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolCut::clic(CGPoint pt, int count){
i2dvertex		br;
bGenericType*	tp;

	if(get_use_locs()){// Cas des polygones
		if(count>1){
			if(get_locs()->count()>1){
				action(0);
			}
			set_use_locs(false);
			set_use_sel(true);
			set_obj(NULL);
			get_locs()->reset();
		}		
		if(get_join(&br)){
			bToolGeomWithJoin::clic(br,count);
		}
		else{
			bToolGeomWithJoin::clic(pt,count);
		}
		
		if(get_obj()){
ivertices*	vxs;
			get_clic(&br);
			get_obj()->getVertices(&vxs);
			if(	(	(ivx2ivs_dist(&br,vxs)>__FUZZY_DIST__)		&&
					(!ivx_in_ivs(&br,vxs,false))			)	||
				(	(get_locs()->count()>1)						&&							
					(ivx2ivs_dist(&br,vxs)<=__FUZZY_DIST__)	)	){
				if(get_locs()->count()>1){
					action(0);
				}
				set_use_locs(false);
				set_use_sel(true);
				set_obj(NULL);
				get_locs()->reset();
			}
		}
		return;
	}

	if(!get_obj()){
		if(get_join(&br)){
			bToolGeomWithJoin::clic(br,count);
		}
		else{
			bToolGeomWithJoin::clic(pt,count);
		}
		return;
	}
	
	tp=_gapp->typesMgr()->get(get_obj()->getType());

	switch(tp->kind()){
		case kBaseKindPolyline:
			if(get_join(&br)){
				bToolGeomWithJoin::clic(br,count);
			}
			else{
				bToolGeomWithJoin::clic(pt,count);
			}
			action(0);
			break;
			
		case kBaseKindPolygon:
		case kBaseKindRaster:
			set_use_locs(true);
			if(get_join(&br)){
				bToolGeomWithJoin::clic(br,count);
			}
			else{
				bToolGeomWithJoin::clic(pt,count);
			}
			set_use_sel(false);
			break;
			
		default:
			if(get_join(&br)){
				bToolGeomWithJoin::clic(br,count);
			}
			else{
				bToolGeomWithJoin::clic(pt,count);
			}
			break;
	}
}
예제 #29
0
// ---------------------------------------------------------------------------
// 
// -----------
void bToolRedraw::clic(CGPoint pt, int count){
i2dvertex		br;
bGenericType*	tp;	
	
	if(_ec>1){
		if(count>1){
			if(get_locs()->count()>=1){
				action(0);
			}
			set_use_locs(false);
			set_obj(NULL);
			get_locs()->reset();
			_ec=0;
			set_curs();
		}
		
		if(get_join(&br)){
			bToolGeomWithJoin::clic(br,count);
		}
		else{
			bToolGeomWithJoin::clic(pt,count);
		}
		return;
	}
	else if((count>1)&&(_ec==1)){// =Annuler
		set_use_locs(false);
		set_obj(NULL);
		get_locs()->reset();
		_ec=0;
		set_curs();
	}
	
	if(!get_obj()){
		if(get_join(&br)){
			bToolGeomWithJoin::clic(br,count);
		}
		else{
			bToolGeomWithJoin::clic(pt,count);
		}
		return;
	}
	
	tp=_gapp->typesMgr()->get(get_obj()->getType());
	
	switch(tp->kind()){	
		case kBaseKindPolyline:
		case kBaseKindPolygon:
		case kBaseKindRaster:
			if(_ec==0){
				set_use_locs(true);
				if(get_join(&br)){
					bToolGeomWithJoin::clic(br,count);
				}
				else{
					bToolGeomWithJoin::clic(pt,count);
				}
				set_use_locs(false);
				get_clic(&_vxa);
				_ec++;
			}
			else if(_ec==1){
				if(get_join(&br)){
					bToolGeomWithJoin::clic(br,count);
					get_clic(&_vxb);
					if(!eq_ivx2(&_vxa,&_vxb)){
						set_clic(&_vxa);
						set_use_locs(true);
						_ec++;
						set_curs(_cdrw);
					}
					else{
						NSBeep();
					}
				}
				else{
					NSBeep();
				}			
			}
			else{
				if(get_join(&br)){
					bToolGeomWithJoin::clic(br,count);
				}
				else{
					bToolGeomWithJoin::clic(pt,count);
				}
				_ec++;
			}
			break;
			
		default:
			if(get_join(&br)){
				bToolGeomWithJoin::clic(br,count);
			}
			else{
				bToolGeomWithJoin::clic(pt,count);
			}
			break;
	}		
}