Exemplo n.º 1
0
bool TextWidget::on_expose_event(GdkEventExpose* event)
{
    Rect drw_rct = Planed::DevToRel(trans, MakeRect(event->area));
    CairoStateSave save(caiCont);

    CR::RectClip(caiCont, drw_rct);
    ClearCanvas(caiCont);

    // собственно отрисовка
    RenderByRegion(drw_rct);

    PaintRegion(drw_rct);
    return false;
}
Exemplo n.º 2
0
	inline void Renderer::Render(Camera* camera, Scene* scene) {
		
		if (p_surface == NULL || camera == NULL) return;

		if (m_width != p_surface->w || m_height != p_surface->h) {
			m_width = p_surface->w;
			m_height = p_surface->h;
			SetViewport(0.0f, 0.0f, m_width, m_height);

			if (camera->autoUpdate) {
				camera->Set(m_width, m_height);
				camera->Update();
			}
		}

		SetClearColor(camera->background, 1.0f);
		ClearCanvas(m_clearColor, m_clearDepth, m_clearStencil);
		
		if (scene == NULL) return;
		uint32 i, il;
		
		Array<Sprite*>* sprites = scene->GetComponents<Sprite>();
		if (sprites != NULL) {
			for (i = 0, il = sprites->Length(); i < il; i++) {
				Sprite* sprite = (*sprites)[i];
				GameObject* gameObject = sprite->GetGameObject();
				if (gameObject == NULL) continue;
				Transform* transform = gameObject->GetComponent<Transform>();
				if (transform == NULL) continue;
				
				transform->UpdateMatrices(camera->view);
				m_RenderSprite(camera, sprite, transform);
			}
		}
		
		Array<MeshFilter*>* meshFilters = scene->GetComponents<MeshFilter>();
		if (meshFilters != NULL) {
			for (i = 0, il = meshFilters->Length(); i < il; i++) {
				MeshFilter* meshFilter = (*meshFilters)[i];
				GameObject* gameObject = meshFilter->GetGameObject();
				if (gameObject == NULL) continue;
				Transform* transform = gameObject->GetComponent<Transform>();
				if (transform == NULL) continue;
				
				transform->UpdateMatrices(camera->view);
				m_RenderMeshFilter(camera, meshFilter, transform);
			}
		}
	}
Exemplo n.º 3
0
/** 
 * Draw energy loss fits to a multi-page PDF. 
 *
 * @par Input: 
 * The input file is expected to contain a AliFMDCorrELossFit object
 * named @c elossfits in the top level directory.
 * 
 * @par Output: 
 * A multi-page PDF.  Note, that the PDF generated by ROOT in this way
 * is broken (cannot be read by Acrobat Reader on Windows and MacOSX)
 * and one should pass it through a filter to correct these problems.
 * 
 * @param fname   File name 
 * @param option  Drawing options 
 *
 * @ingroup pwglf_forward_scripts_corr
 */
void
DrawCorrVtxBias(const char* fname, const char* option="colz")
{
  //__________________________________________________________________
  // Load libraries and object 
  gROOT->Macro("$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");

  TFile* file = TFile::Open(fname, "READ");
  if (!file) { 
    Error("DrawCorrVtxBias", "Failed to open %s", fname);
    return;
  }
  TString pname(fname);
  pname.ReplaceAll(".root", ".pdf");

  const char* objName = 
    AliForwardCorrectionManager::Instance()
    .GetObjectName(AliForwardCorrectionManager::kVertexBias);
  AliFMDCorrVertexBias* corr = 
    static_cast<AliFMDCorrVertexBias*>(file->Get(objName));
  if (!corr) { 
    Error("DrawCorrVtxBias", "Object '%s' not found in %s", objName, fname);
    return;
  }

  //__________________________________________________________________
  // Create a canvas
  TCanvas* c = new TCanvas("c", "c", 800 / TMath::Sqrt(2), 800);
  c->SetFillColor(0);
  c->SetBorderSize(0);
  c->SetBorderMode(0);
  c->Print(Form("%s[", pname.Data()));
  
  gStyle->SetOptStat(0);
  gStyle->SetTitleColor(0);
  gStyle->SetTitleStyle(0);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetTitleX(.1);
  gStyle->SetTitleY(1);
  gStyle->SetTitleW(.8);
  gStyle->SetTitleH(.09);
  gStyle->SetFrameFillColor(kWhite);
  gStyle->SetFrameBorderSize(1);
  gStyle->SetFrameBorderMode(1);
  gStyle->SetPalette(1);

  ClearCanvas(c);
  //__________________________________________________________________
  // Create a title page 
  TLatex* ll = new TLatex(.5,.8, fname);
  ll->SetTextAlign(22);
  ll->SetTextSize(0.03);
  ll->SetNDC();
  ll->Draw();

  TLatex* l = new TLatex(.5,.8, fname);
  l->SetNDC();
  l->SetTextSize(0.03);
  l->SetTextFont(132);
  l->SetTextAlign(12);
  l->DrawLatex(0.2, 0.70, "Vertex Bias Corrections");
  l->SetTextAlign(22);
  l->DrawLatex(0.5, 0.60,  "c_{v}(#eta,#phi)=#frac{1/N_{t}}{1/N_{v}}"
	       "#sum_{i}^{N_{tv}}N_{ch,i}(#eta,#phi) / "
	       "#sum_{i}^{N_{v}}N_{ch,i}(#eta,#phi)");
  l->SetTextAlign(12);
  l->DrawLatex(0.2, 0.50, "N_{t}: Number of events w/triggers");
  l->DrawLatex(0.2, 0.45, "N_{v}: Number of events w/vertex");
  l->DrawLatex(0.2, 0.40, "N_{tv}: Number of events w/trigger and vertex");
  l->DrawLatex(0.2, 0.35, "N_{ch,i}(#eta,#phi): Number of charged, "
	       "particles in (#eta,#phi) bin");
  l->DrawLatex(0.2, 0.30, "All quantities determined in MC");
  
  c->Print(pname.Data(), "Title:Title page");

  ClearCanvas(c);

  //__________________________________________________________________
  // Draw all corrections
  const TAxis& vtxAxis = corr->GetVertexAxis();
  Int_t        nVtx    = vtxAxis.GetNbins();
  UShort_t     nQ      = 2;
  UShort_t     d       = 0;
  for (UShort_t q = 0; q < nQ; q++) { 
    Char_t r = (q == 0 ? 'I' : 'O');

    ClearCanvas(c);
    c->Divide(2, (nVtx+1)/2);
    for (UShort_t v=1; v <= nVtx; v++) { 
      TVirtualPad* p = c->cd(v);
      
      
      TH2* h1 = corr->GetCorrection(r, v);
      if (!h1) { 
	Warning("DrawCorrVtxBias", "No correction for r=%c, v=%d", r, v);
	continue;
      }
      h1->Draw(option);
    }
    c->Print(pname.Data(), Form("Title:FMDX%c", r));
  }

  //__________________________________________________________________
  // Close output file 
  c->Print(Form("%s]", pname.Data()));
}