// ---------------------------------------------------------------------------
//
// ------------
int bXMapNetClean::join_on_edges(bArray& loop, int* fields, bool report){
_bTrace_("bXMapNetClean::join_on_edges",true);
bGenericGeoElement	*oa,*ob;
ivertices			*vsa,*vsb;
i2dvertex			vx,vmin;
bArray				edg(sizeof(bGenericGeoElement*));
bArray				bdg(sizeof(bGenericGeoElement*));
double				dte,dab;
bool				flg;
char				msg[__MESSAGE_STRING_LENGTH_MAX__];
char				ttl[__MESSAGE_STRING_LENGTH_MAX__];
    
    get_localized_name(ttl,getbundle());

    b_message_string(kXMapNetCleanJoinOnEdgesMessage,msg,getbundle(),0);
bProgressWait	wt(ttl,msg,true,true,loop.count());
    for(long i=1;i<=loop.count();i++){
        if(!wt.set_progress(i)){
            break;
        }
        loop.get(i,&oa);
        oa->getVertices(&vsa);
        get_bridges(&vsa->vx.vx2[0],bdg);
        if(bdg.count()!=0){
            continue;
        }
        get_edges(&vsa->vx.vx2[0],edg,true);
        flg=(edg.count()>0);
        for(long j=1;j<=edg.count();j++){
            edg.get(j,&ob);
            ob->getVertices(&vsb);
            dte=ivx2_dist(&vsa->vx.vx2[0],&vsb->vx.vx2[0]);
            dab=ivx2_dist(&vsa->vx.vx2[0],&vsb->vx.vx2[vsb->nv-1]);
            if(dte<dab){
                vx=vsb->vx.vx2[0];
            }
            else{
                vx=vsb->vx.vx2[vsb->nv-1];
            }
            if(j==1){
                vmin=vx;
            }
            else{
                if(!eq_ivx2(&vmin,&vx)){
                    flg=false;
                    break;
                }
            }
        }
        if(!flg){
            continue;
        }
        vsa->vx.vx2[0]=vmin;
        oa->setVertices(vsa);
        if(report){
            set_net_flag(oa,fields[oa->getType()-1],_kNodeJoined);
        }
    }
    return(0);
}
示例#2
0
void update_property_dialog(Icon *i)
{
    Fl_String val;

    Fl_Config i_config(i->get_cfg()->filename());
    i_config.set_section("Desktop Entry");

    val = get_localized_name(i_config);
    if(!val.empty()) {
        pr_name->label(val);
    }

    if(!i_config.read("Exec", val, 0)) {
        pr_exec->label(val);
    }

    Fl_FileAttr *attr = fl_file_attr(i->get_cfg()->filename());
    if(attr)
    {
        char size[32];
        snprintf(size, 32, _("%d bytes, %s"), (int) attr->size, attr->time);
        pr_size->label(size);
        delete attr;
    }

    pr_icon->image(i->icon_im);
}
示例#3
0
void Icon::update_all()
{
    Fl_Config &iconConfig = *cfg;
    iconConfig.read_file(false);
    iconConfig.set_section("Desktop Entry");

    // Icon Label:
    icon_name = get_localized_name(iconConfig);
    tooltip(icon_name);
    label(icon_name);

    label_color(label_foreground);
    label_size(label_fontsize);

    lwidth = label_maxwidth; // This is a bit strange, but otherwise we get mysterious crashes...
    lheight= 0;
    fl_font(label_font(), label_size());
    fl_measure(icon_name, lwidth, lheight, FL_ALIGN_WRAP);
    lwidth += 4; //  height+= 4;

    // Icon file:
    iconConfig.read("Icon", icon_file, "folder.png");

    update_icon();

    redraw();
    //desktop->redraw();
}
// ---------------------------------------------------------------------------
//
// ------------
int bXMapNetClean::join_on_nodes(bArray& loop, int* fields, bool report){
_bTrace_("bXMapNetClean::join_on_nodes",true);
bGenericGeoElement	*oa,*op;
ivertices			*vsa,*vsp;
bArray				bdg(sizeof(bGenericGeoElement*));
bArray				nod(sizeof(bGenericGeoElement*));
bool				mod;
char				msg[__MESSAGE_STRING_LENGTH_MAX__];
char				ttl[__MESSAGE_STRING_LENGTH_MAX__];
    
    get_localized_name(ttl,getbundle());

    b_message_string(kXMapNetCleanJoinOnNodesMessage,msg,getbundle(),0);
bProgressWait	wt(ttl,msg,true,true,loop.count());
    for(long i=1;i<=loop.count();i++){
        if(!wt.set_progress(i)){
            break;
        }
        loop.get(i,&oa);
        oa->getVertices(&vsa);
        mod=false;
        get_bridges(&vsa->vx.vx2[0],bdg);
        if(bdg.count()==0){
            get_nodes(&vsa->vx.vx2[0],nod);
            if(nod.count()==1){
                nod.get(1,&op);
                op->getVertices(&vsp);
                vsa->vx.vx2[0]=vsp->vx.vx2[0];
                mod=true;
            }
        }
        get_bridges(&vsa->vx.vx2[vsa->nv-1],bdg);
        if(bdg.count()==0){
            get_nodes(&vsa->vx.vx2[vsa->nv-1],nod);
            if(nod.count()==1){
                nod.get(1,&op);
                op->getVertices(&vsp);
                vsa->vx.vx2[vsa->nv-1]=vsp->vx.vx2[0];
                mod=true;
            }
        }
        
        if(mod){
            oa->setVertices(vsa);
            if(report){
                set_net_flag(oa,fields[oa->getType()-1],_kEdgeJoined);
            }
        }
    }
    
    return(0);
}
示例#5
0
int create_new_dnd_icon(int x, int y, char *filename) //create icon from dnd data
{
    if (filename) 
    {
        char config[FL_PATH_MAX];
	const char *name = fl_file_filename(filename);
	snprintf(config, sizeof(config)-1, "%s/.ede/desktop/%s.desktop", getenv("HOME"), name);
	
        if (!fl_file_exists((char*)config))
        {
	    char val[FL_PATH_MAX];
	    Fl_Config checkconf(filename, true, false);
	
	    if(!checkconf.get("Desktop Entry", "Exec", val, 0, sizeof(val))) 
	    {	
    	        Fl_Config cfg(config);
		cfg.set_section("Desktop Entry");
		
		checkconf.get("Desktop Entry", "Icon", val, "no icon", sizeof(val)); 
        	cfg.write("Icon", val);
        	cfg.write("X", x);
        	cfg.write("Y", y);
        	cfg.write(get_localized_string(), get_localized_name(checkconf));

                checkconf.get("Desktop Entry", "Exec", val, filename, sizeof(val));
        	cfg.write("Exec", val);
        	cfg.flush();
	    }
	    else
	    {
	        Fl_Config cfg(config);
    	        cfg.set_section("Desktop Entry");
        	cfg.write("Icon", "no icon");
        	cfg.write("X", x);
        	cfg.write("Y", y);
        	cfg.write(get_localized_string(), name);
                cfg.write("Exec", filename);
        	cfg.flush();
	    }	
	    desktop->begin();
            Icon *icon = new Icon((char*)config);
    	    icon->show();
    	    desktop->end();
    	    desktop->redraw();
	}
	else 
	{
	    fl_alert(_("The icon with the same name already exists."));
	}  
    }  
    return 0;
}
// ---------------------------------------------------------------------------
//
// ------------
int bXMapNetClean::check_nodes(bArray& loop, int* fields){
_bTrace_("bXMapNetClean::check_nodes",true);
bGenericGeoElement	*oa;
ivertices			*vsa;
bArray				edg(sizeof(bGenericGeoElement*));
bArray				nod(sizeof(bGenericGeoElement*));
double				dbk=_cfg_prm.dnod;
char				msg[__MESSAGE_STRING_LENGTH_MAX__];
char				ttl[__MESSAGE_STRING_LENGTH_MAX__];
    
    _cfg_prm.dnod=0;
    
    get_localized_name(ttl,getbundle());

    b_message_string(kXMapNetCleanCheckNodesMessage,msg,getbundle(),0);
bProgressWait	wt(ttl,msg,true,true,loop.count());
    for(long i=1;i<=loop.count();i++){
        if(!wt.set_progress(i)){
            break;
        }
        loop.get(i,&oa);
        oa->getVertices(&vsa);
        get_nodes(&vsa->vx.vx2[0],nod);
        if(nod.count()>1){
            set_net_flag(oa,fields[oa->getType()-1],_kNodeDoubled);
        }
        get_edges(&vsa->vx.vx2[0],nod,true);
        if(edg.count()==0){
            set_net_flag(oa,fields[oa->getType()-1],_kNodeAlone);
            set_net_flag(oa,fields[oa->getType()-1],_kNodeNot3);
        }
        else if(edg.count()==1){
            set_net_flag(oa,fields[oa->getType()-1],_kNodeDeadEnd);
            set_net_flag(oa,fields[oa->getType()-1],_kNodeNot3);
        }
        else if(edg.count()==2){
            set_net_flag(oa,fields[oa->getType()-1],_kNodeNot3);
        }
    }
    
    _cfg_prm.dnod=dbk;
    
    return(0);
}
示例#7
0
void update_iconeditdialog(Icon *i)
{ 
    i_link->value(i->get_cfg()->filename());

    Fl_Config &i_config = *i->get_cfg();

    Fl_String val;
    i_config.set_section("Desktop Entry");

    val = get_localized_name(i_config);
    if(!val.empty()) {
        i_name->value(val);
    }

    if(!i_config.read("Exec", val, 0)) {
        i_location->value(val);
    }

    if(!i_config.read("Icon", val, 0)) {
        i_filename->value(val);
    }
}
// ---------------------------------------------------------------------------
// 
// ------------
void bXMapLineUp::make(){
bGenericGeoElement* o;
ivx_rect			vr,vrb,bnd;
bArray				arr(*_gapp->selMgr()->elements());
int					i,j,ko,kv;
int					imax,jmax,n=0;
insidePtr			inside;
ivertices			*ref,*vxs;
i2dvertex			p,lp;
bool				end=false;
int					hd=round(Measure_d2i(_gapp,_hd));
int					vd=round(Measure_d2i(_gapp,_vd));

	if(_use_surf){
		inside=ivx_in_ivs;
		_gapp->cntMgr()->elements()->get(1,&o);
		o->getBounds(&bnd);
		o->getVertices(&ref);
		imax=1+(bnd.bottom-bnd.top)/vd;
		jmax=1+(bnd.right-bnd.left)/hd;
	}
	else{
		inside=dummy_ivx_in_ivs;
		arr.get(1,&o);
		o->getBounds(&bnd);
		vr=bnd;
		o->getVertices(&vxs);
		n+=vxs->nv;
		for(i=2;i<arr.count();i++){
			arr.get(i,&o);
			o->getBounds(&vrb);
			ivr_union(&vrb,&vr,&bnd);
			vr=bnd;
			o->getVertices(&vxs);
			n+=vxs->nv;
		}
		ref=NULL;
		if(_kind==kXMapLineUpKindLine){
			imax=ceil((double)n/_nb);
			jmax=_nb;
		}
		else{
			imax=_nb;
			jmax=ceil((double)n/_nb);	
		}
	}
		
	_gapp->layersMgr()->SetObjInvalidation(false);	
	
char			msg[__MESSAGE_STRING_LENGTH_MAX__];
char			ttl[__MESSAGE_STRING_LENGTH_MAX__];
    get_localized_name(ttl,getbundle());
	message_string(kMsgProgress,msg,1);
bProgressWait	wt(ttl,msg,true,true,arr.count());	

bEventLog	log(_gapp,this);
	
	ko=1;
	kv=0;
	arr.get(ko,&o);
	o->getVertices(&vxs);
	lp.h=bnd.left;
	lp.v=bnd.top;
	for(i=0;i<imax;i++){
		for(j=0;j<jmax;j++){
			p.h=bnd.left+j*hd;
			p.v=bnd.top+i*vd;
			if(!inside(&p,ref,1)){
				continue;
			}
			lp=p;
			vxs->vx.vx2[kv]=p;
			kv++;
			if(kv==vxs->nv){
				kv=0;
				ko++;
				o->setVertices(vxs);
				if(!wt.set_progress(ko)){
					end=true;
					break;
				}
				if(!arr.get(ko,&o)){
					end=true;
					break;
				}
				o->getVertices(&vxs);
			}
		}
		if(end){
			break;
		}
	}
	
	if(!end){
		if(kv<vxs->nv){
			for(i=kv;i<vxs->nv;i++){
				vxs->vx.vx2[kv]=lp;
			}
			o->setVertices(vxs);
			ko++;
		}
		for(i=ko;i<=arr.count();i++){
			if(!wt.set_progress(i)){
				break;
			}	
			arr.get(i,&o);
			o->getVertices(&vxs);
			for(j=0;j<vxs->nv;j++){
				vxs->vx.vx2[j]=lp;
			}
			o->setVertices(vxs);
		}
	}
	_gapp->layersMgr()->SetObjInvalidation(true);	
	log.close();
}
// ---------------------------------------------------------------------------
// 
// -----------
bool bXMapMakeConstraints::do_make_from_field(bGenericType* tp,
											  long field,
											  long srcfield,
											  bool usevalue){
_bTrace_("bXMapMakeConstraints::do_make_from_field",true);
int						k;
MakeConstraints_prm		prm;
MCITp					pp;

	prm.tp=tp;
	prm.field=field;
	prm.srcfield=srcfield;
	prm.srcuse=usevalue?kMakeConstraintsUseValue:kMakeConstraintsUseLabel;

	pp.prm=&prm;
	pp.init=0;
	
char	mess[__MESSAGE_STRING_LENGTH_MAX__];

	tp->fields()->get_name(srcfield,mess);
	tp->fields()->get_name(field,mess);
	
	get_localized_name(mess,getbundle());
bProgressWait	wt(mess,NULL,true,true,prm.tp->nb_live()*2);
	pp.wt=&wt;
	pp.wtn=0;
 	
	if(prm.tp->fields()->count_constraints(prm.field)==0){
		if(prm.srcuse==kMakeConstraintsUseValue){
_tm_("nouvelle contrainte par valeur");
			prm.tp->fields()->get_kind(prm.field,&k);
			switch(k){
				case _char:{
					char	buff[1024];
					pp.val=buff;
					prm.tp->iterator()->iterate(&pp,fill_char);
				}break;
				case _bool:
				case _int:{
					int	buff;
					pp.val=&buff;
					prm.tp->iterator()->iterate(&pp,fill_int);
				}break;
				case _double:
				case _date:
				case _time:{
					double	buff;
					pp.val=&buff;
					prm.tp->iterator()->iterate(&pp,fill_double);
				}break;
			}
		}
		else{
_tm_("nouvelle contrainte par intitulé");
			int	buff=1;
			pp.val=&buff;
			pp.init=1;
			prm.tp->iterator()->iterate(&pp,fill_int);
		}
	}
	
	if(prm.srcuse==kMakeConstraintsUseValue){
		prm.tp->fields()->get_kind(prm.field,&k);
		switch(k){
			case _char:
				prm.tp->iterator()->iterate(&pp,analyse_char);
				break;
			case _bool:
			case _int:
				prm.tp->iterator()->iterate(&pp,analyse_int);
				break;
			case _double:
			case _date:
			case _time:
				prm.tp->iterator()->iterate(&pp,analyse_double);
				break;
		}
	}
	else{
		prm.tp->iterator()->iterate(&pp,analyse_char);
	}
	
	return(false);
}
示例#10
0
// ---------------------------------------------------------------------------
// 
// ------------
bool bXMapPaste::process(int msg, void* prm){
_bTrace_("bXMapPaste::process",true);
void*	data=NULL;
size_t  dtsz;
void*   nsdata=getPasteBoardData(&data,&dtsz);

    if((dtsz==0)||(data==NULL)){
        return true;
    }
    
void*				cur=data;
void*				last=(void*)((UInt32)data+dtsz);
int					idx,k;
tag*				tg;
bGenericGeoElement*	o=NULL;
bGenericType*		tp=NULL;
char				name[260];
UInt32				etsz=(sizeof(tag)-sizeof(void*));
char				mess[__MESSAGE_STRING_LENGTH_MAX__];
	get_localized_name(mess,_bndl);
bBarberWait			wt(mess,NULL,true,true);
bEventLog           log(_gapp,this);
   
    _gapp->layersMgr()->SetObjInvalidation(false);

	while(cur<last){
		if(!wt.set_progress(0)){
            _gapp->layersMgr()->SetObjInvalidation(true);
			return(true);
		}
		tg=(tag*)cur;
		if(tg->sign==kScrapMacMapTagType){
			memcpy(name,(void*)((UInt32)cur+etsz),tg->snsz);
			tp=_gapp->typesMgr()->get(_gapp->typesMgr()->index(name));
			if(!tp){
_te_("bad type name "+name);
				o=NULL;
			}
			else if(!tp->new_object(&o)){
_te_("new_object failed");
				o=NULL;
			}
		}
		else if(tg->sign==kScrapMacMapTagField){
			if(o){
				memcpy(name,(void*)((UInt32)cur+etsz),tg->snsz);
				idx=tp->fields()->get_index(name);
				if(idx!=0){
					tp->fields()->get_kind(idx,&k);
					switch(k){
						case _ivxs2:{
						case _ivxs3:
							ivertices*	vxs=(ivertices*)malloc(tg->cnsz);
							memcpy(vxs,(void*)((UInt32)cur+etsz+tg->snsz),tg->cnsz);
							vxs=ivs_unpack(vxs);
							o->setValue(idx,(void*)vxs);
							ivs_free(vxs);
							}break;
						case _dvxs2:
						case _dvxs3:{
							dvertices*	vxs=(dvertices*)malloc(tg->cnsz);
							memcpy(vxs,(void*)((UInt32)cur+etsz+tg->snsz),tg->cnsz);
							vxs=dvs_unpack(vxs);
							o->setValue(idx,(void*)vxs);
							dvs_free(vxs);
							}break;
						default:
							o->setValue(idx,(void*)((UInt32)cur+etsz+tg->snsz));
							break;
					}					
				}
				else{
_te_("bad field name "+name);
				}
			}
		}
		else{
_te_("bad tag sign");
			break;
		}
		cur=(void*)((UInt32)cur+etsz+tg->snsz+tg->cnsz);
	}
    _gapp->layersMgr()->SetObjInvalidation(true);
	log.close();
    cleanPasteBoardData(nsdata);
    
	return(true);
}
// ---------------------------------------------------------------------------
//
// ------------
int bXMapNetClean::cut_edges(bArray& loop, bArray& added, int* fields, bool report){
_bTrace_("bXMapNetClean::cut_edges",true);
bGenericGeoElement	*oa,*ob,*op;
bGenericType		*tp;
ivertices			*vsa,*vsb,*vse,*vsp;
bArray				edg(sizeof(bGenericGeoElement*));
bArray				bdg(sizeof(bGenericGeoElement*));
int                 k;
double				d,r;
i2dvertex			vr;
char				msg[__MESSAGE_STRING_LENGTH_MAX__];
char				ttl[__MESSAGE_STRING_LENGTH_MAX__];
    
    get_localized_name(ttl,getbundle());

    b_message_string(kXMapNetCleanCutEdgesMessage,msg,getbundle(),0);
bProgressWait	wt(ttl,msg,true,true,loop.count());
    for(long i=1;i<=loop.count();i++){
        if(!wt.set_progress(i)){
            break;
        }
        loop.get(i,&op);
        op->getVertices(&vsp);
        get_bridges(&vsp->vx.vx2[0],bdg);
        if(bdg.count()>0){
_tm_("bridge");
            continue;
        }
        
        get_edges(&vsp->vx.vx2[0],edg,false);
        for(long j=1;j<=edg.count();j++){
            edg.get(j,&oa);
            oa->getVertices(&vsa);
            d=ivx_proj(&vsp->vx.vx2[0],
                       vsa,
                       &vr,
                       &k,
                       &r);
            if(ivs2ivs(vsa,&vse)){
_te_("ivs2ivs failed");
                continue;
            }
            vsa=NULL;
            vsb=NULL;
            vse=ivx2_insert(vse,&vr,k);
            if((k==0)||(k==vse->nv-1)){
                ivs_free(vse);
                continue;
            }
            ivs_split(vse,k,&vsa,&vsb);
            if((!vsa)||(!vsb)){
                ivs_free(vse);
                if(vsa){
                    ivs_free(vsa);
                }
                if(vsb){
                    ivs_free(vsb);
                }
_tm_("ivs_split failed at "+k);
                continue;
            }
            tp=_gapp->typesMgr()->get(oa->getType());
            if(!tp->clone_object(oa,&ob)){
                ivs_free(vse);
                ivs_free(vsa);
                ivs_free(vsb);
_tm_("clone_object failed");
                break;
            }
            oa->setVertices(vsa);
            ob->setVertices(vsb);
            if(report){
                set_net_flag(oa,fields[tp->index()-1],_kEdgeCreated);
                set_net_flag(ob,fields[tp->index()-1],_kEdgeCreated);
            }
            added.add(&ob);
        }
    }
    return(0);
}
// ---------------------------------------------------------------------------
//
// ------------
int bXMapNetClean::create_nodes(bArray& loop, bArray& added, int* fields, bool report){
_bTrace_("bXMapNetClean::create_nodes",true);
    if(!_cfg_prm.tnod){
        return(0);
    }
bGenericGeoElement	*oa,*ob,*op;
ivertices			*vsa,*vsb,*vsp;
i2dvertex			vx;
ivx_rect			vxr;
bArray				edg(sizeof(bGenericGeoElement*));
bArray				bdg(sizeof(bGenericGeoElement*));
bArray				nod(sizeof(bGenericGeoElement*));
char				msg[__MESSAGE_STRING_LENGTH_MAX__];
char				ttl[__MESSAGE_STRING_LENGTH_MAX__];
    
    
    vsp=ivs_new(_2D_VX,1,0);
    
    get_localized_name(ttl,getbundle());
    b_message_string(kXMapNetCleanNodeCreationMessage,msg,getbundle(),0);
bProgressWait	wt(ttl,msg,true,true,loop.count());
    for(long i=1;i<=loop.count();i++){
        if(!wt.set_progress(i)){
            break;
        }
        loop.get(i,&oa);
        oa->getVertices(&vsa);
        
        get_nodes(&vsa->vx.vx2[0],nod);
        if(nod.count()==0){
            _cfg_prm.tnod->new_object(&op);
            vsp->vx.vx2[0]=vsa->vx.vx2[0];
            op->setVertices(vsp);
            op->setSubType(_cfg_prm.stnod);
            op->setName(_cfg_prm.name);
            if(report){
                set_net_flag(op,fields[_cfg_prm.tnod->index()-1],_kNodeCreated);
            }
            added.add(&op);
        }
        
        get_nodes(&vsa->vx.vx2[vsa->nv-1],nod);
        if(nod.count()==0){
            _cfg_prm.tnod->new_object(&op);
            vsp->vx.vx2[0]=vsa->vx.vx2[vsa->nv-1];
            op->setVertices(vsp);
            op->setSubType(_cfg_prm.stnod);
            op->setName(_cfg_prm.name);
            if(report){
                set_net_flag(op,fields[_cfg_prm.tnod->index()-1],_kNodeCreated);
            }
            added.add(&op);
        }
        
        oa->getBounds(&vxr);
        get_edges(&vxr,edg);
        for(long j=1;j<=edg.count();j++){
            edg.get(j,&ob);
            if(oa==ob){
                continue;
            }
            
            ob->getVertices(&vsb);
            for(long k=0;k<vsa->nv-1;k++){
                for(long l=0;l<vsb->nv-1;l++){
                    if(ivx2_sect(	&vsa->vx.vx2[k],
                                    &vsa->vx.vx2[k+1],
                                    &vsb->vx.vx2[l],
                                    &vsb->vx.vx2[l+1])){
                        ivx2_get_sect(	&vsa->vx.vx2[k],
                                        &vsa->vx.vx2[k+1],
                                        &vsb->vx.vx2[l],
                                        &vsb->vx.vx2[l+1],
                                        &vx);
                        
                        get_bridges(&vx,bdg);
                        if(bdg.count()>0){
                            continue;
                        }
                        get_nodes(&vx,nod);
                        if(nod.count()>0){
                            nod.get(1,&op);
                            added.add(&op);
                            continue;
                        }
                        _cfg_prm.tnod->new_object(&op);
                        vsp->vx.vx2[0]=vx;
                        op->setVertices(vsp);
                        op->setSubType(_cfg_prm.stnod);
                        op->setName(_cfg_prm.name);
                        if(report){
                            set_net_flag(op,fields[_cfg_prm.tnod->index()-1],_kNodeCreated);
                        }
                        added.add(&op);
                    }
                }
            }
        }
    }
    
    ivs_free(vsp);
    
    return(0);
}