Elise_Set_Of_Palette GlobPal(int aNbR,int aNbV,int aNbB,int aNbGray,int aNbCirc)
{
   Disc_Pal  Pdisc = Disc_Pal::PNCOL();
   Gray_Pal  Pgr (aNbGray);
   Circ_Pal  Pcirc = Circ_Pal::PCIRC6(aNbCirc);
   RGB_Pal   Prgb  (aNbR,aNbV,aNbB);
   Elise_Set_Of_Palette SOP(NewLElPal(Pdisc)+Elise_Palette(Pgr)+Elise_Palette(Prgb)+Elise_Palette(Pcirc));

   return SOP;
}
示例#2
0
文件: autoacts.c 项目: hiciu/ekg2
int irc_autorejoin(session_t *s, int when, char *chan) {
	irc_private_t *j;
	string_t st;
	window_t *w;
	char *chanprefix;
	int rejoin;

#if 1	/* there's no need of doing it, already checked by irc_onkick_handler() or if it goes through irc_c_init() it's even better. */
	if (!s || !(j = s->priv) || (s->plugin != &irc_plugin))
		return -1;
#endif
	chanprefix = SOP(_005_CHANTYPES);
	rejoin = session_int_get(s, "REJOIN");

	if (!(rejoin&(1<<(when))))
		return -1;

	switch (when) {
		case IRC_REJOIN_CONNECT:
			st = string_init(NULL);
			for (w = windows; w; w = w->next) {
				if (!w->target || w->session != s)			/* check if sessions match and has w->target */
					continue;

				if (valid_plugin_uid(s->plugin, w->target) != 1)	/* check if window is correct for irc: */
					continue;

				if (!xstrchr(chanprefix, (w->target)[4]))		/* check if this is channel.. */
					continue;

				if (st->len)
					string_append_c(st, ',');
				if ((w->target)[4] == '!') {
					string_append_c(st, '!');
					string_append(st, w->target + 10);
				} else {
					string_append(st, w->target + 4);
				}
			}
			if (st->len)
				irc_write(s, "JOIN %s\r\n", st->str);
			string_free(st, 1);
			break;

		case IRC_REJOIN_KICK:
			irc_write(s, "JOIN %s\r\n", chan);
			break;

		default:
			return -1;
	}
	return 0;
}
示例#3
0
文件: b_0_43.cpp 项目: jakexie/micmac
void bench_delaunay()
{
    Pt2di sz (950,950);

    Disc_Pal       Pdisc  = Disc_Pal::P8COL();

    Elise_Set_Of_Palette SOP(NewLElPal(Pdisc));
    Video_Display Ecr((char *) NULL);
    Ecr.load(SOP);                         
    Video_Win   W  (Ecr,SOP,Pt2di(50,50),sz);  


    for (INT nb = 100; nb < 500 ; nb +=50)
    {

       std::list<PtDelTest> L;
       ElFilo<PtDelTest> Pts;

       for (INT k= 0; k< nb; k++)
       {
           PtDelTest pt
                     (
                             (INT)(  10 + (sz.x -20) * NRrandom3()),
                             (INT)(  10 + (sz.y -20) * NRrandom3())
                     );
            // Pts.pushlast(pt);
            L.push_back(pt);
            //W.draw_circle_loc(pt.pt(),4,Pdisc(P8COL::red));
            W.draw_circle_loc(Pt2dr(pt.pt()),4,Pdisc(P8COL::red)); // __NEW
       }
       DelTestAct Act(W);
       Delaunay_Mediatrice 
       (
             L.begin(),
             L.end(),
             Pt_of_DPT,
             Act,
	     200.0,
            (PtDelTest *) 0
       );

       // W.clik_in();
       W.clear();
    }
}
示例#4
0
文件: regcomp.c 项目: OPSF/uClinux
/*
 - doemit - emit a strip operator
 *
 * It might seem better to implement this as a macro with a function as
 * hard-case backup, but it's just too big and messy unless there are
 * some changes to the data structures.  Maybe later.
 */
static void
doemit(struct parse *p, sop op, size_t opnd)
{
	/* avoid making error situations worse */
	if (p->error != 0)
		return;

	/* deal with oversize operands ("can't happen", more or less) */
	assert(opnd < 1<<OPSHIFT);

	/* deal with undersized strip */
	if (p->slen >= p->ssize)
		enlarge(p, (p->ssize+1) / 2 * 3);	/* +50% */
	assert(p->slen < p->ssize);

	/* finally, it's all reduced to the easy case */
	p->strip[p->slen++] = SOP(op, opnd);
}
Video_Win * Video_Win::PtrWStd(Pt2di sz,bool all_pal,const Pt2dr & aScale)
{
    Disc_Pal  Pdisc = Disc_Pal::PNCOL();
    Gray_Pal  Pgr (30);
    Circ_Pal  Pcirc = Circ_Pal::PCIRC6(30);
    RGB_Pal   Prgb  (2,2,2);
    Elise_Set_Of_Palette SOP(NewLElPal(Pdisc)+Elise_Palette(Pgr)+Elise_Palette(Prgb)+Elise_Palette(Pcirc));
    if (! all_pal)
        SOP = Elise_Set_Of_Palette (NewLElPal(Pdisc));

    Video_Display Ecr((char *) NULL);
    Ecr.load(SOP);
    Video_Win * aRes =  new Video_Win (Ecr,SOP,Pt2di(50,50),sz);

    aRes = aRes->PtrChc(Pt2dr(0,0),aScale);

    return aRes;
}
int CMP3::PlayMP3( const char *pszSong )
{
	if( m_iIsPlaying )
	{
	// sound system is already initialized
		SCL( m_Stream );
	} 
	else
	{
		SOP( FSOUND_OUTPUT_DSOUND );
		SBS( 200 );
		SDRV( 0 );
		INIT( 44100, 1, 0 ); // we need just one channel, multiple mp3s at a time would be, erm, strange...	
	}//AJH not for really cool effects, say walking past cars in a street playing different tunes, might change this later.

	char song[256];

	sprintf( song, "%s/%s", gEngfuncs.pfnGetGameDirectory(), pszSong);

	//gEngfuncs.Con_Printf("Using fmod.dll version %f\n",VER());

	if (SO)
	{
		m_Stream = SO( song, FSOUND_NORMAL | FSOUND_LOOP_NORMAL, 0 ,0); //AJH new version fmod uses Open
	}
	else if( SOF )
	{													
		m_Stream = SOF( song, FSOUND_NORMAL | FSOUND_LOOP_NORMAL, 1 ); //AJH old version fmod OpenFile
	}
	if(m_Stream)
	{
		SPLAY( 0, m_Stream );
		m_iIsPlaying = 1;
		return 1;
	}
	else
	{
		m_iIsPlaying = 0;
		gEngfuncs.Con_Printf("Error: Could not load %s\n",song);
		return 0;
	}
}
示例#7
0
void lena_for_ever()
{
    Video_Display Ecr((char *) NULL);
    Gray_Pal       Pgray  (30);
    Disc_Pal       Pdisc  = Disc_Pal::P8COL();
    Elise_Set_Of_Palette    SOP(newl(Pgray)+Pdisc);


    Ecr.load(SOP);

    Video_Win W (Ecr,SOP,Pt2di(50,50),Pt2di(SZX,SZY));
    Elise_File_Im FLena("../IM_ELISE/lena",2,SXY,GenIm::u_int1,1,0);
    Im2D_U_INT1 I(SZX,SZY);

    ELISE_COPY
    (
        W.all_pts(),
        FLena.in(),
        W.ogray() | I.out()
    );

    bench_dilate_simple(W,I);
    bench_zonec_simple(W,I);
}
execplan::ParseTree* ScalarSub::buildParseTree(PredicateOperator* op)
{
    idbassert(fColumn.get() && fSub && fFunc);

    vector<SRCP> cols;
    Filter* filter;
    RowColumn* rcol = dynamic_cast<RowColumn*>(fColumn.get());

    if (rcol)
    {
        // IDB only supports (c1,c2..) =/!= (subquery)
        if (fFunc->functype() != Item_func::EQ_FUNC && fFunc->functype() != Item_func::NE_FUNC)
        {
            fGwip.fatalParseError = true;
            fGwip.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_INVALID_OPERATOR_WITH_LIST);
            return NULL;
        }

        cols = rcol->columnVec();
    }
    else
        cols.push_back(fColumn);

    SCSEP csep(new CalpontSelectExecutionPlan());
    csep->sessionID(fGwip.sessionid);
    csep->location(CalpontSelectExecutionPlan::WHERE);
    csep->subType (CalpontSelectExecutionPlan::SINGLEROW_SUBS);

    // gwi for the sub query
    gp_walk_info gwi;
    gwi.thd = fGwip.thd;
    gwi.subQuery = this;

    // @4827 merge table list to gwi in case there is FROM sub to be referenced
    // in the FROM sub
    gwi.derivedTbCnt = fGwip.derivedTbList.size();
    uint32_t tbCnt = fGwip.tbList.size();

    gwi.tbList.insert(gwi.tbList.begin(), fGwip.tbList.begin(), fGwip.tbList.end());
    gwi.derivedTbList.insert(gwi.derivedTbList.begin(), fGwip.derivedTbList.begin(), fGwip.derivedTbList.end());

    if (getSelectPlan(gwi, *(fSub->get_select_lex()), csep) != 0)
    {
        //@todo more in error handling
        if (!gwi.fatalParseError)
        {
            fGwip.fatalParseError = true;
            fGwip.parseErrorText = "Error occured in ScalarSub::transform()";
        }
        else
        {
            fGwip.fatalParseError = gwi.fatalParseError;
            fGwip.parseErrorText = gwi.parseErrorText;
        }

        return NULL;
    }

    fGwip.subselectList.push_back(csep);

    // error out non-support case for now: comparison out of semi join tables.
    // only check for simplecolumn
    if (!gwi.correlatedTbNameVec.empty())
    {
        for (uint32_t i = 0; i < cols.size(); i++)
        {
            SimpleColumn* sc = dynamic_cast<SimpleColumn*>(cols[i].get());

            if (sc)
            {
                CalpontSystemCatalog::TableAliasName tan = make_aliastable(sc->schemaName(), sc->tableName(), sc->tableAlias());
                uint32_t j = 0;

                for (; j < gwi.correlatedTbNameVec.size(); j++)
                    if (tan == gwi.correlatedTbNameVec[j])
                        break;

                if (j == gwi.correlatedTbNameVec.size())
                {
                    fGwip.fatalParseError = true;
                    fGwip.parseErrorText = IDBErrorInfo::instance()->errorMsg(ERR_NON_SUPPORT_SCALAR);
                    return NULL;
                }
            }
        }
    }

    // remove outer query tables
    CalpontSelectExecutionPlan::TableList tblist;

    if (csep->tableList().size() >= tbCnt)
        tblist.insert(tblist.begin(), csep->tableList().begin() + tbCnt, csep->tableList().end());

    CalpontSelectExecutionPlan::SelectList derivedTbList;

    if (csep->derivedTableList().size() >= gwi.derivedTbCnt)
        derivedTbList.insert(derivedTbList.begin(), csep->derivedTableList().begin() + gwi.derivedTbCnt, csep->derivedTableList().end());

    csep->tableList(tblist);
    csep->derivedTableList(derivedTbList);

//	if (fSub->is_correlated)
    if (fSub->unit->first_select()->master_unit()->uncacheable)
    {
        SelectFilter* subFilter = new SelectFilter();
        subFilter->correlated(true);
        subFilter->cols(cols);
        subFilter->sub(csep);
        subFilter->op(SOP(op));
        subFilter->returnedColPos(fReturnedColPos);
        filter = subFilter;
    }
    else
    {
        SimpleScalarFilter* subFilter = new SimpleScalarFilter();
        subFilter->cols(cols);
        subFilter->sub(csep);
        subFilter->op(SOP(op));
        filter = subFilter;
    }

    return new ParseTree(filter);

}
示例#9
0
/*
 - backref - figure out what matched what, figuring in back references
 == static const char *backref(struct match *m, const char *start, \
 ==	const char *stop, sopno startst, sopno stopst, sopno lev);
 */
static const char *		/* == stop (success) or NULL (failure) */
backref(struct match *m,
	const char *start,
	const char *stop,
	sopno startst,
	sopno stopst,
	sopno lev,		/* PLUS nesting level */
	int rec)
{
	int i;
	sopno ss;		/* start sop of current subRE */
	const char *sp;		/* start of string matched by it */
	sopno ssub;		/* start sop of subsubRE */
	sopno esub;		/* end sop of subsubRE */
	const char *ssp;	/* start of string matched by subsubRE */
	const char *dp;
	size_t len;
	int hard;
	sop s;
	regoff_t offsave;
	cset *cs;
	wint_t wc;

	AT("back", start, stop, startst, stopst);
	sp = start;

	/* get as far as we can with easy stuff */
	hard = 0;
	for (ss = startst; !hard && ss < stopst; ss++)
		switch (OP(s = m->g->strip[ss])) {
		case OCHAR:
			if (sp == stop)
				return(NULL);
			sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR);
			if (wc != OPND(s))
				return(NULL);
			break;
		case OANY:
			if (sp == stop)
				return(NULL);
			sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR);
			if (wc == BADCHAR)
				return (NULL);
			break;
		case OANYOF:
			if (sp == stop)
				return (NULL);
			cs = &m->g->sets[OPND(s)];
			sp += XMBRTOWC(&wc, sp, stop - sp, &m->mbs, BADCHAR);
			if (wc == BADCHAR || !CHIN(cs, wc))
				return(NULL);
			break;
		case OBOL:
			if ( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
					(sp < m->endp && *(sp-1) == '\n' &&
						(m->g->cflags&REG_NEWLINE)) )
				{ /* yes */ }
			else
				return(NULL);
			break;
		case OEOL:
			if ( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
					(sp < m->endp && *sp == '\n' &&
						(m->g->cflags&REG_NEWLINE)) )
				{ /* yes */ }
			else
				return(NULL);
			break;
		case OBOW:
			if (( (sp == m->beginp && !(m->eflags&REG_NOTBOL)) ||
					(sp < m->endp && *(sp-1) == '\n' &&
						(m->g->cflags&REG_NEWLINE)) ||
					(sp > m->beginp &&
							!ISWORD(*(sp-1))) ) &&
					(sp < m->endp && ISWORD(*sp)) )
				{ /* yes */ }
			else
				return(NULL);
			break;
		case OEOW:
			if (( (sp == m->endp && !(m->eflags&REG_NOTEOL)) ||
					(sp < m->endp && *sp == '\n' &&
						(m->g->cflags&REG_NEWLINE)) ||
					(sp < m->endp && !ISWORD(*sp)) ) &&
					(sp > m->beginp && ISWORD(*(sp-1))) )
				{ /* yes */ }
			else
				return(NULL);
			break;
		case O_QUEST:
			break;
		case OOR1:	/* matches null but needs to skip */
			ss++;
			s = m->g->strip[ss];
			do {
				assert(OP(s) == OOR2);
				ss += OPND(s);
			} while (OP(s = m->g->strip[ss]) != O_CH);
			/* note that the ss++ gets us past the O_CH */
			break;
		default:	/* have to make a choice */
			hard = 1;
			break;
		}
	if (!hard) {		/* that was it! */
		if (sp != stop)
			return(NULL);
		return(sp);
	}
	ss--;			/* adjust for the for's final increment */

	/* the hard stuff */
	AT("hard", sp, stop, ss, stopst);
	s = m->g->strip[ss];
	switch (OP(s)) {
	case OBACK_:		/* the vilest depths */
		i = OPND(s);
		assert(0 < i && i <= m->g->nsub);
		if (m->pmatch[i].rm_eo == -1)
			return(NULL);
		assert(m->pmatch[i].rm_so != -1);
		len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so;
		if (len == 0 && rec++ > MAX_RECURSION)
			return(NULL);
		assert(stop - m->beginp >= len);
		if (sp > stop - len)
			return(NULL);	/* not enough left to match */
		ssp = m->offp + m->pmatch[i].rm_so;
		if (memcmp(sp, ssp, len) != 0)
			return(NULL);
		while (m->g->strip[ss] != SOP(O_BACK, i))
			ss++;
		return(backref(m, sp+len, stop, ss+1, stopst, lev, rec));
		break;
	case OQUEST_:		/* to null or not */
		dp = backref(m, sp, stop, ss+1, stopst, lev, rec);
		if (dp != NULL)
			return(dp);	/* not */
		return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev, rec));
		break;
	case OPLUS_:
		assert(m->lastpos != NULL);
		assert(lev+1 <= m->g->nplus);
		m->lastpos[lev+1] = sp;
		return(backref(m, sp, stop, ss+1, stopst, lev+1, rec));
		break;
	case O_PLUS:
		if (sp == m->lastpos[lev])	/* last pass matched null */
			return(backref(m, sp, stop, ss+1, stopst, lev-1, rec));
		/* try another pass */
		m->lastpos[lev] = sp;
		dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev, rec);
		if (dp == NULL)
			return(backref(m, sp, stop, ss+1, stopst, lev-1, rec));
		else
			return(dp);
		break;
	case OCH_:		/* find the right one, if any */
		ssub = ss + 1;
		esub = ss + OPND(s) - 1;
		assert(OP(m->g->strip[esub]) == OOR1);
		for (;;) {	/* find first matching branch */
			dp = backref(m, sp, stop, ssub, esub, lev, rec);
			if (dp != NULL)
				return(dp);
			/* that one missed, try next one */
			if (OP(m->g->strip[esub]) == O_CH)
				return(NULL);	/* there is none */
			esub++;
			assert(OP(m->g->strip[esub]) == OOR2);
			ssub = esub + 1;
			esub += OPND(m->g->strip[esub]);
			if (OP(m->g->strip[esub]) == OOR2)
				esub--;
			else
				assert(OP(m->g->strip[esub]) == O_CH);
		}
		break;
	case OLPAREN:		/* must undo assignment if rest fails */
		i = OPND(s);
		assert(0 < i && i <= m->g->nsub);
		offsave = m->pmatch[i].rm_so;
		m->pmatch[i].rm_so = sp - m->offp;
		dp = backref(m, sp, stop, ss+1, stopst, lev, rec);
		if (dp != NULL)
			return(dp);
		m->pmatch[i].rm_so = offsave;
		return(NULL);
		break;
	case ORPAREN:		/* must undo assignment if rest fails */
		i = OPND(s);
		assert(0 < i && i <= m->g->nsub);
		offsave = m->pmatch[i].rm_eo;
		m->pmatch[i].rm_eo = sp - m->offp;
		dp = backref(m, sp, stop, ss+1, stopst, lev, rec);
		if (dp != NULL)
			return(dp);
		m->pmatch[i].rm_eo = offsave;
		return(NULL);
		break;
	default:		/* uh oh */
		assert(nope);
		break;
	}

	/* "can't happen" */
	assert(nope);
	/* NOTREACHED */
	return "shut up gcc";
}
示例#10
0
void lena_for_ever()
{

    Gray_Pal       Pgray  (30);
    Disc_Pal       Pdisc  = Disc_Pal::P8COL();

    Elise_Set_Of_Palette SOP(newl(Pgray)+Pdisc);
    Video_Display Ecr((char *) NULL);
    Ecr.load(SOP);

    Video_Win   Wv  (Ecr,SOP,Pt2di(50,50),Pt2di(SZX,SZY));


    PS_Display disp("TMP/test.ps","Mon beau fichier ps",SOP);

    Pt2di NBW(4,20);
    Pt2di sz(200,100);
    Mat_PS_Window mps(disp,sz,Pt2dr(2.0,2.0),NBW,Pt2dr(0.5,0.1));

    for (int x = 0; x < NBW.x ; x++)
        for (int y = 0; y < NBW.y ; y++)
        {
            mps(x,y).fill_rect(Pt2di(0,0),sz,Pgray((y*255)/( NBW.y-1)));
            mps(x,y).draw_rect(Pt2di(0,0),sz,Pdisc(P8COL::red));
        }
/*
    PS_Window  Wps = disp.w_centered_max(Pt2di(SZX,SZY),Pt2dr(0.0,8.0));


    Elise_File_Im FLena("../IM_ELISE/lena",Pt2di(SZX,SZY),GenIm::u_int1);
    Im2D_U_INT1 I(SZX,SZY);



    Col_Pal        red    = Pdisc(P8COL::red);
    Col_Pal        blue   = Pdisc(P8COL::blue);
    Col_Pal        green  = Pdisc(P8COL::green);
    Col_Pal        black  = Pdisc(P8COL::black);
    Col_Pal        cyan   = Pdisc(P8COL::cyan);
    Col_Pal        white  = Pdisc(P8COL::white);
    Col_Pal        yellow  = Pdisc(P8COL::yellow);


    El_Window W = Wv|Wps;

    ELISE_COPY
    (
       Wps.all_pts(),
       32*(FLena.in()/32),
       W.ogray()|I.out()
    );
    W.fill_rect(Pt2dr(100,200),Pt2dr(400,300),yellow);


    Line_St s1     (red,3);
    Line_St s2     (green,2);

    Plot_1d  Plot1  (W,s1,s2,Interval(-10,10),newl(PlBox(50,50,300,400)));


    Plot1.show_axes();

    Plot1.show_axes
    (
              newl(PlBox(150,150,250,250)) + PlOriY(0.2)
            + PlAxeSty(s2)
    );


    Plot_1d  Plot2(W,s1,s2,Interval(-100,100));


    Plot1.show_box
    (
            newl(PlBox(150,150,250,250))  + PlBoxSty(cyan,2)
    );


    Plot2.set
    (
              newl(PlBox(20,200,400,400)) 
            + PlOriY(0.4)
            + PlAxeSty(Line_St(Pdisc(P8COL::yellow),1))
            + PlBoxSty(Line_St(black,2))
            + PlClearSty(white)
    );
    Plot2.show_axes();
    Plot2.show_box();


    Plot2.plot(10*sin(FX/4.0));

    Plot2.plot
    (
         10*sin(FX/4.0),
            newl(PlIntervBoxX(-50,50))
         +  PlotLinSty(red,2) 
    );

    Plot2.plot
    (
         10*sin(FX/4.0),
           newl( PlotLinSty(blue,2) )
         + PlIntervPlotX(-30,70)
         + PlAutoScalY(true)
         + PlShAxes(true)
         + PlAxeSty(cyan,3)
    );

    
    Plot2.plot
    (
         10*(1.2+sin(FX/4.0)),
           newl( PlotLinSty(red,2) )
         + PlAutoScalOriY(true)
         + PlShAxes(true)
         + PlAxeSty(cyan,2)
         + PlAutoClear(true)
    );



    Plot2.clear(newl(PlClearSty(Pgray(196))));

    Plot2.plot
    ( 
         50*cos(FX/9.0),
         newl(PlotLinSty(Pdisc(P8COL::red)))
       + PlClipY(false) + PlStepX(1.0)
    );


    Plot2.plot
    (
         70*sin(square(FX) / 500.0),
         newl(PlotLinSty(Pdisc(P8COL::blue)))
       + PlClipY(true) + PlStepX(0.15)
    );
    
    
    Plot2.set ( newl(PlBox(20,0,400,200)) );
    Plot2.set(newl(PlIntervBoxX(-20,20)));
    Plot2.clear();

    Plot2.plot
    (
         10 * cos(FX/4.0),
         newl(PlotFilSty(green))
        + PlClipY(false)
        + PlModePl(Plots::fill_box)
    );

     Plot2.plot
     (
         10 * cos(FX/4.0),
         newl(PlotFilSty(red))
        + PlClipY(true)
        + PlModePl(Plots::fill_box)
     );



     Plot2.plot
     (
         10 * cos(FX/4.0),
         newl(PlotLinSty(black,2))
        + PlClipY(true)
        + PlModePl(Plots::draw_box)
        + PlShAxes(true)
        + PlAxeSty(Line_St(Pdisc(P8COL::blue),2))
     );

cout << "aaaaaaaaaa\n";

getchar();
*/
}