Drawing a dotted line with TPolyLine3D

Dear all,

I am drawing tracks in the ROOT’s GL viewer with TPolyLine3D. I want to draw some tracks as dotted lines, so I set the style with the function SetLineStyle. I tried several styles, i.e. 2, 9, 10, … but I always get solid lines drawn. Does anyone has any hint?

Many thanks,

Alejandro

{
   TCanvas *c1 = new TCanvas("c1", "",1034,45,700,502);
   TView *view1 = TView::CreateView(1);
   view1->SetRange(0,0,0,2,2,2);
   
   TPolyLine3D *pline3D = new TPolyLine3D(100,"");
   pline3D->SetLineColor(2);
   pline3D->SetLineStyle(2);
   pline3D->SetLineWidth(2);
   pline3D->SetPoint(0,1.999483,0.3258198,0.5652356);
   pline3D->SetPoint(1,1.894402,0.4633131,0.9699472);
   pline3D->SetPoint(2,1.914954,1.488611,1.080087);
   pline3D->SetPoint(3,1.479906,1.519888,1.317273);
   pline3D->Draw();
}

Many thanks for the replay Couet,

I just tried your example and it works. But the thing is that I am drawing the TPolyLine3D objects in a canvas which is created by the ROOT’s GL viewer. I create this canvas by drawing a geometry in gdml as follows,

TGeoManager::Import(“geometry.gdml”);
gGeoManager->GetTopVolume()->Draw(“ogl”);

This creates an interactive canvas called “ROOT’s GL viewer”. I then draw the TPolyLine3D objects just by doing,

gtracksXYZ = new TPolyLine3D(nPoints,"");
gtracksXYZ->SetLineColor(kBlue);
gtracksXYZ->SetLineWidth(2);
gtracksXYZ->SetLineStyle(2);

for(int ipoint=0;ipoint<nPoints;ipoint++) {
gtracksXYZ[Nevents][itrk]->SetPoint(ipoint,X[ipoint],Y[ipoint],Z[ipoint]);
}

gtracksXYZ->Draw();

I manage to draw the TPolyLine3D object but it is always drawn as a solid line not a dotted one.

Do you have any other suggestion?

Many thanks,

Alejandro

Can you post a small running script reproducing the issue ?

Dear Couet,

Attached you a macro (Macro.cc) which you just need to run as follows,

root -l Macro.cc

For running it you will need the gdml geomtry file (Mygeometry.gdml.cc) which is also attached.

Let me know if you’re able to reproduce the problem.

Many thanks,

Alejandro

Macro.cc (610 Bytes)
Mygeometry.gdml.cc (6.68 KB)

Yes I see that the line is solid.

TEveLine supports GL stippling for line style 2-10 … the way TPolyLine3D is passed into GL discards these attributes.

Matevz

Many thanks matevz,

Is there any solution? The thing is that I would like to plot the real particle trajectories as dotted lines. I then use the hits of theses particles on silicon sensors in my geometry to fit a straight line. So, I would like then to plot the fitted straight line as a solid line on top of the real particle trajectory (which is a dotted line). In this representation it will be quite easy to see which trajectories where successfully fitted.

Thanks again,

Alejandro

Yes, just replace TPolyLine3D with TEveLine and you should be good … the interface for setting the points is the same.