Hi,
I have a simple code which displays 12 wires with TGeo objects. Everything looks fine in the 2D view. But when I start the opengl mode in the MenuClicked method only one wire is displayed in the opengl window.
What’s wrong with my code?
code:
void DCTDriftChamber::Init()
{
int i,j;
char volumeName[100];
char shapeName[100];
fCanvas = new TRootEmbeddedCanvas(“DriftChamberCanvas”, this, 800, 400);
AddFrame(fCanvas,
new TGLayoutHints(kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 0, 0, 1, 1));
// manager
fGeoManager = new TGeoManager( “Example”, “Example geometry” );
// define materials
fGeoMaterialVacuum = new TGeoMaterial( “Vacuum”, 0, 0, 0 );
fGeoMaterialAl = new TGeoMaterial( “Al”, 26.98, 13, 2.7 );
// define mediums
fGeoMediumVacuum = new TGeoMedium( “MediumVacuum”, 0, fGeoMaterialVacuum );
fGeoMediumAl = new TGeoMedium( “MediumAl”, 1, fGeoMaterialAl );
// define vacuum
fGeoVolumeVacuum = fGeoManager->MakeBox( “VolumeVacuum”, fGeoMediumVacuum, 800., 800., 800. );
// add vacuum
fGeoManager->SetTopVolume( fGeoVolumeVacuum );
TGeoRotation *rot = new TGeoRotation(“rot”,0,90,90);
// wires
fAnodeWire = new TGeoVolume**[4];
for (i=0;i<4;i++) {
fAnodeWire[i] = new TGeoVolume*[3];
for (j=0;j<3;j++) {
sprintf(volumeName,“volumeAnodeWire_%d_%d”,i,j);
sprintf(shapeName,“shapeAnodeWire_%d_%d”,i,j);
fAnodeWire[i][j] = new TGeoVolume(volumeName,new TGeoTube( shapeName, 0, 0.5, 115) , fGeoMediumAl);
fGeoVolumeVacuum->AddNode(fAnodeWire[i][j],1,new TGeoCombiTrans(9j,0,20i,rot));
}
}
// close and draw
fGeoManager->CloseGeometry();
fGeoVolumeVacuum->Draw();
}
void DCTDriftChamber::MenuClicked(TGPopupMenu *menu,Long_t param)
{
int exitID=1,i,j;
bool flag = true;
switch (param) {
case gWindow->M_VIEW_OPENGL:
TViewerOpenGL gl = new TViewerOpenGL(fCanvas->GetCanvas());
gl->BeginScene();
for (i=0;i<4;i++) {
for (j=0;j<3;j++) {
gl->AddObject(i3+j,fAnodeWire[i][j]->GetShape()->GetBuffer3D(0,0));
}
}
gl->EndScene();
break;
}
}