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 ( )
1763: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)
1767 {
1768 if(eDraw==kFALSE) return;
1769 if(gEDA->GetScaleZ()==1.0) RenderBar(ctx);
1770 else RenderAxes(ctx);
1771}
EdbEDA * gEDA
Definition: EdbEDA.C:3
void RenderBar(TGLRnrCtx &ctx)
Definition: EdbEDA.C:1853
void RenderAxes(TGLRnrCtx &ctx)
Definition: EdbEDA.C:1773
double GetScaleZ()
Definition: EdbEDA.h:732

◆ RenderAxes()

void EdbEDAOverlay::RenderAxes ( TGLRnrCtx &  ctx)

Render 3 scale axes.

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

◆ RenderBar()

void EdbEDAOverlay::RenderBar ( TGLRnrCtx &  ctx)

Render a scale bar.

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

◆ SetDraw()

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

◆ SetLength()

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

◆ SetXY()

void EdbEDAOverlay::SetXY ( int  pixel_x = 50,
int  pixel_y = 30 
)
1764{ 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: