/*! Wrapper for QPainter::drawText() */ void QwtPainter::drawText(QPainter *painter, int x, int y, const QString &text) { drawText(painter, QPoint(x, y), text); }
// Build world frame list void COpenGlDisplay::buildWorldFrameList(void) { worldFrameList = glGenLists(1); if (0 == worldFrameList) { return; } float axis_length = 2.0f; float axis_width = 1.5f; float text_scale = 0.6; glNewList(worldFrameList, GL_COMPILE); // Generate show list glPushMatrix(); glColor3f(205./255., 186./255., 250./255.); glLineWidth(axis_width); // Draw x axis glBegin(GL_LINES); glVertex3f(0,0,0); glVertex3f(axis_length,0,0); glEnd(); glPushMatrix(); glTranslatef(axis_length, 0.0f, 0.0f); drawText("X", text_scale); glPopMatrix(); glPushMatrix(); glTranslatef(axis_length, 0.0f, 0.0f); glRotatef(90.0f, 0.0f, 1.0f, 0.0f); glutSolidCone(axis_length*0.02, axis_length*0.05, 100,100); // Draw coordinate arrow glPopMatrix(); // Draw y axis glBegin(GL_LINES); glVertex3f(0,0,0); glVertex3f(0,axis_length,0); glEnd(); glPushMatrix(); glTranslatef(0.0f, axis_length, 0.0f); drawText("Y", text_scale); glPopMatrix(); glPushMatrix(); glTranslatef(0.0f, axis_length, 0.0f); glRotatef(-90.0f, 1.0f, 0.0f, 0.0f); glutSolidCone(axis_length*0.02, axis_length*0.05, 100,100); // Draw coordinate arrow glPopMatrix(); // Draw z axis glBegin(GL_LINES); glVertex3f(0,0,0); glVertex3f(0,0,axis_length); glEnd(); glPushMatrix(); glTranslatef(0.0f, 0.0f, axis_length); glRotatef(90, 1, 0, 0); drawText("Z", text_scale); glPopMatrix(); glPushMatrix(); glTranslatef(0.0f, 0.0f, axis_length); glutSolidCone(axis_length*0.02, axis_length*0.05, 100,100); // Draw coordinate arrow glPopMatrix(); glPopMatrix(); glEndList(); }
void compareThree(TTree* t1, TTree* t2, TTree* t3, TString var, int nBins, double xMin, double xMax, TCut cut1, TCut cut2,TCut cut3, const string cap) { SetHistTitleStyle(); SetyjPadStyle(); gStyle->SetOptStat(0); TH1::SetDefaultSumw2(); static int j = 1; TCanvas* c =new TCanvas(Form("c_%s_%d",var.Data(),j),"", 400,400); //c->Divide(1,2); //c->cd(1); gPad->SetLogy(); double ptbin[] = {60,70,80,90,100,110,120,130,140,150,170,200,250}; int nptbin = sizeof(ptbin)/sizeof(double) -1; TH1D* h[3]; //if(var=="phoEt") h[0] = new TH1D(Form("h1_%s_%d",var.Data(),j), Form(";%s;",var.Data()),nptbin, ptbin); //else h[0] = new TH1D(Form("h1_%s_%d",var.Data(),j), Form(";%s;",var.Data()), nBins,xMin,xMax); h[0] = new TH1D(Form("h1_%s_%d",var.Data(),j), Form(";%s;",var.Data()), nBins,xMin,xMax); h[1] = (TH1D*)h[0]->Clone(Form("h2_%s_%d",var.Data(),j)); h[2] = (TH1D*)h[0]->Clone(Form("h3_%s_%d",var.Data(),j)); for(int i=0;i<3;i++){ h[i]->Sumw2(); h[i]->SetMarkerStyle(20); h[i]->SetMarkerSize(0.8); h[i]->SetMarkerColor(i+1); h[i]->SetLineColor(i+1); } t1->Draw(Form("%s>>%s",var.Data(),h[0]->GetName()), cut1); t2->Draw(Form("%s>>%s",var.Data(),h[1]->GetName()), cut2); t3->Draw(Form("%s>>%s",var.Data(),h[2]->GetName()), cut3); for(int i=0;i<3;i++){ h[i]->Scale( 1. / h[i]->Integral()); h[i]->SetAxisRange(1e-6,1.0,"Y"); //h[i]->Scale( 1. / h[i]->Integral(),"width"); if(var=="pho_ecalClusterIsoR4+pho_hcalRechitIsoR4+pho_trackIsoR4PtCut20") h[i]->SetTitle(Form(";%s;","sumIsoR4")); else if(var=="pfpIso4+pfnIso4+pfcIso4") h[i]->SetTitle(Form(";%s;","pfSumIsoR4")); else if(var=="pfpVsIso4+pfnVsIso4+pfcVsIso4") h[i]->SetTitle(Form(";%s;","pfVsSumIsoR4")); else if(var=="pfpVsIso4th1+pfnVsIso4th1+pfcVsIso4th1") h[i]->SetTitle(Form(";%s;","pfVsSumIsoR4th1")); else if(var=="pfpVsIso4th2+pfnVsIso4th2+pfcVsIso4th2") h[i]->SetTitle(Form(";%s;","pfVsSumIsoR4th2")); } h[0]->DrawCopy("hist e"); h[1]->DrawCopy("hist e same"); h[2]->DrawCopy("hist e same"); TLegend* l1 = new TLegend(0.65,0.75,0.95,0.9); legStyle(l1); l1->AddEntry(h[0],"DATA","p"); l1->AddEntry(h[1],"AllQCDPhoton","pl"); l1->AddEntry(h[2],"EmEnrichedDijet","pl"); l1->Draw(); drawText(cap.data(),0.2,0.2); c-> SaveAs(Form("pdf/isolationComparison_%s_%s_noHotspot_addMomPID_v2.pdf",var.Data(),cap.data())); j++; /* * c->cd(2); h1->Divide(h2); h1->SetYTitle("DATA / MC"); double ratioRange = getCleverRange(h1); if(ratioRange > 5) h1->SetAxisRange(0,5,"Y"); else h1->SetAxisRange(0,2,"Y"); h1->DrawCopy("le1"); jumSun(xMin,1,xMax,1); i++; */ }
void drawTrkCorrEtavCent( TString outdir="fig/06.19_TrkMt" ) { TString mod="hitrkEffAnalyzer_MergedGeneral"; // TString mod="hitrkEffAnalyzer_Selected"; // TString mod="hitrkEffAnalyzer_GeneralCalo"; // TString mod="hitrkEffAnalyzer_PixTrk"; // TString mod="hitrkEffAnalyzer_MergeTrk"; float xmin=-2.4,xmax=2.4; TString title="Iterative Tracking"; if (mod.Contains("Pix")) { title="Pixel Tracks"; } else if (mod.Contains("Calo")) { title="Iter. Calo Tracks"; } TrackingCorrections trkCorr("itertrkpixtrk",mod); // trkCorr.AddSample("../trkcorr/itertrkpixtrk/trkcorr_hy18dj30_v1.root",30); // trkCorr.AddSample("../trkcorr/itertrkpixtrk/trkcorr_hy18dj50_v1.root",50); // trkCorr.AddSample("../trkcorr/itertrkpixtrk/trkcorr_hy18dj80_v1.root",80); // trkCorr.AddSample("../trkcorr/itertrkpixtrk/trkcorr_hy18dj120_v1.root",120); // trkCorr.AddSample("../trkcorr/itertrkpixtrk/trkcorr_hy18dj200_v1.root",200); // trkCorr.AddSample("../trkcorr/itertrkpixtrk_hgt/trkcorr_hy18dj50_iterTrkPixTrk_v1_full.root",50); // trkCorr.AddSample("../trkcorr/itertrkpixtrk_hgt/trkcorr_hy18dj120_iterTrkPixTrk_v1_full.root",120); // trkCorr.AddSample("../trkcorr/itertrkpixtrk_hgt/trkcorr_hy18dj170_iterTrkPixTrk_v1_full.root",170); // trkCorr.AddSample("../trkcorr/itertrkpixtrk_hgt/trkcorr_hy18dj200_iterTrkPixTrk_v1_full.root",200); trkCorr.AddSample("../trkcorr/Forest2_v19/trkcorr_hy18dj30_Forest2_v19.root",30); trkCorr.AddSample("../trkcorr/Forest2_v19/trkcorr_hy18dj50_Forest2_v19.root",50); trkCorr.AddSample("../trkcorr/Forest2_v19/trkcorr_hy18dj80_Forest2_v19.root",80); trkCorr.AddSample("../trkcorr/Forest2_v19/trkcorr_hy18dj120_Forest2_v19.root",120); trkCorr.AddSample("../trkcorr/Forest2_v19/trkcorr_hy18dj170_Forest2_v19.root",170); trkCorr.smoothLevel_ = 1; trkCorr.Init(); cout << endl << "========= plot =========" << endl; Float_t trkPtMin=1; Int_t trkBegBin = trkCorr.ptBin_->FindBin(trkPtMin); Int_t trkEndBin = trkCorr.numPtBins_; cout << Form("trk pt > %.0f bin: ",trkPtMin) << trkBegBin << " to " << trkEndBin << endl; Float_t jetPtMin=0; Int_t jetBegBin = trkCorr.jetBin_->FindBin(jetPtMin); Int_t jetEndBin = trkCorr.numJEtBins_; cout << Form("jet pt %.0f bin: ",jetPtMin) << jetBegBin << " to " << jetEndBin << endl; cout << "========================" << endl; // Get Eff/fake histograms TH1D * vhCorrPtRef[2][5], *vhCorrPt[2][5]; Int_t colors[10] = {kBlack,kRed,kYellow+2,kGreen+2,kBlue}; Int_t styles[2] = {kFullCircle,kOpenCircle}; for (Int_t lv=0; lv<2; ++lv) { for (Int_t c=0; c<5; ++c) { vhCorrPt[lv][c] = (TH1D*) trkCorr.InspectCorr(lv,c,c,jetBegBin,jetEndBin,1,trkBegBin,trkEndBin); vhCorrPt[lv][c]->SetMarkerColor(colors[c]); vhCorrPt[lv][c]->SetMarkerStyle(styles[lv]); handsomeTH1(vhCorrPt[lv][c]); } } TCanvas * cEff = new TCanvas("cEff","cEff",500,500); vhCorrPt[0][0]->SetAxisRange(xmin,xmax,"X"); vhCorrPt[0][0]->SetAxisRange(0,1,"Y"); vhCorrPt[0][0]->SetTitle(";Track #eta;A #times #epsilon"); vhCorrPt[0][0]->SetTitleOffset(1.2); vhCorrPt[0][0]->SetTitleSize(0.055); vhCorrPt[0][0]->Draw("E"); vhCorrPt[1][0]->Draw("sameE"); for (Int_t lv=0; lv<2; ++lv) { for (Int_t c=4; c>=0; --c) { vhCorrPt[lv][c]->Draw("sameE"); } } TLegend *leg0 = new TLegend(0.16,0.786,0.46,0.92); leg0->SetFillStyle(0); leg0->SetBorderSize(0); leg0->SetTextSize(0.04); leg0->AddEntry(vhCorrPt[0][0],"PYTHIA+HYDJET",""); if (jetPtMin >= 40) leg0->AddEntry(vhCorrPt[0][0],Form("Jet p_{T} #geq %.0f GeV/c",jetPtMin),""); leg0->AddEntry(vhCorrPt[0][0],Form("Track p_{T} > %.1f",trkCorr.ptBin_->GetBinLowEdge(trkBegBin)),""); leg0->Draw(); // TLine * l = new TLine(xmin,1,xmax,1); // l->SetLineStyle(2); // l->Draw(); TLegend *leg = new TLegend(0.39,0.22,0.61,0.52); leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetTextSize(0.035); leg->AddEntry(vhCorrPt[0][0],title,""); leg->AddEntry(vhCorrPt[0][0],"0-5%","p"); leg->AddEntry(vhCorrPt[0][1],"5-10%","p"); leg->AddEntry(vhCorrPt[0][2],"10-20%","p"); leg->AddEntry(vhCorrPt[0][3],"30-50%","p"); leg->AddEntry(vhCorrPt[0][4],"50-90%","p"); leg->Draw(); drawText("CMS Simulation",0.64,0.89); drawText("Fake Rate",0.69,0.26); cEff->Print(mod+Form("_vs_Eta_vsCentrality_jet%.0f_pt%.0f.gif",jetPtMin,trkPtMin)); cEff->Print(mod+Form("_vs_Eta_vsCentrality_jet%.0f_pt%.0f.pdf",jetPtMin,trkPtMin)); }
void JSInsObj::draw(JGraphics g, int x, int y, int w, int h) { JRect rect(x, y, w, h); drawText(g, JString("Ins"), rect); }
void picPunto::processFilePic(QFile* file) { // QString outname, sep; QString sep = " "; QString::SplitBehavior skip = QString::KeepEmptyParts; QStringList data; QString cmd; pointData *pd; while (!file->atEnd()) { int i = 2; QString line = file->readLine(); line.remove ( line.size()-1, 1); // printf("process line: %s\n",line.toStdString().c_str() ); data = line.split(sep, skip); if (data.size() < 4 ) continue; cmd = data.at(0); if (cmd == "line" ) { if (data.at(2) == "from"){ i++; // dashed line } for (;i < data.size(); i += 2) { pd = new pointData; pd->x = data.at(i).split(',').at(0); pd->y = data.at(i).split(',').at(1); dataList.append(pd); if ( i < data.size()-1 and data.at(i+1) != "to") { QMessageBox::critical ( this, "picPunto", QString(tr("format error in %1")).arg(line) ); return; } } if (dataList.size() > 0 ) drawLine(); } else { if (cmd == "circle") { // circle at 7.935,3.643 rad 0.035 if ( data.size() != 5 ) { QMessageBox::critical ( this, "picPunto", QString(tr("format error in %1")).arg(line) ); return; } drawCircle(data.at(2).split(',').at(0), data.at(2).split(',').at(1), data.at(4)); } else { if (cmd == "box") { // box invis fill 0.000 with .sw at (7.480,6.917) width 0.079 height 0.157 if ( data.size() < 11 ) { // QMessageBox::critical ( this, "picPunto", QString(tr("format error in %1")).arg(line) ); continue; } QString posx = data.at(7).split(',').at(0); QString posy = data.at(7).split(',').at(1); drawBox(posx.remove(0,1), posy.remove(posy.size()-1,1), data.at(9), data.at(11)); } else { if ( cmd.startsWith("\"\\s") and data.size() > 3 ) { // "\s5\fRAbstell fläche\fP" at 8.132,7.456 ljust QString txt = line.split("\"", skip).at(1); QStringList rline = line.split("\"", skip).at(2).split(" ",skip); txt.remove ( txt.size()-3, 3); txt.remove (QRegExp("^.*fR")); // printf("process line: %s: %s\n",rline.at(2).toStdString().c_str(),txt.toStdString().c_str() ); drawText(rline.at(2).split(',').at(0), rline.at(2).split(',').at(1), txt, rline.at(3)); } } } } } }
THFontDrawArea THBitmapFont::drawTextWrapped(THRenderTarget* pCanvas, const char* sMessage, size_t iMessageLength, int iX, int iY, int iWidth, int iMaxRows, int iSkipRows, eTHAlign eAlign) const { THFontDrawArea oDrawArea = {}; int iSkippedRows = 0; if(iMessageLength != 0 && m_pSpriteSheet != nullptr) { const unsigned int iFirstASCII = 31; unsigned int iLastASCII = static_cast<unsigned int>(m_pSpriteSheet->getSpriteCount()) + iFirstASCII; const char* sMessageEnd = sMessage + iMessageLength; while(sMessage != sMessageEnd && oDrawArea.iNumRows < iMaxRows) { const char* sBreakPosition = sMessageEnd; const char* sLastGoodBreakPosition = sBreakPosition; int iMsgWidth = -m_iCharSep; int iMsgBreakWidth = iMsgWidth; unsigned int iTallest = 0; const char* s; bool foundNewLine = false; unsigned int iNextChar = 0; for(s = sMessage; s != sMessageEnd; ) { const char* sOld = s; unsigned int iChar = unicodeToCodepage437(utf8next(s)); iNextChar = unicodeToCodepage437(static_cast<unsigned char>(*s)); if((iChar == '\n' && iNextChar == '\n') || (iChar == '/' && iNextChar == '/')) { foundNewLine = true; iMsgBreakWidth = iMsgWidth; sBreakPosition = sOld; break; } unsigned int iCharWidth = 0, iCharHeight = 0; if(iFirstASCII <= iChar && iChar <= iLastASCII) { m_pSpriteSheet->getSpriteSizeUnchecked(iChar - iFirstASCII, &iCharWidth, &iCharHeight); } iMsgWidth += m_iCharSep + iCharWidth; if(iChar == ' ') { sLastGoodBreakPosition = sOld; iMsgBreakWidth = iMsgWidth - iCharWidth; } if(iMsgWidth > iWidth) { sBreakPosition = sLastGoodBreakPosition; break; } if(iCharHeight > iTallest) iTallest = iCharHeight; } if(s == sMessageEnd) iMsgBreakWidth = iMsgWidth; if(iMsgBreakWidth > oDrawArea.iWidth) oDrawArea.iWidth = iMsgBreakWidth; if(iSkippedRows >= iSkipRows) { if(pCanvas) { int iXOffset = 0; if(iMsgBreakWidth < iWidth) iXOffset = (iWidth - iMsgBreakWidth) * static_cast<int>(eAlign) / 2; drawText(pCanvas, sMessage, sBreakPosition - sMessage, iX + iXOffset, iY); } iY += static_cast<int>(iTallest) + m_iLineSep; oDrawArea.iEndX = iMsgWidth; oDrawArea.iNumRows++; if (foundNewLine) { iY += static_cast<int>(iTallest) + m_iLineSep; oDrawArea.iNumRows++; } } else { iSkippedRows++; if(foundNewLine) { if(iSkippedRows == iSkipRows) { iY += static_cast<int>(iTallest) + m_iLineSep; oDrawArea.iNumRows++; } iSkippedRows++; } } sMessage = sBreakPosition; if(sMessage != sMessageEnd) { utf8next(sMessage); if(foundNewLine) { utf8next(sMessage); } } foundNewLine = 0; } } oDrawArea.iEndX = iX + oDrawArea.iEndX; oDrawArea.iEndY = iY; return oDrawArea; }
void drawText(float x, float y, const std::string & text, const Font & font) { return drawText(x,y,0.0,text,font); }
int main(int argc, char **argv) { enum GameMode gameMode; struct Windows windows; struct MapList mapList; struct Map *map; struct Dialog dialog[MAX_LEVELS]; struct UnitList inmates, guards; struct UnitNode *unitNode; struct Path path; bool progress[MAX_LEVELS]; int level=0; /* Parse map files */ parseMap(argv[1], &mapList, dialog); /* Create nCurses WINDOWs */ uiInit(&windows); /* Present user with main menu */ gameMode = menuMain(&windows); do{ if(gameMode==EXIT){ break; } else if (gameMode!=NEW){ level = levelSelect(&windows, &mapList, progress); } /* Select current map */ map = &(mapList).level[level]; /* Display intro text */ drawText(&windows, dialog[level], gameMode); /* Initialize game elements */ getGuards(&guards, *map); getPath(&path, *map); inmates.count = 0; inmates.head = NULL; inmates.tail = NULL; /* Draw level */ drawLevel(&windows, map, &guards); /* Prompt user for unit selection */ drawInmateSelection(&windows, map, &inmates, &guards); unitNode = getHead(&inmates); for (int i = 0; i < inmates.count; i++) { ((struct Inmate *) unitNode->unit)->position = path.first->location; unitNode = unitNode->next; } /* Simulate unit interactions */ progress[level] = simulate(&windows, &guards, &inmates, &path); if(progress[level]) gameMode=WIN; else gameMode=LOSE; /* Display outro text */ drawText(&windows, dialog[level], gameMode); } while (level!=EXIT); uiFree(&windows); quit("Thanks for playing.\n"); return 0; }
int main() { init(); enterMenu(0); int cloudScroll = 0; int loopSlower = 0; bool shootCoolDown = true; int reloadTimer = 0; //GAME LOOP while (true) { //INPUT if((REG_KEYINPUT & KEY_RIGHT) == 0){ tryMove(2,0,player.getWidth()-2,player.getHeight()/2,player); player.setRunning(true); player.setDir(true); } if((REG_KEYINPUT & KEY_LEFT) == 0){ tryMove(-2,0,0,player.getHeight()/2,player); player.setRunning(true); player.setDir(false); } if((REG_KEYINPUT & KEY_UP) == 0 || (REG_KEYINPUT & KEY_B) == 0){ if(player.getLanded()){ player.jump(); player.updateFrame(); } player.setJumpHeight(player.getJumpHeight()+4); } if((REG_KEYINPUT & KEY_A) == 0){ if(shootCoolDown){ if(weapon == 8){ if(player.getDir())tryMove(-2,0,0,player.getHeight()/2,player); else tryMove(2,0,player.getWidth()-2,player.getHeight()/2,player); }else if(weapon == 1){ if(player.getDir())tryMove(-1,0,0,player.getHeight()/2,player); else tryMove(1,0,player.getWidth()-2,player.getHeight()/2,player); } shoot(); shootCoolDown = false; reloadTimer = 0; } } //Player movement if(player.getJumping()){ if(!tryMove(0,-3,player.getWidth()/2,0,player)){ player.setJumping(false); } }else{ if(!tryMove(0,2,player.getWidth()/2,player.getHeight(),player)){ tryMove(0,1,player.getWidth()/2,player.getHeight(),player); player.setLanded(true); player.setJumping(false); }else{ player.setLanded(false); } } //Monster Movement for(int i = 0; i < enemies.size(); i++){ if(!enemies.at(i).isDead()){ if(enemies.at(i).getDir()){ if(!tryMove(1,0,enemies.at(i).getWidth(),(enemies.at(i).getHeight()/2)+1,enemies.at(i))){ enemies.at(i).setDir(false); } }else{ if(!tryMove(-1,0,0,(enemies.at(i).getHeight()/2)+1,enemies.at(i))){ enemies.at(i).setDir(true); } } tryMove(0,2,enemies.at(i).getWidth()/2,enemies.at(i).getHeight(),enemies.at(i)); ObjBuffer[i+3].attr0 &= ~(ATTR0_HIDE); }else{ ObjBuffer[i+3].attr0 |= ATTR0_HIDE; } } //Bullet movement for(int i = 0; i < bullets.size(); i++){ if(!bullets.at(i).isDead()){ int yMove = 0; if(rand() % 3 == 0)yMove = bullets.at(i).getLift(); if(bullets.at(i).getType() == 4){ tryMove(0,1,bullets.at(i).getWidth(),bullets.at(i).getHeight()+4,bullets.at(i)); }else if(bullets.at(i).getType() == 6){ if(player.getDir()){ ObjBuffer[i+24].attr1 &= ~(ATTR1_HFLIP); bullets.at(i).move(player.getX()+8, player.getY()); }else{ ObjBuffer[i+24].attr1 |= ATTR1_HFLIP; bullets.at(i).move(player.getX()-8, player.getY()); } if(bullets.at(i).charge()){ bullets.at(i).setDead(true); int number = 0; if(player.getDir())number = (SCREEN_WIDTH - player.getX())/8; else number = (0 + player.getX())/8; for(int i = 0; i < number; i++){ spawnBullet(7); } } }else if(bullets.at(i).getType() == 7){ if(bullets.at(i).charge())bullets.at(i).setDead(true); }else{ if(bullets.at(i).getDir()){ if(!tryMove(2,yMove,bullets.at(i).getWidth(), bullets.at(i).getHeight(), bullets.at(i))){ if(bullets.at(i).getType() == 3 && !bullets.at(i).getBounce()){ bullets.at(i).setBounce(true); bullets.at(i).setDir(false); }else{ bullets.at(i).setDead(true); if(bullets.at(i).getType() == 0 || bullets.at(i).getType() == 4){ explode(bullets.at(i).getX(), bullets.at(i).getY()); } } } }else{ if(!tryMove(-2,yMove,bullets.at(i).getWidth(), bullets.at(i).getHeight(), bullets.at(i))){ if(bullets.at(i).getType() == 3 && !bullets.at(i).getBounce()){ bullets.at(i).setBounce(true); bullets.at(i).setDir(true); }else{ bullets.at(i).setDead(true); if(bullets.at(i).getType() == 0 || bullets.at(i).getType() == 4){ explode(bullets.at(i).getX(), bullets.at(i).getY()); } } } } } ObjBuffer[i+24].attr0 &= ~(ATTR0_HIDE); }else{ ObjBuffer[i+24].attr0 |= ATTR0_HIDE; } } for(int i = 0; i < enemies.size(); i++){ if(!enemies.at(i).isDead()){ if(checkEntityCollision(player, enemies.at(i))){ player.setDead(true); } for(int k = 0; k < bullets.size(); k++){ if(!bullets.at(k).isDead()){ if(checkEntityCollision(bullets.at(k), enemies.at(i))){ enemies.at(i).hurt(bullets.at(k).getDamage()); if(bullets.at(k).getType() != 3 && bullets.at(k).getType() != 6 && bullets.at(k).getType() != 7){ bullets.at(k).setDead(true); if(bullets.at(k).getType() == 0 || bullets.at(k).getType() == 4){ explode(bullets.at(k).getX(), bullets.at(k).getY()); } } break; } } } } } if(checkEntityCollision(player, crate)){ crate.setDead(true); weapon = crate.getWeapon(); score++; } if(crate.isDead()){ switch(rand() % 7){ case 0:crate.move(80,32); break; case 1:crate.move(150,32); break; case 2:crate.move(30,64); break; case 3:crate.move(200,64); break; case 4:crate.move(115,104); break; case 5:crate.move(80,144); break; case 6:crate.move(150,144); break; } int newWep = 0; do newWep = rand() % 9; while(newWep == weapon || newWep == 6); crate.setWeapon(newWep); crate.setDead(false); } //General Slow things if(loopSlower % 7 == 0){ cloudScroll++; REG_BG3HOFS = cloudScroll; SetTile(30, 14, 19, 16+rand()%5); SetTile(30, 15, 19, 16+rand()%5); player.updateFrame(); for(int i = 0; i < enemies.size(); i++){ if(!enemies.at(i).isDead()){ enemies.at(i).updateFrame(); } } ObjBuffer[2].attr2 = ATTR2_ID8(player.getFrame()); for(int i = 0; i < enemies.size(); i++){ ObjBuffer[i+3].attr2 = ATTR2_ID8(enemies.at(i).getFrame()); } } reloadTimer++; if(weapon == 0 || weapon == 5 || weapon == 6 || weapon == 7){ if(reloadTimer >= 60){ shootCoolDown = true; } }else if(weapon == 2 || weapon == 4){ if(reloadTimer >= 45){ shootCoolDown = true; } }else if (weapon == 3){ if(reloadTimer >= 20){ shootCoolDown = true; } }else if(weapon == 1){ if(reloadTimer >= 10){ shootCoolDown = true; } }else{ if(reloadTimer >= 5){ shootCoolDown = true; } } if(reloadTimer > 1000)reloadTimer = 60; //Monster spawner if(rand()%100 == 0){ spawnMonster(); } //Player state updates if(player.getJumping())player.setState(2); else if(player.getRunning())player.setState(1); else player.setState(0); if(!player.getDir()){ ObjBuffer[0].attr1 |= ATTR1_HFLIP; ObjBuffer[2].attr1 |= ATTR1_HFLIP; }else{ ObjBuffer[0].attr1 &= ~(ATTR1_HFLIP); ObjBuffer[2].attr1 &= ~(ATTR1_HFLIP); } if(weapon == 8)ObjBuffer[0].attr0 |= ATTR0_SHAPE(1); else ObjBuffer[0].attr0 &= ~(ATTR0_SHAPE(1)); ObjBuffer[0].attr2 = ATTR2_ID8(22+weapon); for(int i = 0; i < enemies.size(); i++){ if(!enemies.at(i).isDead()){ if(!enemies.at(i).getDir())ObjBuffer[i+3].attr1 |= ATTR1_HFLIP; else ObjBuffer[i+3].attr1 &= ~(ATTR1_HFLIP); } } player.update(); if(player.isDead())enterMenu(2); //Render if(!player.getDir()){ if(weapon != 8)SetObjectX(0, player.getX()-4); else{ if(player.getX()-12 <= 0) SetObjectX(0, 0); else SetObjectX(0, player.getX()-12); } }else{ SetObjectX(0, player.getX()+4); } SetObjectY(0, player.getY()+1); SetObjectX(1, crate.getX()); SetObjectY(1, crate.getY()); SetObjectX(2, player.getX()); SetObjectY(2, player.getY()); for(int i = 0; i < enemies.size(); i++){ if(!enemies.at(i).isDead()){ SetObjectX(i+3, enemies.at(i).getX()); SetObjectY(i+3, enemies.at(i).getY()); } } for(int i = 0; i < bullets.size(); i++){ if(!bullets.at(i).isDead()){ SetObjectX(i+24, bullets.at(i).getX()); SetObjectY(i+24, bullets.at(i).getY()); } } drawText(112,10,toString(score)); WaitVSync(); UpdateObjects(); clearText(); loopSlower++; } return 0; }
void enterMenu(int menu){ LoadPaletteBGData(0, menuBGPal, menuBGPalLen); bool active = true; int option = 0; int keyPressCoolDown = 30; if(menu == 0)ClearObjects(); //MENU LOOP while(active){ keyPressCoolDown--; if(keyPressCoolDown <= 0)keyPressCoolDown = 0; clearText(); switch(menu){ case 0://Main menu if((REG_KEYINPUT & KEY_UP) == 0){ option = 0; } if((REG_KEYINPUT & KEY_DOWN) == 0){ option = 1; } if((REG_KEYINPUT & KEY_A) == 0 && keyPressCoolDown == 0){ if(option == 0){ active = false; gameInit(); }else{ menu = 1; keyPressCoolDown = 30; } } drawText(60,20,"Super Crate Box"); drawText(105,65,"PLAY"); drawText(93,90,"CREDITS"); if(option == 0)drawText(90, 65, "> <"); if(option == 1)drawText(78, 90, "> <"); break; case 1://Credits if((REG_KEYINPUT & KEY_A) == 0 && keyPressCoolDown == 0){ menu = 0; keyPressCoolDown = 30; } if((REG_KEYINPUT & KEY_B) == 0 && keyPressCoolDown == 0){ menu = 0; keyPressCoolDown = 30; } drawText(30, 20, "GBA - Super Crate Box"); drawText(30,60, "Created by Peter Black"); drawText(70,80, "for CGA 2014"); drawText(8, 135, "Assets & Gameplay C Vlambeer"); break; case 2://Game Over if((REG_KEYINPUT & KEY_A) == 0 && keyPressCoolDown == 0){ active = false; gameInit(); } if((REG_KEYINPUT & KEY_B) == 0 && keyPressCoolDown == 0){ menu = 0; ClearObjects(); keyPressCoolDown = 30; } drawText(82,60,"GAME OVER"); drawText(85,80,"Score:"); drawText(133,80,toString(score)); drawText(77, 125,"A = Retry"); drawText(65, 135,"B = Main Menu"); break; } WaitVSync(); UpdateObjects(); } LoadPaletteBGData(0, backgroundPal, backgroundPalLen); }
void drawText(int x1, int y1, const char *text) { drawText(cv::Point(x1,y1),text); }
void Button::drawInternal(Graphics* const TheGraphics, Real32 Opacity) const { Pnt2f TopLeft, BottomRight; getInsideBorderBounds(TopLeft, BottomRight); //If I have a DrawObject then Draw it UIDrawObjectCanvasRefPtr DrawnDrawObject = getDrawnDrawObject(); UIDrawObjectCanvasRefPtr BaseDrawObject = getBaseDrawObject(); if(DrawnDrawObject != NULL) { //Get the Draw Object Size Vec2f DrawObjectSize = DrawnDrawObject->getRequestedSize(); Vec2f BaseDrawObjectSize = BaseDrawObject->getRequestedSize(); if(getText() != "" && getFont() != NULL) { //Draw both the text and Draw Object //Get the Text Size Pnt2f TextTopLeft, TextBottomRight; getFont()->getBounds(getText(), TextTopLeft, TextBottomRight); Vec2f InternalsSize; if(getDrawObjectToTextAlignment() == ALIGN_DRAW_OBJECT_LEFT_OF_TEXT || getDrawObjectToTextAlignment() == ALIGN_DRAW_OBJECT_RIGHT_OF_TEXT) { InternalsSize.setValues((TextBottomRight.x()-TextTopLeft.x()) + DrawObjectSize.x() + getDrawObjectToTextPadding(), osgMax((TextBottomRight.y()-TextTopLeft.y()), DrawObjectSize.y())); } else { InternalsSize.setValues(osgMax((TextBottomRight.x()-TextTopLeft.x()), DrawObjectSize.x()), (TextBottomRight.y()-TextTopLeft.y()) + DrawObjectSize.y() + getDrawObjectToTextPadding()); } Pnt2f InternalAlignment; InternalAlignment = calculateAlignment(TopLeft, (BottomRight-TopLeft), InternalsSize,getAlignment().y(), getAlignment().x()); //Draw Object Alignment Pnt2f DrawObjectAlignedPosition; switch(getDrawObjectToTextAlignment()) { case ALIGN_DRAW_OBJECT_LEFT_OF_TEXT: DrawObjectAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, DrawObjectSize,0.5f, 0.0); break; case ALIGN_DRAW_OBJECT_RIGHT_OF_TEXT: DrawObjectAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, DrawObjectSize,0.5f, 1.0); break; case ALIGN_DRAW_OBJECT_ABOVE_TEXT: DrawObjectAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, DrawObjectSize,0.0f, 0.5); break; case ALIGN_DRAW_OBJECT_BELOW_TEXT: DrawObjectAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, DrawObjectSize,1.0f, 0.5); break; } //If active then translate the Text by the Active Offset DrawObjectAlignedPosition = DrawObjectAlignedPosition + getDrawnOffset(); DrawnDrawObject->setPosition( DrawObjectAlignedPosition ); //Text Alignment Pnt2f TextAlignedPosition; switch(getDrawObjectToTextAlignment()) { case ALIGN_DRAW_OBJECT_LEFT_OF_TEXT: TextAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, (TextBottomRight - TextTopLeft),0.5f, 1.0); break; case ALIGN_DRAW_OBJECT_RIGHT_OF_TEXT: TextAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, (TextBottomRight - TextTopLeft),0.5f, 0.0); break; case ALIGN_DRAW_OBJECT_ABOVE_TEXT: TextAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, (TextBottomRight - TextTopLeft),1.0f, 0.5); break; case ALIGN_DRAW_OBJECT_BELOW_TEXT: TextAlignedPosition = calculateAlignment(InternalAlignment, InternalsSize, (TextBottomRight - TextTopLeft),0.0f, 0.5); break; } drawText(TheGraphics, TextAlignedPosition, Opacity); } else { //Just Draw the Draw Object Pnt2f AlignedPosition; AlignedPosition = calculateAlignment(TopLeft, (BottomRight-TopLeft), BaseDrawObjectSize,getAlignment().y(), getAlignment().x()); //If active then translate the Text by the Active Offset AlignedPosition = AlignedPosition + getDrawnOffset(); DrawnDrawObject->setPosition( AlignedPosition ); } //Draw the DrawnDrawObject DrawnDrawObject->draw(TheGraphics, getOpacity()*Opacity); } else if(getText() != "" && getFont() != NULL) { //Just Draw the Text Pnt2f AlignedPosition; Pnt2f TextTopLeft, TextBottomRight; getFont()->getBounds(getText(), TextTopLeft, TextBottomRight); AlignedPosition = calculateAlignment(TopLeft, (BottomRight-TopLeft), (TextBottomRight - TextTopLeft),getAlignment().y(), getAlignment().x()); drawText(TheGraphics, AlignedPosition, Opacity); } //Focus Border if(getFocused() && getFocusedBorder() != NULL) { getFocusedBorder()->activateInternalDrawConstraints(TheGraphics,0,0,getSize().x(),getSize().y()); drawBorder(TheGraphics, getFocusedBorder(), Opacity); } }
/*! Wrapper for QPainter::drawText() */ void QwtPainter::drawText(QPainter *painter, int x, int y, int w, int h, int flags, const QString &text) { drawText(painter, QRect(x, y, w, h), flags, text); }
void JRRandomObj::draw(JGraphics g, int x, int y, int w, int h) { JRect rect(x, y, w, h); drawText(g, JString("Rand"), rect); }
void JTNG4Obj::draw(JGraphics g, int x, int y, int w, int h) { JRect rect(x, y, w, h); drawText(g, JString("TNG4"), rect); }
/* SCallTip::updateBuffer * Redraws the calltip text to the buffer image, setting the buffer * image size to the exact dimensions of the text *******************************************************************/ void SCallTip::updateBuffer() { buffer.SetWidth(1000); buffer.SetHeight(1000); wxFont bold = font.Bold(); // Setup faded text colour rgba_t faded; if (txed_calltips_dim_optional) faded = rgba_t( col_fg.r * 0.5 + col_bg.r * 0.5, col_fg.g * 0.5 + col_bg.g * 0.5, col_fg.b * 0.5 + col_bg.b * 0.5 ); else faded = col_fg; wxMemoryDC dc(buffer); // Clear dc.SetPen(*wxTRANSPARENT_PEN); dc.SetBrush(wxBrush(WXCOL(col_bg))); dc.DrawRectangle(0, 0, 1000, 1000); if (function) { dc.SetFont(font); dc.SetTextForeground(WXCOL(col_fg)); // Draw arg set switching stuff int left = 0; if (switch_args) { // up-filled \xE2\x96\xB2 // up-empty \xE2\x96\xB3 // down-filled \xE2\x96\xBC // down-empty \xE2\x96\xBD // Up arrow dc.SetTextForeground((btn_mouse_over == 2) ? WXCOL(col_fg_hl) : WXCOL(col_fg)); dc.DrawLabel( wxString::FromUTF8("\xE2\x96\xB2"), wxNullBitmap, wxRect(0, 0, 100, 100), 0, -1, &rect_btn_up); // Arg set int width = dc.GetTextExtent("X/X").x; dc.SetTextForeground(WXCOL(col_fg)); dc.DrawLabel( S_FMT("%d/%d", arg_set_current + 1, function->nArgSets()), wxNullBitmap, wxRect(rect_btn_up.GetRight() + 4, 0, width, 900), wxALIGN_CENTER_HORIZONTAL); // Down arrow dc.SetTextForeground((btn_mouse_over == 1) ? WXCOL(col_fg_hl) : WXCOL(col_fg)); dc.DrawLabel( wxString::FromUTF8("\xE2\x96\xBC"), wxNullBitmap, wxRect(rect_btn_up.GetRight() + width + 8, 0, 900, 900), 0, -1, &rect_btn_down); left = rect_btn_down.GetRight() + 8; rect_btn_up.Offset(12, 8); rect_btn_down.Offset(12, 8); } // Draw function name string fname = function->getName(); wxRect rect; dc.SetTextForeground(WXCOL(col_func)); dc.DrawLabel(fname, wxNullBitmap, wxRect(left, 0, 900, 900), 0, -1, &rect); // Draw opening bracket dc.SetTextForeground(WXCOL(col_fg)); left = drawText(dc, "(", rect.GetRight() + 1, rect.GetTop(), &rect); // Draw args int top = rect.GetTop(); int max_right = 0; int args_left = left; for (unsigned a = 0; a < args.size(); a++) { // Go down to next line if current is too long if (left > SCALLTIP_MAX_WIDTH) { left = args_left; top = rect.GetBottom() + 2; } // Set highlight colour if current arg if (a == arg_current) { dc.SetTextForeground(WXCOL(col_fg_hl)); dc.SetFont(bold); } // Optional opening bracket if (args[a].optional && !txed_calltips_dim_optional) left = drawText(dc, "[", left, top, &rect); // Type if (!args[a].type.empty()) { if (a != arg_current) dc.SetTextForeground(WXCOL(col_type)); left = drawText(dc, args[a].type + " ", left, top, &rect); } // Name if (a != arg_current) dc.SetTextForeground(args[a].optional ? WXCOL(faded) : WXCOL(col_fg)); // Faded text if optional left = drawText(dc, args[a].name, left, top, &rect); // Optional closing bracket if (args[a].optional && !txed_calltips_dim_optional) left = drawText(dc, "]", left, top, &rect); // Comma (if needed) dc.SetFont(font); dc.SetTextForeground(WXCOL(col_fg)); if (a < args.size() - 1) left = drawText(dc, ", ", left, top, &rect); // Update max width if (rect.GetRight() > max_right) max_right = rect.GetRight(); } // Draw closing bracket left = drawText(dc, ")", left, top, &rect); // Draw overloads number if (function->nArgSets() > 1 && !switch_args) dc.DrawLabel( S_FMT(" (+%d)", function->nArgSets() - 1), wxNullBitmap, wxRect(left, top, 900, 900), 0, -1, &rect); // Update max width if (rect.GetRight() > max_right) max_right = rect.GetRight(); // Description string desc = function->getDescription(); if (!desc.IsEmpty()) { wxFont italic = font.Italic(); dc.SetFont(italic); if (dc.GetTextExtent(desc).x > SCALLTIP_MAX_WIDTH) { // Description is too long, split into multiple lines vector<string> desc_lines; string line = desc; wxArrayInt extents; while (true) { dc.GetPartialTextExtents(line, extents); bool split = false; for (unsigned a = 0; a < extents.size(); a++) { if (extents[a] > SCALLTIP_MAX_WIDTH) { int eol = line.SubString(0, a).Last(' '); desc_lines.push_back(line.SubString(0, eol)); line = line.SubString(eol + 1, line.Length()); split = true; break; } } if (!split) { desc_lines.push_back(line); break; } } int bottom = rect.GetBottom() + 8; for (unsigned a = 0; a < desc_lines.size(); a++) { drawText(dc, desc_lines[a], 0, bottom, &rect); bottom = rect.GetBottom(); if (rect.GetRight() > max_right) max_right = rect.GetRight(); } } else { drawText(dc, desc, 0, rect.GetBottom() + 8, &rect); if (rect.GetRight() > max_right) max_right = rect.GetRight(); } } // Size buffer bitmap to fit buffer.SetWidth(max_right + 1); buffer.SetHeight(rect.GetBottom() + 1); } else { // No function, empty buffer buffer.SetWidth(16); buffer.SetHeight(16); } }
static void lvDisplay(void) { glClear(GL_COLOR_BUFFER_BIT); applyTransforms(); glScalef(scale, scale, scale); glColor3f(0.25f, 0.25f, 0.25f); glLineWidth(2); drawLine(-lvWidth-lvTransX, 0, lvWidth-lvTransX, 0); drawLine(0, -lvHeight-lvTransY, 0, lvHeight-lvTransY); glLineWidth(1); lsystem.Draw(); // Draw image planes glColor3f(1.0, 0.0, 1.0); glLineWidth(2); drawLine(lsystem.iPlane, lsystem.maxAperture()/2, lsystem.iPlane, -lsystem.maxAperture()/2); drawText(lsystem.iPlane - 1, -lsystem.maxAperture()/2 - 5, SBFONT, "I"); drawLine(zDist, lsystem.maxAperture()/2, zDist, -lsystem.maxAperture()/2); drawText(zDist - 1, -lsystem.maxAperture()/2 - 5, SBFONT, "O"); // Trace rays through lens system glColor3f(0.0, 0.0, 1.0); glLineWidth(1); for (int i = -9; i < 10; i++) { Ray rayv = Ray(Point(0, iPlaneY, lsystem.iPlane), Vector(0, lsystem.pupil.y/2 * (float) i/9 - iPlaneY, lsystem.pupil.z - lsystem.iPlane)); Ray& rays = rayv; lsystem.Trace(rays, new Ray()); } //lsystem.findExitPupil(); //lsystem.recalAper(); //lsystem.findF(); //lsystem.findFp(); //lsystem.refocus(zDist, -1); //Draw principal axes glColor3f(0.0, 1.0, 0.0); glLineWidth(2); drawLine(lsystem.pupil.z, lsystem.pupil.y/2, lsystem.pupil.z, (lsystem.pupil.y+lsystem.maxAperture()) / 2); drawLine(lsystem.pupil.z, -lsystem.pupil.y/2, lsystem.pupil.z, (-lsystem.pupil.y-lsystem.maxAperture()) / 2); drawText(lsystem.pupil.z, (-lsystem.pupil.y-lsystem.maxAperture()) / 2 - 5, SBFONT, "ep"); //Draw principal axes glColor3f(1.0, 0.0, 0.0); glLineWidth(2); drawLine(lsystem.p2, lsystem.maxAperture()/2, lsystem.p2, -lsystem.maxAperture()/2); drawText(lsystem.p2 - 1, -lsystem.maxAperture()/2 - 5, SBFONT, "P'"); drawLine(lsystem.p1, lsystem.maxAperture()/2, lsystem.p1, -lsystem.maxAperture()/2); drawText(lsystem.p1 - 1, -lsystem.maxAperture()/2 - 5, SBFONT, "P"); //Draw focal planes glColor3f(1.0, 1.0, 0.0); drawPoint(5, lsystem.f1, 0); drawText(lsystem.f1 - 1, -5, SBFONT, "F"); drawPoint(5, lsystem.f2, 0); drawText(lsystem.f2 - 1, -5, SBFONT, "F'"); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D(0, lvWidth, lvHeight, 0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); drawSquare(0.25f, 0.25f, 0.25f, 0, 0, lvWidth, BARH); drawSquare(0.25f, 0.25f, 0.25f, 0, lvHeight, lvWidth, lvHeight-BARH); glLoadIdentity(); gluOrtho2D(-lvWidth, lvWidth, lvHeight, -lvHeight); glColor3f(0, 1, 1); drawText(-lvWidth + 15, -lvTransY*lvZoom - 8, SBFONT, "+z"); drawText(lvWidth - 50, -lvTransY*lvZoom - 8, SBFONT, "-z"); drawText(-lvTransX*lvZoom, -lvHeight + 75, SBFONT, "+y"); drawText(-lvTransX*lvZoom, lvHeight - 65, SBFONT, "-y"); glColor3f(1, 1, 1); const char* mode = lsystem.M == precise ? "precise" : "thick"; lvText(9, lvHeight-16, SBFONT, 0, "fstop %1.1f (aperture %1.1fmm) | " "object %1.1fmm | image %1.1fmm | mode: %s", lsystem.fstop,lsystem.getAperture()->aper,zDist,lsystem.iPlane, mode); lvText(9, 8, SBFONT, 0, "F %1.1fmm | F' %1.1fmm | P %1.1fmm | " "P' %1.1fmm | exit pupil (%1.1fmm, %1.1fmm)", lsystem.f1,lsystem.f2,lsystem.p1,lsystem.p2,lsystem.pupil.z,lsystem.pupil.y); glPopMatrix(); glutSwapBuffers(); }
NULL)); SIMPLE_TEST_STEP(DrawBitmapRectSrcRect, drawBitmapRect(kTestBitmap, &kTestIRect, kTestRect, NULL)); SIMPLE_TEST_STEP(DrawBitmapRectPaint, drawBitmapRect(kTestBitmap, NULL, kTestRect, &kTestPaint)); SIMPLE_TEST_STEP(DrawBitmapMatrix, drawBitmapMatrix(kTestBitmap, kTestMatrix, NULL)); SIMPLE_TEST_STEP(DrawBitmapMatrixPaint, drawBitmapMatrix(kTestBitmap, kTestMatrix, &kTestPaint)); SIMPLE_TEST_STEP(DrawBitmapNine, drawBitmapNine(kTestBitmap, kTestIRect, kTestRect, NULL)); SIMPLE_TEST_STEP(DrawBitmapNinePaint, drawBitmapNine(kTestBitmap, kTestIRect, kTestRect, &kTestPaint)); SIMPLE_TEST_STEP(DrawSprite, drawSprite(kTestBitmap, 0, 0, NULL)); SIMPLE_TEST_STEP(DrawSpritePaint, drawSprite(kTestBitmap, 0, 0, &kTestPaint)); SIMPLE_TEST_STEP(DrawText, drawText(kTestText.c_str(), kTestText.size(), 0, 1, kTestPaint)); SIMPLE_TEST_STEP(DrawPosText, drawPosText(kTestText.c_str(), kTestText.size(), kTestPoints2, kTestPaint)); SIMPLE_TEST_STEP(DrawTextOnPath, drawTextOnPath(kTestText.c_str(), kTestText.size(), kTestPath, NULL, kTestPaint)); SIMPLE_TEST_STEP(DrawTextOnPathMatrix, drawTextOnPath(kTestText.c_str(), kTestText.size(), kTestPath, &kTestMatrix, kTestPaint)); SIMPLE_TEST_STEP(DrawData, drawData(kTestText.c_str(), kTestText.size())); SIMPLE_TEST_STEP(BeginGroup, beginCommentGroup(kTestText.c_str())); SIMPLE_TEST_STEP(AddComment, addComment(kTestText.c_str(), kTestText.c_str())); SIMPLE_TEST_STEP(EndGroup, endCommentGroup()); /////////////////////////////////////////////////////////////////////////////// // Complex test steps // Save/restore calls cannot be in isolated simple test steps because the test
void imguiRenderGLDraw() { const imguiGfxCmd* q = imguiGetRenderQueue(); int nq = imguiGetRenderQueueSize(); const float s = 1.0f/8.0f; glDisable(GL_SCISSOR_TEST); for (int i = 0; i < nq; ++i) { const imguiGfxCmd& cmd = q[i]; if (cmd.type == IMGUI_GFXCMD_RECT) { if (cmd.rect.r == 0) { drawRect((float)cmd.rect.x*s+0.5f, (float)cmd.rect.y*s+0.5f, (float)cmd.rect.w*s-1, (float)cmd.rect.h*s-1, 1.0f, cmd.col); } else { drawRoundedRect((float)cmd.rect.x*s+0.5f, (float)cmd.rect.y*s+0.5f, (float)cmd.rect.w*s-1, (float)cmd.rect.h*s-1, (float)cmd.rect.r*s, 1.0f, cmd.col); } } else if (cmd.type == IMGUI_GFXCMD_LINE) { drawLine(cmd.line.x0*s, cmd.line.y0*s, cmd.line.x1*s, cmd.line.y1*s, cmd.line.r*s, 1.0f, cmd.col); } else if (cmd.type == IMGUI_GFXCMD_TRIANGLE) { if (cmd.flags == 1) { const float verts[3*2] = { (float)cmd.rect.x*s+0.5f, (float)cmd.rect.y*s+0.5f, (float)cmd.rect.x*s+0.5f+(float)cmd.rect.w*s-1, (float)cmd.rect.y*s+0.5f+(float)cmd.rect.h*s/2-0.5f, (float)cmd.rect.x*s+0.5f, (float)cmd.rect.y*s+0.5f+(float)cmd.rect.h*s-1, }; drawPolygon(verts, 3, 1.0f, cmd.col); } if (cmd.flags == 2) { const float verts[3*2] = { (float)cmd.rect.x*s+0.5f, (float)cmd.rect.y*s+0.5f+(float)cmd.rect.h*s-1, (float)cmd.rect.x*s+0.5f+(float)cmd.rect.w*s/2-0.5f, (float)cmd.rect.y*s+0.5f, (float)cmd.rect.x*s+0.5f+(float)cmd.rect.w*s-1, (float)cmd.rect.y*s+0.5f+(float)cmd.rect.h*s-1, }; drawPolygon(verts, 3, 1.0f, cmd.col); } } else if (cmd.type == IMGUI_GFXCMD_TEXT) { drawText(cmd.text.x, cmd.text.y, cmd.text.text, cmd.text.align, cmd.col); } else if (cmd.type == IMGUI_GFXCMD_SCISSOR) { if (cmd.flags) { glEnable(GL_SCISSOR_TEST); glScissor(cmd.rect.x, cmd.rect.y, cmd.rect.w, cmd.rect.h); } else { glDisable(GL_SCISSOR_TEST); } } } glDisable(GL_SCISSOR_TEST); }
void finalPlotsGammaTrack () { TH1D* hDphiF[5][10]; TH1D* hXawayF[5][10]; TH1D* hPtAwayF[5][10]; TFile* inf = new TFile("photonTrackOutput_photonPt50GeV.root"); for ( int icent =1 ; icent<=nCent_std ; icent++) { hXawayF[icent][kHIDATA] = (TH1D*)inf->Get(Form("hidata_icent%d_hTrkXAway_final",icent)); handsomeTH1(hXawayF[icent][kHIDATA],color[icent]); hXawayF[icent][kHIMC] = (TH1D*)inf->Get(Form("himc_icent%d_hTrkXAway_final",icent)); handsomeTH1(hXawayF[icent][kHIMC],color[icent]); TH1ScaleByWidth(hXawayF[icent][kHIDATA]); TH1ScaleByWidth(hXawayF[icent][kHIMC]); } TCanvas* c100 = new TCanvas("c100","",1000,500); c100->Divide(2,1); c100->cd(2); TH1D* htemp100 = (TH1D*)hXawayF[1][kHIDATA]->Clone("htemp100"); htemp100->Reset(); handsomeTH1(htemp100,1); htemp100->SetAxisRange(0.01,1e2,"Y"); htemp100->SetYTitle("dN_{track}/dx_{T#gamma} per #gamma"); htemp100->DrawCopy(); gPad->SetLogy(); for ( int icent =1 ; icent<=nCent_std ; icent++) { hXawayF[nCent_std+1-icent][kHIDATA]->Draw("same"); } TLegend* l1 = new TLegend(0.4979083,0.4978381,0.9999163,0.7767209,NULL,"brNDC"); easyLeg(l1,""); for ( int icent = nCent_std ; icent>=1 ; icent--) { int lowCent = centBin_std[icent-1]; int highCent = centBin_std[icent]-1; l1->AddEntry(hXawayF[icent][kHIDATA], Form("%.0f%% - %.0f%%", float((float)lowCent*2.5), float((float)(highCent+1)*2.5))); } drawText("CMS Preliminary",0.5,0.83,1); drawText("PbPb #int L dt = ~150 #mub^{-1}",0.5,0.75,1); c100->cd(1); htemp100->DrawCopy(); gPad->SetLogy(); for ( int icent =1 ; icent<=nCent_std ; icent++) { hXawayF[nCent_std+1-icent][kHIMC]->Draw("same"); } drawText("MC",0.5,0.83,1); drawText("PYTHIA+HYDJET",0.5,0.75,1); l1->Draw(); int percentBin[5] = {0,10,30,50,100}; TCanvas* c102 = new TCanvas("c102","",1000,350); makeMultiPanelCanvas(c102,4,1,0.0,0.0,0.24,0.15,0.02); htemp100->SetYTitle("DATA/MC"); htemp100->SetAxisRange(0,2,"Y"); htemp100->SetNdivisions(505); for ( int icent =1 ; icent<=nCent_std ; icent++) { c102->cd(nCent_std+1-icent); htemp100->DrawCopy(); jumSun(0,1,1,1); TH1D* tempRatio = (TH1D*)hXawayF[icent][kHIDATA]->Clone(Form("tempRatio_icent%d",icent)); tempRatio->Divide(hXawayF[icent][kHIMC]); tempRatio->Draw("same"); if ( icent ==4 ) { drawText("CMS Preliminary",0.4,0.91,1,16); drawText("PbPb #int L dt = ~150 #mub^{-1}",0.4,0.82,1,16); } drawText(Form("%d%% - %d%%",percentBin[icent-1],percentBin[icent]),0.4,0.73,1,16); } }
//Metodo que sirve para resaltar un elemento en el menu y actualizar los elementos //que se van mostrando void TMenu::MostrarMenu(int numMenu) { Clear(); //Hay que mover fondo circulos a otro lugar this->miImagen->fondoCirculos(); int contador2 = 0; int lineas_pantalla = (this->maxHeight -this->top) / (tamFuente + saltoLinea); bool pantallaMovida = false; if (menusD->posCampo >= menusD->posMenuScreenFin) { menusD->posMenuScreenIni++; menusD->posMenuScreenFin++; pantallaMovida = true; } else if (menusD->posCampo < menusD->posMenuScreenIni) { menusD->posMenuScreenIni--; menusD->posMenuScreenFin--; pantallaMovida = true; } int inicio=menusD->posMenuScreenIni, fin=menusD->posMenuScreenFin; if (menusD->menus[numMenu].numCampos < lineas_pantalla) fin = menusD->menus[numMenu].numCampos; //this->sangrado(numMenu); if (menusD->posMenuScreenIni > 0) { this->miImagen->pintarTriangulo (5,1,10,9,true,clBlanco); } if (menusD->posMenuScreenIni < menusD->menus[numMenu].numCampos - lineas_pantalla ) { this->miImagen->pintarTriangulo (5,screen->h - 1,10,9,false,clBlanco); } int posX=0; //Lo mismo que se hace aqui para pintar los menus, debe hacerse //en TMenuPrincipal::MostrarMenuPrincipal() for (int i = inicio; i < fin;i++) { if (i == menusD->posCampo) { TTF_SizeText(font,menusD->menus[numMenu].campo[i].nombre,&posX,NULL); this->miImagen->pintarCirculo(margenI + left + 3,margenS + top + contador2*separacion + separacion/2, separacion/2,clRojo); this->miImagen->pintarCirculo(margenI + left + 3 + posX, margenS + top + contador2*separacion+separacion/2, separacion/2,clRojo); this->setColor(clNegro); SDL_Rect pantalla = { margenI + left + 3,margenS + top + contador2*separacion +1, posX, separacion-2}; //Pintamos el texto sobresaltado en color rojo ClRojo SDL_FillRect(screen, &pantalla, SDL_MapRGB(screen->format,255,0,0)); IconosMenu(numMenu,i,margenS + top + contador2*separacion +1); } else { this->setColor(clBlanco); IconosMenu(numMenu,i,margenS + top + contador2*separacion +1); } drawText(menusD->menus[numMenu].campo[i].nombre,left, margenS + top + contador2*separacion); contador2++; } if (numMenu <= this->menusD->mensajes_menus.menus-1) { this->setColor(clBlanco); if (numMenu == 6) { objTraza->print("Antes de asignar los menus recientes",fichLang->getClave("mBorra")); //this->miImagen->pintarTitulo("Borrar ficheros recientes de la ruta:"); this->miImagen->pintarTitulo(fichLang->getClave("mBorra")); //drawText("Borrar de la ruta:",0,0); drawText(this->menusD->mensajes_menus.mensajes[numMenu].textoMensaje,0,25); } else { this->miImagen->pintarTitulo(this->menusD->mensajes_menus.mensajes[numMenu].textoMensaje); } /* else { drawText(this->mensajes_menus.mensajes[numMenu].textoMensaje,0,0); } */ } if (numMenu == 0) { //Se hace lo mismo en TMenuPrincipal::MostrarMenuPrincipal this->miImagen->pintarTitulo(this->nombreFicheroAbierto); this->verTiempoLectura(); } /* else if (numMenu == 2) { this->pintarTitulo("Opciones"); } else if (numMenu == 3) { this->pintarTitulo("Tipos de fuente"); } else if (numMenu == 4) { this->pintarTitulo("Ir a la página"); } */ SDL_UpdateRect(screen, 0, 0, 0, 0); visible = true; }
void Board::draw() { window->Clear(); sf::Shape bLine, fLine, Circle; sf::Shape vLine1 = sf::Shape::Line(regions[2], 0, regions[2], regions[1], 5.f, sf::Color::White); sf::Shape vLine2 = sf::Shape::Line(regions[4], 0, regions[4], regions[1], 5.f, sf::Color::White); sf::Shape hLine1 = sf::Shape::Line(0, regions[3], regions[0], regions[3], 5.f, sf::Color::White); sf::Shape hLine2 = sf::Shape::Line(0, regions[5], regions[0], regions[5], 5.f, sf::Color::White); int i = 0; for(i = 0; i < BOARD_SIZE; i++) { unsigned int *bounding_box = getBoundingBox(i); switch(board[i]) { case 2: bLine = sf::Shape::Line(bounding_box[0], bounding_box[1], bounding_box[6], bounding_box[7], 5.f, sf::Color::White); fLine = sf::Shape::Line(bounding_box[4], bounding_box[5], bounding_box[2], bounding_box[3], 5.f, sf::Color::White); window->Draw(bLine); window->Draw(fLine); break; case 3: float x = (float)bounding_box[6] - (regions[2] / 2); float y = (float)bounding_box[7] - (regions[3] / 2); Circle = sf::Shape::Circle(x, y, 100.f, sf::Color::White); window->Draw(Circle); break; } delete bounding_box; } window->Draw(vLine1); window->Draw(vLine2); window->Draw(hLine1); window->Draw(hLine2); if(match != -1) { if(match == 2) { drawText("Winner X!", regions[2], regions[3]); } else if(match == 1) { drawText("Winner O!", regions[2], regions[3]); } else if(match == 0) { drawText("Cat's Game!", regions[2], regions[3]); } drawText("Play Again (Y/N)", regions[2], regions[3]+50); char scr[255]; sprintf(scr, "Score: X %d, O: %d, C: %d", score[0], score[1], score[2]); drawText(scr, regions[2], regions[3]+100); } }
void JBSubObj::draw(JGraphics g, int x, int y, int w, int h) { JRect rect(x, y, w, h); drawText(g, JString("Sub"), rect); }
void QgsResidualPlotItem::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget ) { Q_UNUSED( itemStyle ); Q_UNUSED( pWidget ); if ( mGCPList.size() < 1 || !painter ) { return; } double widthMM = rect().width(); double heightMM = rect().height(); QPen enabledPen( QColor( 255, 0, 0, 255 ), 0.3, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin ); QPen disabledPen( QColor( 255, 0, 0, 85 ), 0.2, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin ); QBrush enabledBrush( QColor( 255, 255, 255, 255 ) ); QBrush disabledBrush( QColor( 255, 255, 255, 127 ) ); //draw all points and collect minimal mm/pixel ratio double minMMPixelRatio = DBL_MAX; double mmPixelRatio = 1; painter->setRenderHint( QPainter::Antialiasing, true ); QgsGCPList::const_iterator gcpIt = mGCPList.constBegin(); for ( ; gcpIt != mGCPList.constEnd(); ++gcpIt ) { QgsPoint gcpCoords = ( *gcpIt )->pixelCoords(); double gcpItemMMX = ( gcpCoords.x() - mExtent.xMinimum() ) / mExtent.width() * widthMM; double gcpItemMMY = ( 1 - ( gcpCoords.y() - mExtent.yMinimum() ) / mExtent.height() ) * heightMM; if (( *gcpIt )->isEnabled() ) { painter->setPen( enabledPen ); painter->setBrush( enabledBrush ); } else { painter->setPen( disabledPen ); painter->setBrush( disabledBrush ); } painter->drawRect( QRectF( gcpItemMMX - 0.5, gcpItemMMY - 0.5, 1, 1 ) ); drawText( painter, gcpItemMMX + 2, gcpItemMMY + 2, QString::number(( *gcpIt )->id() ), QFont() ); mmPixelRatio = maxMMToPixelRatioForGCP( *gcpIt, gcpItemMMX, gcpItemMMY ); if ( mmPixelRatio < minMMPixelRatio ) { minMMPixelRatio = mmPixelRatio; } } //draw residual arrows gcpIt = mGCPList.constBegin(); for ( ; gcpIt != mGCPList.constEnd(); ++gcpIt ) { QgsPoint gcpCoords = ( *gcpIt )->pixelCoords(); double gcpItemMMX = ( gcpCoords.x() - mExtent.xMinimum() ) / mExtent.width() * widthMM; double gcpItemMMY = ( 1 - ( gcpCoords.y() - mExtent.yMinimum() ) / mExtent.height() ) * heightMM; if (( *gcpIt )->isEnabled() ) { painter->setPen( enabledPen ); } else { painter->setPen( disabledPen ); } QPointF p1( gcpItemMMX, gcpItemMMY ); QPointF p2( gcpItemMMX + ( *gcpIt )->residual().x() * minMMPixelRatio, gcpItemMMY + ( *gcpIt )->residual().y() * minMMPixelRatio ); painter->drawLine( p1, p2 ); painter->setBrush( QBrush( painter->pen().color() ) ); QgsComposerUtils::drawArrowHead( painter, p2.x(), p2.y(), QgsComposerUtils::angle( p1, p2 ), 1 ); } //draw scale bar double initialScaleBarWidth = rect().width() / 5; double scaleBarWidthUnits = rect().width() / 5 / minMMPixelRatio; //a simple method to round to next nice number int nDecPlaces; if ( scaleBarWidthUnits < 1 ) { nDecPlaces = -floor( log10( scaleBarWidthUnits ) ); scaleBarWidthUnits *= pow( 10.0, nDecPlaces ); scaleBarWidthUnits = ( int )( scaleBarWidthUnits + 0.5 ); scaleBarWidthUnits /= pow( 10.0, nDecPlaces ); } else { nDecPlaces = ( int )log10( scaleBarWidthUnits ); scaleBarWidthUnits /= pow( 10.0, nDecPlaces ); scaleBarWidthUnits = ( int )( scaleBarWidthUnits + 0.5 ); scaleBarWidthUnits *= pow( 10.0, nDecPlaces ); } initialScaleBarWidth = scaleBarWidthUnits * minMMPixelRatio; painter->setPen( QColor( 0, 0, 0 ) ); painter->drawLine( QPointF( 5, rect().height() - 5 ), QPointF( 5 + initialScaleBarWidth, rect().height() - 5 ) ); painter->drawLine( QPointF( 5, rect().height() - 5 ), QPointF( 5, rect().height() - 7 ) ); painter->drawLine( QPointF( 5 + initialScaleBarWidth, rect().height() - 5 ), QPointF( 5 + initialScaleBarWidth, rect().height() - 7 ) ); QFont scaleBarFont; scaleBarFont.setPointSize( 9 ); if ( mConvertScaleToMapUnits ) { drawText( painter, 5, rect().height() - 4 + fontAscentMillimeters( scaleBarFont ), QString( "%1 map units" ).arg( scaleBarWidthUnits ), QFont() ); } else { drawText( painter, 5, rect().height() - 4 + fontAscentMillimeters( scaleBarFont ), QString( "%1 pixels" ).arg( scaleBarWidthUnits ), QFont() ); } drawFrame( painter ); if ( isSelected() ) { drawSelectionBoxes( painter ); } }
void triggerEfficiency() { TCut trigCut; trigCut = "yhlt.HLT_HISinglePhoton40_v2"; // trigCut = "yhlt.HLT_HISinglePhoton30_v2"; //trigCut = "yhlt.L1_SingleEG5_BptxAND"; // trigCut = "yhlt.HLT_HISinglePhoton30_v2 "; // trigCut = "yhlt.L1_SingleEG5_BptxAND";// || yhlt.HLT_HIJet80_v1"; // || yhlt.HLT_HIJet80_v1"; TCut goodL1Cut = "yhlt.Run > 181675 && !(yhlt.Run==181912 || yhlt.Run==181910 || yhlt.Run==182089 || yhlt.Run==182098 || yhlt.Run==182099 || yhlt.Run==182124)"; TCut goodHLTCut = "!(yhlt.Run==182123 || yhlt.Run==182133 || yhlt.Run==181946) && yhlt.Run<=182134 "; TCut goodRunCut = goodL1Cut && goodHLTCut; const int nPtBin = 10; double ptBin[nPtBin+1] = {0,10,15,20,25,30,33,41,50,70,120}; TH1D* heff = new TH1D("heff",";Leading Photon E_{T} (GeV);",nPtBin, ptBin); TGraphAsymmErrors* geff = new TGraphAsymmErrors(); TCanvas* c1 = new TCanvas("c2","",610,522); c1->Divide(2,1); c1->cd(1); getEff(heff,geff,trigCut,ptMode, goodRunCut); handsomeTH1(heff,1); handsomeTGraph(geff,1); geff->SetMarkerStyle(20); heff->SetMarkerSize(0.1); for ( int i=0;i<= heff->GetNbinsX() ; i++) heff->SetBinError(i,0); heff->Draw(0); // heff->DrawCopy("pl"); geff->Draw("p"); drawText("HLT_HISinglePhoton40",0.4,0.3,1,18); c1->cd(2); TH1D* heffr = new TH1D("heffr",";Run number;",182400.5 - 181500.5,181500.5,182400.5); TGraphAsymmErrors* geffr = new TGraphAsymmErrors(); getEff(heffr,geffr,trigCut, runByRunMode, "pt>50" && goodRunCut); handsomeTH1(heffr,1); heffr->SetNdivisions(505); handsomeTGraph(geffr,1); geffr->SetMarkerStyle(20); heffr->Reset(); heffr->DrawCopy(); geffr->Draw("p"); TCanvas* c3 = new TCanvas("c3","",700,500); heff->SetYTitle("Efficiency"); heff->SetFillColor(kGray); heff->SetFillStyle(3001); heff->SetAxisRange(0,1.2,"Y"); heff->DrawCopy("hist "); geff->Draw("p same"); drawCMS3(0.5,0.5,84,17); drawText("HLT_HISinglePhoton40",0.5,0.3,1,18); c3->SaveAs("plot_triggerEfficiencyPhoton30.eps"); c3->SaveAs("plot_triggerEfficiencyPhoton30.gif"); }
// Draw feature with respect to the world frame void COpenGlDisplay::drawCurrentFeatures(CSLAM* SLAM) { if (0 == SLAM->m_nMatches) { return; } Point3f location, sigma; Quaternion axis; char text[10]; PointsMap* map_p = SLAM->map; while (NULL != map_p) { if (true == map_p->isMatching) { glPushMatrix(); location.x = (float)map_p->xyz.x; location.y = (float)map_p->xyz.y; if (TRUE == SLAM->isCompensate) { location.z = (float)(map_p->xyz.z + SLAM->m_deep)/2.0; } else { location.z = (float)map_p->xyz.z; } glTranslatef(location.x,location.y,location.z); // Move Left 1.5 Units And Into The Screen 6.0 glColor3f( 1.0f, 0.0f, 0.0f ); _itoa_s(map_p->ID, text, 10); drawText(text, 0.3); sigma.x = (float)map_p->sigma.x; sigma.y = (float)map_p->sigma.y; sigma.z = (float)map_p->sigma.z; axis = map_p->axis; float angle = 2*atan2(sqrt(axis.x*axis.x+axis.y*axis.y+axis.z*axis.z), axis.r); angle = angle*180/3.141593f; //glTranslatef(location.x,location.y,location.z); glRotated(angle, -axis.x, -axis.y, -axis.z); glScaled(min(4.0f,sigma.x),min(4.0f,sigma.y),min(4.0f,sigma.z)); glEnable(GL_LIGHTING); if (true == map_p->isLoop) { glColor3f( 0.0f, 1.0f, 0.0f ); } else { glColor3f( 1.0f, 0.0f, 0.0f ); } glutWireSphere(3.0f, 10,10); glPopMatrix(); } map_p = map_p->next; } }
Image* D2Data::renderItem(D2Item* item) { File* invfile = loadImageByName(item->image); if (!invfile) return NULL; DC6_FRAME frm; invfile->read(&frm, sizeof frm); int itemWidth = (frm.width + 28) / 29; int itemHeight = (frm.height + 28) / 29; if (item->base) { itemWidth = item->base->invwidth; itemHeight = item->base->invheight; } LocalPtr<D2Image> image = new D2Image(*invBackground); D2Font* font = getFont(); String desc = item->description; int gidSep = desc.lastIndexOf('$'); if (gidSep >= 0) desc.resize(gidSep); Array<String> lines; desc.split(lines, "\\n"); if (!lines.length()) return NULL; int ilvlSep = lines[0].lastIndexOf('('); if (ilvlSep >= 0) { lines[0].resize(ilvlSep); lines[0].trim(); } int boxWidth = 0; for (int i = 0; i < lines.length(); i++) { int width = font->width(lines[i], lines[i].length()); boxWidth = max(boxWidth, width); } boxWidth += 8; int boxHeight = 16 * lines.length(); int storType, storX, storY; int storRoom[2][16][16]; memset(storRoom, 0, sizeof storRoom); int validT[128]; int validX[128]; int validY[128]; int validNum = 0; for (int t = 0; t < 2; t++) { for (int x = 0; x + itemWidth <= storage[t].width; x++) { for (int y = 0; y + itemHeight <= storage[t].height; y++) { if (storage[t].y0 + y * 29 - boxHeight + 1 >= 0 || storage[t].y0 + (y + itemHeight) * 29 + boxHeight <= invBackground->height()) { validT[validNum] = t; validX[validNum] = x; validY[validNum] = y; validNum++; } } } } if (validNum) { validNum = (rand() % validNum); storType = validT[validNum]; storX = validX[validNum]; storY = validY[validNum]; } else { storType = 0; storY = 0; storX = (rand() % (storage[0].width - itemWidth + 1)); } int itemX = storage[storType].x0 + storX * 29; int itemY = storage[storType].y0 + storY * 29; image->fill(itemX, itemY - 1, itemX + itemWidth * 29, itemY - 1 + itemHeight * 29, 118, blendTable[2]); uint8* tint = NULL; if (item->base && item->invColor >= 0) tint = tints[item->base->invtrans][item->invColor]; drawDC6(image, itemX, itemY, &frm, invfile, tint, item->flags & D2Item::fEthereal ? blendTable[1] : NULL); for (int x = 0; x < itemWidth; x++) for (int y = 0; y < itemHeight; y++) storRoom[storType][storX + x][storY + y] = 1; if (item->parent) { for (int curi = 0; curi < item->parent->items.length(); curi++) { D2Item* curitem = item->parent->items[curi]; if (curitem == item) continue; File* curfile = loadImageByName(curitem->image); if (!curfile) continue; DC6_FRAME curfrm; curfile->read(&curfrm, sizeof curfrm); int curWidth = (curfrm.width + 28) / 29; int curHeight = (curfrm.height + 28) / 29; int curT = -1, curX, curY; for (int t = 0; t < 2 && curT < 0; t++) { for (int x = 0; x + curWidth <= storage[t].width && curT < 0; x++) { for (int y = 0; y + curHeight <= storage[t].height; y++) { int valid = 1; for (int cx = 0; cx < curWidth && valid; cx++) for (int cy = 0; cy < curHeight; cy++) { if (storRoom[t][x + cx][y + cy]) { valid = 0; break; } } if (valid) { curT = t; curX = x; curY = y; break; } } } } if (curT >= 0) { for (int x = 0; x < curWidth; x++) for (int y = 0; y < curHeight; y++) storRoom[curT][curX + x][curY + y] = 1; int scrX = storage[curT].x0 + curX * 29; int scrY = storage[curT].y0 + curY * 29; if (curitem->description.find("\\n\\xffc1") >= 0 || !strncmp(curitem->description, "\\xffc1", 6)) image->fill(scrX, scrY - 1, scrX + curWidth * 29, scrY - 1 + curHeight * 29, 8, blendTable[2]); else image->fill(scrX, scrY - 1, scrX + curWidth * 29, scrY - 1 + curHeight * 29, 234, blendTable[2]); uint8* tint = NULL; if (curitem->base && curitem->invColor >= 0) tint = tints[curitem->base->invtrans][curitem->invColor]; drawDC6(image, scrX, scrY, &curfrm, curfile, tint, curitem->flags & D2Item::fEthereal ? blendTable[1] : NULL); } } } if (item->sockets.length()) { File* soxImage = loadImage("data\\global\\ui\\PANEL\\gemsocket.dc6"); int sox = item->sockets.length(); if (sox > 6) sox = 6; D2Point const* pos = getSocketPos(itemWidth, itemHeight, sox); for (int i = 0; i < sox; i++) { soxImage->seek(0, SEEK_SET); drawDC6(image, itemX + pos[i].x - 1, itemY + pos[i].y + 1, NULL, soxImage, NULL, blendTable[2]); if (item->sockets[i] != "gemsocket") { File* gemfile = loadImageByName(item->sockets[i]); if (gemfile) drawDC6(image, itemX + pos[i].x, itemY + pos[i].y, NULL, gemfile); } } } int boxX = itemX + (itemWidth * 29 - boxWidth) / 2; if (boxX < 0) boxX = 0; if (boxX + boxWidth > image->width()) boxX = image->width() - boxWidth; int boxY = itemY - boxHeight + 1; if (boxY < 0) { boxY = itemY + itemHeight * 29; if (boxY + boxHeight > image->height()) boxY = image->height() - boxHeight; } image->fill(boxX, boxY, boxX + boxWidth, boxY + boxHeight, 0, blendTable[0]); for (int i = 0; i < lines.length(); i++) { int width = font->width(lines[i], lines[i].length()); int lineX = boxX + (boxWidth - width) / 2; int lineY = boxY + i * 16 + 8; drawText(image, lineX, lineY, lines[i], lines[i].length(), font); } int cursorX = itemX + itemWidth * 29 - 2 - (rand() % 10); int cursorY = itemY + 4 + (rand() % (itemHeight * 29 - 8)); drawFrames(image, "data\\global\\ui\\CURSOR\\protate.dc6", rand() % 8, 1, &cursorX, &cursorY); int resLeft = min(itemX, boxX) - 10; int resTop = min(itemY, boxY) - 10; int resRight = max(itemX + itemWidth * 29, boxX + boxWidth) + 10; int resBottom = max(itemY + itemHeight * 29, boxY + boxHeight) + 10; return image->image(resLeft, resTop, resRight, resBottom, palette); }
void drawTrkCorrPtvCent(Int_t corrLevel=0, //TString mod="hitrkEffAnalyzer", //TString modref="hitrkEffAnalyzer", //TString app="", //TString appref="", //TString mod="hitrkEffAnalyzer", //TString modref="hitrkEffAnalyzer", TString mod="hitrkEffAnalyzer_akpu3pf", TString modref="hitrkEffAnalyzer_akpu3pf", //TString mod="hiGoodTightTrkEffAnalyzer_icpu5calo_j2", //TString modref="hiGoodTightTrkEffAnalyzer_icpu5calo_j1", //TString modref="hiGoodTightTrkEffAnalyzer", //TString mod="hiGoodTightTrkEffAnalyzer", //TString app="_mattgmv1", TString appref="_ppcorrpthgtv4", TString app="_tev9hgtv4_3", //TString app="_tev6", //TString appref="_ppv1", //TString appref="_matthptv1", //TString app="_matthptv1", //TString appref="_ppz2gtv1", //TString app="_pp413hgtv1", //TString app="_tev8hgtv1", //TString appref="_tev8hgtv1", //TString app="_pp413hgtv1", //TString appref="_tev7hpt", //TString app="_tev7genjet", //TString appref="_tev7genjet", //TString app="_ppv1", //TString appref="_ppv1", //TString app="_pphptv1", //TString appref="_pphptv1", //TString app = "_LargeSet1_1k_rereco", //TString appref = "_LargeSet1_1k", //TString app="_jtv5_cv6", //TString appref="_jtv5_cv6", Int_t isample=0, // -1 for all samples Int_t etaPM=2 // +/- 2 for |eta|<1 ) { Int_t mode=1; // 0 for write, 1 for read Corrector3D trkCorr("trkCorrHisAna_djuq",app,mod); //Corrector3D trkCorr("trkhist_may052011_rereco_chi2_v2_hydjetBass_dijet",app,mod); trkCorr.ptHatMin_.clear(); trkCorr.ptHatMin_.push_back(30); trkCorr.ptHatMin_.push_back(50); trkCorr.ptHatMin_.push_back(80); trkCorr.ptHatMin_.push_back(110); trkCorr.ptHatMin_.push_back(170); trkCorr.sampleMode_ = 1; // 0 for choosing individual sample, 1 for merge samples trkCorr.Init(); Corrector3D trkCorrRef("trkCorrHisAna_djuq",appref,modref); //Corrector3D trkCorrRef("trkhist_may052011_rereco_chi2_v2_hydjetBass_dijet",appref,modref); trkCorrRef.ptHatMin_.clear(); trkCorrRef.ptHatMin_.push_back(30); trkCorrRef.ptHatMin_.push_back(50); trkCorrRef.ptHatMin_.push_back(80); trkCorrRef.ptHatMin_.push_back(110); trkCorrRef.ptHatMin_.push_back(170); trkCorrRef.sampleMode_ = 1; // 0 for choosing individual sample, 1 for merge samples trkCorrRef.Init(); cout << endl << "========= plot =========" << endl; Float_t jet1PtMin=40; Float_t jet2PtMin=40; Int_t jet1BegBin = trkCorrRef.jetBin_->FindBin(jet1PtMin); Int_t jet2BegBin = trkCorr.jetBin_->FindBin(jet2PtMin); Int_t jetEndBin = 20; cout << Form("jet pt %.0f bin: ",jet1PtMin) << jet1BegBin << Form(" %.0f bin: ",jet2PtMin) << jet2BegBin << endl; cout << "jet pt end bin: " << jetEndBin << endl; cout << "========================" << endl; // Get Eff/fake histograms TH1D * vhCorrPtRef[2][5], *vhCorrPt[2][5]; Int_t colors[10] = {kBlack,kRed,kYellow+2,kGreen+2,kBlue}; for (Int_t lv=0; lv<2; ++lv) { for (Int_t c=0; c<5; ++c) { vhCorrPt[lv][c] = (TH1D*) trkCorr.InspectCorr(lv,isample,c,c,jet2BegBin,jetEndBin,2,7-etaPM,7+etaPM); vhCorrPt[lv][c]->SetMarkerColor(colors[c]); handsomeTH1(vhCorrPt[lv][c]); vhCorrPt[lv][c]->SetAxisRange(1,119.9,"X"); vhCorrPt[lv][c]->SetAxisRange(0,1,"Y"); vhCorrPt[lv][c]->SetTitle(";Track p_{T} (GeV/c);A #times #epsilon"); vhCorrPt[lv][c]->SetTitleOffset(1.2); vhCorrPt[lv][c]->SetTitleSize(0.055); } vhCorrPtRef[lv][0] = (TH1D*) trkCorrRef.InspectCorr(lv,isample,0,4,jet1BegBin,jetEndBin,2,7-etaPM,7+etaPM); vhCorrPtRef[lv][0]->SetMarkerStyle(kOpenSquare); } TCanvas * cEff = new TCanvas("cEff","cEff",500,500); cEff->SetLogx(); vhCorrPt[0][0]->Draw("E"); for (Int_t lv=0; lv<2; ++lv) { for (Int_t c=4; c>=0; --c) { vhCorrPt[lv][c]->Draw("sameE"); } vhCorrPtRef[lv][0]->Draw("sameE"); } TLegend *leg0 = new TLegend(0.16,0.76,0.46,0.89); leg0->SetFillStyle(0); leg0->SetBorderSize(0); leg0->SetTextSize(0.04); leg0->AddEntry(vhCorrPt[0][0],"PYTHIA+HYDJET",""); //leg0->AddEntry(vhCorrPt[0][0],Form("#hat{p}_{T} 30,50,80,110,170 GeV/c"),""); leg0->AddEntry(vhCorrPt[0][0],Form("Jet p_{T} > %.0f GeV/c, Track |#eta|<1",jet1PtMin),""); leg0->Draw(); TLegend *leg = new TLegend(0.26,0.25,0.56,0.55); leg->SetFillStyle(0); leg->SetBorderSize(0); leg->SetTextSize(0.035); //leg->AddEntry(vhCorrPt[0][0],"Pre-Approval Track Selection",""); //leg->AddEntry(vhCorrPt[0][0],"hiGoodTight Tracks",""); leg->AddEntry(vhCorrPt[0][0],"Final Track Selection",""); leg->AddEntry(vhCorrPt[0][0],"0-5%","p"); leg->AddEntry(vhCorrPt[0][1],"5-10%","p"); leg->AddEntry(vhCorrPt[0][2],"10-20%","p"); leg->AddEntry(vhCorrPt[0][3],"30-50%","p"); leg->AddEntry(vhCorrPt[0][4],"50-90%","p"); leg->AddEntry(vhCorrPtRef[0][0],"pp","p"); leg->Draw(); drawText("CMS Simulation",0.64,0.89); drawText("Fake Rate",0.6,0.2); cEff->Print("TrkCorr_vs_Pt_vsCentrality"+app+".gif"); cEff->Print("TrkCorr_vs_Pt_vsCentrality"+app+".pdf"); }
void JRATanObj::draw(JGraphics g, int x, int y, int w, int h) { JRect rect(x, y, w, h); drawText(g, JString("ATan"), rect); }