Quaternion searchline(Quaternion front,Quaternion back) { Quaternion t=front-back; if (t.mod()<smallest) return back; Quaternion mid=(front+back)/2.0; // if (mid.c>forget) // return Quaternion(0,0,forget,0); if (julquat(mid)==0) return searchline(front,mid); else return searchline(mid,back); }
V3d searchline(V3d front,V3d back,bool wanted) { V3d t,mid; t=(front-back); if (t.mod()<smallest) return back; mid=((front+back)/2.0); // if (mid.c>forget) // return Quaternion(0,0,forget,0); if ((getpotentialfor(mid)<lessthan)==wanted) return searchline(front,mid,wanted); else return searchline(mid,back,wanted); }
void CscopeTab::DoItemActivated(const wxDataViewItem& item ) { CscopeTabClientData *data = dynamic_cast<CscopeTabClientData*>(m_dataviewModel->GetClientObject(item)); if (data) { wxString wsp_path = clCxxWorkspaceST::Get()->GetPrivateFolder(); //a single entry was activated, open the file //convert the file path to absolut path. We do it here, to improve performance wxFileName fn(data->GetEntry().GetFile()); if ( !fn.MakeAbsolute(wsp_path) ) { wxLogMessage(wxT("failed to convert file to absolute path")); } if(m_mgr->OpenFile(fn.GetFullPath(), wxEmptyString, data->GetEntry().GetLine()-1)) { IEditor *editor = m_mgr->GetActiveEditor(); if( editor && editor->GetFileName().GetFullPath() == fn.GetFullPath() && !GetFindWhat().IsEmpty()) { // We can't use data->GetEntry().GetPattern() as the line to search for as any appended comments have been truncated // For some reason LEditor::DoFindAndSelect checks it against the whole current line // and won't believe a match unless their lengths are the same int line = data->GetEntry().GetLine() - 1; int start = editor->PosFromLine(line); // PosFromLine() returns the line start position int end = editor->LineEnd(line); wxString searchline(editor->GetTextRange(start, end)); // Find and select the entry in the file editor->FindAndSelectV(searchline, GetFindWhat(), start); // The async version of FindAndSelect() editor->DelayedSetActive(); // We need to SetActive() editor. At least in wxGTK, this won't work synchronously } } } else { // Parent item, expand it m_dataview->Expand( item ); } }
float getdepth(int i,int j) { // printf("gd\n"); if (!rend->inmap(i,j)) return back; if (rend->pos[i][j]==crazy) { // Shoot ray into image V3d near=V3d((i-scrhei/2)*2.0/scrhei,(j-scrhei/2)*2.0/scrhei,-2); V3d far=V3d(near.x*2.0,near.y*2.0,2.0); rend->pos[i][j]=back; V3d next,last=near; bool lastin=(getpotentialfor(near)<lessthan); for (int k=1;k<steps;k++) { float dk=(float)k/(float)steps; next=near*(1.0-dk)+far*dk; if ((getpotentialfor(next)<lessthan)!=lastin) { rend->pos[i][j]=searchline(last,next,!lastin).z; break; } last=next; } } return rend->pos[i][j]; }
void main() { int scrwid=320; int scrhei=200; int indent=(scrwid-scrhei)/2; float cenx=0; float ceny=0; float wid=1.0; float hei=1.0; float left=cenx-wid; float right=cenx+wid; float top=ceny-hei; float bottom=ceny+hei; float front=-1.0; float back=1.0; float scale=2.0/(2.0*front); float crazy=0.1234567; int steps=1000; int jump=1; JBmp *b=new JBmp(scrwid,scrhei); allegrosetup(scrwid,scrhei); makepalette(&greypalette); _farsetsel(screen->seg); randomise(); Map2d<float> *map=new Map2d<float>(scrhei,scrhei); current=*new Quaternion(floatrnd(-.5,.5),floatrnd(-.5,.5),floatrnd(-.5,.5),floatrnd(-.5,.5)); do { current=current*Quaternion(0.99,0,0,0)+Quaternion(floatrnd(-.05,.05),floatrnd(-.05,.05),floatrnd(-.05,.05),floatrnd(-.05,.05)); float dslice=floatrnd(-.3,.3); current=*new Quaternion(floatrnd(-.5,.5),floatrnd(-.5,.5),floatrnd(-.5,.5),floatrnd(-.5,.5)); current=*new Quaternion(-0.488193901,0.572800587,0,0); for (int i=0;i<scrhei;i+=jump) { for (int j=0;j<scrhei;j+=jump) { // b->setpixelud(indent+i,j,255); // b->writetoscreen(); int col=0; V3d tmpnear=V3d(left+2.0*wid*i/(float)scrhei,top+2.0*hei*j/(float)scrhei,front); V3d tmpfar=V3d(tmpnear.x*2.0,tmpnear.y*2.0,back); tmpnear=V3d::rotate(tmpnear,V3d(0,1,0),rotation); tmpfar=V3d::rotate(tmpfar,V3d(0,1,0),rotation); tmpnear=V3d::rotate(tmpnear,V3d(1,0,0),elevation); tmpfar=V3d::rotate(tmpfar,V3d(1,0,0),elevation); Quaternion near=Quaternion(tmpnear.x,tmpnear.y,tmpnear.z,dslice); Quaternion far=Quaternion(tmpfar.x,tmpfar.y,tmpfar.z,dslice); map->pos[i][j]=crazy; Quaternion last=near-(far-near); for (int k=0;k<steps;k++) { float dk=(float)k/(float)steps; Quaternion next=near*(1.0-dk)+far*dk; if (julquat(next)==0) { Quaternion res=searchline(last,next); // col=255.0*(1.0-(res.c-front)/(forget-front)); map->pos[i][j]=res.c; break; } last=next; } if (i>=jump && j>=jump) { if (map->pos[i-jump][j-jump]==crazy || map->pos[i-jump][j]==crazy || map->pos[i][j-jump]==crazy) col=0; else { float diff=2.0*map->pos[i-jump][j-jump]-map->pos[i-jump][j]-map->pos[i][j-jump]; col=chop(128.0+diff*1600.0,0,255); } for (int x=0;x<jump;x++) { for (int y=0;y<jump;y++) { b->setpixel(indent+i+x,j+y,col); } } } if (key[KEY_SPACE]) exit(0); } b->writetoscreen(); } PALETTE pal; get_palette(pal); save_bitmap(getnextfilename("bmp"),screen,pal); } while (!key[KEY_SPACE]); allegro_exit(); }
int searchfwd( unsigned int *p_xCursorPos, unsigned int *y_CursorPos ) { struct line_node *savepage, *templine; boolean enlargeflag; unsigned int linecount; unsigned int savecol; unsigned int startpos; size_t i; font_attr font = NORMALATTR; char *foundpoint; char *addr; savecol = firstcol; savepage = curpage; storeline( curline ); templine = curpage; linecount = wind.width - 1; while ( templine != curline ) { linecount--; templine = templine->next; } startpos = linearcolumn( curline->text, *p_xCursorPos + firstcol, &font ); foundpoint = NULL; while ( ( foundpoint == NULL ) && ( curline != sentinel ) ) { foundpoint = searchline( curline->text, startpos ); if ( foundpoint != NULL ) { /* found */ while ( ( *y_CursorPos = findrow( ) ) >= wind.width ) { curpage = curpage->next; } *p_xCursorPos = 0; firstcol = 0; addr = curline->text; enlargeflag = NO; while ( addr != foundpoint ) { if ( ( whatlevel( *addr ) == MIDDLE ) && ( *addr >= 32 ) ) { if ( enlargeflag ) { ( *p_xCursorPos )++; } ( *p_xCursorPos )++; } else { if ( *addr == ENLARGECODE ) { enlargeflag = enlargeflag ^ 1; } } addr++; } for ( i = 0; source[i] != '\0'; i++ ) { if ( whatlevel( source[i] ) == MIDDLE ) { if ( enlargeflag ) { ( *p_xCursorPos )++; } ( *p_xCursorPos )++; } } while ( *p_xCursorPos >= wind.length ) { firstcol = firstcol + wind.length; *p_xCursorPos = *p_xCursorPos - wind.length; } } else { if ( linecount > 0 ) { linecount--; curline = curline->next; lineno++; } else { curline = curline->next; lineno++; curpage = curline; linecount = wind.width - 1; } startpos = 0; } } if ( foundpoint == NULL ) { curline = sentinel->previous; curpage = curline; loadtoline( curline->text ); endline( p_xCursorPos ); } loadtoline( curline->text ); if ( savepage != curpage ) { showpageall( ); } else { if ( firstcol != savecol ) { showpageall( ); } } if ( foundpoint != NULL ) { return( YES ); } else { return( NO ); } }
void main() { allegrosetup(scrwid,scrhei); makepalette(&greypalette); _farsetsel(screen->seg); PALETTE pal; get_palette(pal); randomise(0.456); for (int i=0;i<20;i++) { float amp=0; S s=S(V3d::randomvolume(1),radfromamp(amp),0); S v=S(V3d(0,0,0),0,0); xs+s; xvs+v; } for (int rndloop=0;rndloop<100;rndloop++) { for (int i=0;i<20;i++) { S *v=xvs.p2num(i); S *x=xs.p2num(i); domovement(v,x); } } do { for (int i=scrhei/3;i<scrhei;i+=jump) { for (int j=0;j<scrhei;j+=jump) { // Shoot ray into image // V3d displace=Quaternion(cenx,ceny,0,0); V3d near=V3d((i-scrwid/2)*2.0/scrhei,(j-scrhei/2)*2.0/scrhei,-2); V3d far=V3d(near.x*2.0,near.y*2.0,2.0); rend->pos[i][j]=back; V3d next,last=near; bool lastin=(getpotentialfor(near)<lessthan); for (int k=1;k<steps;k++) { float dk=(float)k/(float)steps; next=near*(1.0-dk)+far*dk; if ((getpotentialfor(next)<lessthan)!=lastin) { rend->pos[i][j]=searchline(last,next,!lastin).z; break; } last=next; } render(i,j); if (key[KEY_SPACE]) exit(0); } b->writetoscreen(); } for (int i=1;i<=xs.len;i++) { S *v=xvs.p2num(i); S *x=xs.p2num(i); domovement(v,x); } b->writefile(getnextfilename("bmp")); } while (!key[KEY_ESC]); }