FEDRA emulsion software from the OPERA Collaboration
EdbEDAOverlay Class Reference

#include <EdbEDA.h>

Inheritance diagram for EdbEDAOverlay:
Collaboration diagram for EdbEDAOverlay:

Public Member Functions

 EdbEDAOverlay ()
 
void Render (TGLRnrCtx &ctx)
 
void RenderAxes (TGLRnrCtx &ctx)
 
void RenderBar (TGLRnrCtx &ctx)
 
void SetDraw (bool b)
 
void SetLength (int pixel_length=120)
 
void SetXY (int pixel_x=50, int pixel_y=30)
 
 ~EdbEDAOverlay ()
 

Private Attributes

int eBarDirection
 
bool eDraw
 
int eLength
 
int eXa
 
int eXb
 
int eYa
 
int eYb
 

Constructor & Destructor Documentation

◆ EdbEDAOverlay()

EdbEDAOverlay::EdbEDAOverlay ( )
1762 :eDraw(1), eXa(80), eYa(30), eLength(120), eXb(50), eYb(20){}
int eLength
Definition: EdbEDA.h:110
bool eDraw
Definition: EdbEDA.h:109
int eXb
Definition: EdbEDA.h:111
int eYb
Definition: EdbEDA.h:111
int eXa
Definition: EdbEDA.h:110
int eYa
Definition: EdbEDA.h:110

◆ ~EdbEDAOverlay()

EdbEDAOverlay::~EdbEDAOverlay ( )
inline
115 {}

Member Function Documentation

◆ Render()

void EdbEDAOverlay::Render ( TGLRnrCtx &  ctx)
1766  {
1767  if(eDraw==kFALSE) return;
1768  if(gEDA->GetScaleZ()==1.0) RenderBar(ctx);
1769  else RenderAxes(ctx);
1770 }
EdbEDA * gEDA
Definition: EdbEDA.C:3
void RenderBar(TGLRnrCtx &ctx)
Definition: EdbEDA.C:1852
void RenderAxes(TGLRnrCtx &ctx)
Definition: EdbEDA.C:1772
double GetScaleZ()
Definition: EdbEDA.h:732

◆ RenderAxes()

void EdbEDAOverlay::RenderAxes ( TGLRnrCtx &  ctx)
1772  {
1773  // Render 3 scale axes.
1774 
1775  // view port to world.
1776  TGLCamera& cam = ctx.RefCamera();
1777  TGLLine3 l1 = cam.ViewportToWorld(eXa,eYa);
1778  TGLLine3 l2 = cam.ViewportToWorld(eXa+eLength,eYa);
1779 
1780  // find distance between 2 lines.
1781  const TGLVector3& glv1 = l1.Vector();
1782  const TGLVector3& glv12 = l2.Start()-l1.Start();
1783  TVector3 v1(glv1.X(), glv1.Y(), glv1.Z());
1784  v1.SetMag(1.);
1785  TVector3 v12(glv12.X(), glv12.Y(), glv12.Z());
1786  TVector3 vx = v1.Cross(v12);
1787  double d1 = vx.Mag();
1788 
1789  // find
1790  double d;
1791  for(int i=0;i<10;i++){
1792  if( d1 < 2*TMath::Power(10,i) ) { d=1*TMath::Power(10,i); break; }
1793  if( d1 < 5*TMath::Power(10,i) ) { d=2*TMath::Power(10,i); break; }
1794  if( d1 < 10*TMath::Power(10,i) ) { d=5*TMath::Power(10,i); break; }
1795  d=d1;
1796  }
1797  //printf("%lf %lf\r", d, d1);
1798 
1799 
1800  // Draw Text
1801  TGLLine3 l3 = cam.ViewportToWorld(eXa+10,eYa+20);
1802  const TGLVertex3& glp31=l3.Start();
1803  const TGLVertex3& glp32=l3.End();
1804  TVector3 vec31(glp31.CArr());
1805  TVector3 vec32(glp32.CArr());
1806  TVector3 p31 = (vec31+vec32)*0.5;
1807 
1808  TString num=Form(" %d um",(int)d);
1809 #if ROOT_VERSION_CODE>=ROOT_VERSION(5,26,00)
1810  TGLUtil::Color(kWhite);
1811  TGLFont font;
1812  ctx.RegisterFont(12, "arial", TGLFont::kBitmap, font);
1813  font.PreRender();
1814  font.Render(num, p31.X(), p31.Y(), p31.Z(), TGLFont::kLeft, TGLFont::kTop);
1815  font.PostRender();
1816 
1817  TGLUtil::LineWidth(1.0);
1818 #else
1819  gEve->GetBrowser()->SetStatusText(num,0);
1820 #endif
1821 
1822  // Light off
1823  TGLCapabilitySwitch lights_off(GL_LIGHTING, kFALSE); // need TGLIncludes.h
1824 
1825  // Draw Line
1826  const TGLVertex3& glp1=l1.Start();
1827  const TGLVertex3& glp2=l1.End();
1828  TVector3 vec1(glp1.CArr());
1829  TVector3 vec2(glp2.CArr());
1830  TVector3 p1 = (vec1+vec2)*0.5;
1831  TVector3 p2;
1832 
1833  TGLUtil::Color3f(1.,0.,0.);
1834  TGLVertex3 glpos(p1.X(), p1.Y(), p1.Z());
1835  TGLVertex3 glpos2(p1.X()+d, p1.Y(), p1.Z());
1836  TGLLine3 lx(glpos, glpos2);
1837  lx.Draw();
1838 
1839  TGLUtil::Color3f(0.,1.,0.);
1840  glpos2.Set(p1.X(), p1.Y()+d, p1.Z());
1841  TGLLine3 ly(glpos, glpos2);
1842  ly.Draw();
1843 
1844  TGLUtil::Color(kCyan);
1845  glpos2.Set(p1.X(), p1.Y(), p1.Z()+d*gEDA->GetScaleZ());
1846  TGLLine3 lz(glpos, glpos2);
1847  lz.Draw();
1848 
1849 
1850 }
void d()
Definition: RecDispEX.C:381

◆ RenderBar()

void EdbEDAOverlay::RenderBar ( TGLRnrCtx &  ctx)
1852  {
1853  // Render a scale bar.
1854 
1855  // view port to world.
1856  TGLCamera& cam = ctx.RefCamera();
1857  TGLLine3 l1 = cam.ViewportToWorld(eXb,eYb);
1858  TGLLine3 l2 = cam.ViewportToWorld(eXb+eLength,eYb);
1859 
1860  // find distance between 2 lines.
1861  const TGLVector3& glv1 = l1.Vector();
1862  const TGLVector3& glv12 = l2.Start()-l1.Start();
1863  TVector3 v1(glv1.X(), glv1.Y(), glv1.Z());
1864  v1.SetMag(1.);
1865  TVector3 v12(glv12.X(), glv12.Y(), glv12.Z());
1866  TVector3 vx = v1.Cross(v12);
1867  double d1 = vx.Mag();
1868 
1869  // find
1870  double d;
1871  for(int i=0;i<10;i++){
1872  if( d1 < 2*TMath::Power(10,i) ) { d=1*TMath::Power(10,i); break; }
1873  if( d1 < 5*TMath::Power(10,i) ) { d=2*TMath::Power(10,i); break; }
1874  if( d1 < 10*TMath::Power(10,i) ) { d=5*TMath::Power(10,i); break; }
1875  d=d1;
1876  }
1877  //printf("%lf %lf\r", d, d1);
1878 
1879  // position
1880  const TGLVertex3& p1=l1.Start();
1881  const TGLVertex3& p2=l2.End();
1882  TVector3 pp1(p1.X(), p1.Y(), p1.Z());
1883  TVector3 pp2(p2.X(), p2.Y(), p2.Z());
1884  TVector3 p=pp1*0.9+pp2*0.1-vx*0.05;
1885  TString num=Form("%d",(int)d);
1886 
1887  // Light off
1888  TGLCapabilitySwitch lights_off(GL_LIGHTING, kFALSE); // need TGLIncludes.h
1889 
1890 #if ROOT_VERSION_CODE>=ROOT_VERSION(5,26,00)
1891  TGLUtil::Color(kWhite);
1892  TGLFont font;
1893  ctx.RegisterFont(12, "arial", TGLFont::kBitmap, font);
1894  font.Render(num, p.X(), p.Y(), p.Z(), TGLFont::kLeft, TGLFont::kTop);
1895  TGLUtil::LineWidth(2.0);
1896 #else
1897  gEve->GetBrowser()->SetStatusText(num,0);
1898 #endif
1899 
1900 
1901  // Draw Line
1902  const Float_t col[4]={1.0,0.0,0.0,0.0};
1903  TGLUtil::Color4fv(col);
1904  TGLVector3 vec12=(l2.End()-l1.Start())*(d/d1);
1905  TGLLine3 l(l1.Start(), vec12);
1906  l.Draw();
1907 
1908  // Draw Text
1909 
1910 
1911 
1912  // doesn't work.
1913  //TGLText tx;
1914  //tx.SetGLTextFont(41);
1915  //tx.SetTextColor(kWhite);
1916  //tx.SetTextSize(12);
1917  //tx.PaintGLText(p.X(), p.Y(), p.Z(),Form("%d", (int) d));
1918 
1919  // doesn't work.
1920  // TGLUtil::DrawNumber(num, p);
1921 
1922  // doesn't work.
1923  // TGLFont f;
1924  // ctx.RegisterFont(12, "arial", TGLFont::kBitmap, f);
1925  // f.Render(num, p.X(), p.Y(), p.Z(), 0);
1926 
1927  // works but need OpenGL32.lib
1928  /* const char *txt=Form("%d",(int)d);
1929  Float_t bb[6];
1930  TGLFont font;
1931  ctx.RegisterFont(12, "arial", TGLFont::kBitmap, font);
1932  font.BBox(txt, bb[0], bb[1], bb[2], bb[3], bb[4], bb[5]);
1933  glPushMatrix();
1934  glTranslated(p.X(), p.Y(), p.Z());
1935  glRasterPos2i(0,0);
1936  font.Render(txt, );
1937  glPopMatrix();
1938  */
1939 
1940 }
p
Definition: testBGReduction_AllMethods.C:8

◆ SetDraw()

void EdbEDAOverlay::SetDraw ( bool  b)
inline
119 {eDraw=b;}

◆ SetLength()

void EdbEDAOverlay::SetLength ( int  pixel_length = 120)
1764 {if(gEDA->GetScaleZ()==1.0) eLength=pixel_length; else eLength=pixel_length;}

◆ SetXY()

void EdbEDAOverlay::SetXY ( int  pixel_x = 50,
int  pixel_y = 30 
)
1763 { if(gEDA->GetScaleZ()==1.0) eXb=pixel_x, eYb=pixel_y; else eXa=pixel_x, eYa=pixel_y;}

Member Data Documentation

◆ eBarDirection

int EdbEDAOverlay::eBarDirection
private

◆ eDraw

bool EdbEDAOverlay::eDraw
private

◆ eLength

int EdbEDAOverlay::eLength
private

◆ eXa

int EdbEDAOverlay::eXa
private

◆ eXb

int EdbEDAOverlay::eXb
private

◆ eYa

int EdbEDAOverlay::eYa
private

◆ eYb

int EdbEDAOverlay::eYb
private

The documentation for this class was generated from the following files: