Hi Rooters, I have observed a very stange behaviour in TNode (I am sure that I am guilty!!!). I have defined a class, ANTLcm, where a volume is defined and placed inside a mother volume (code below). In the main program I have defined a main volume called mother where an ANTLcm menber is placed. When I check that everything is Ok by doing a mainnode->ls(), my ANTLcm menber is correctly placed inside the main volume. However when I try to pick the ANTLcm menber with the mouse, it doesn't work. Moreover I have observed with the ROOT event status that this member is detected at the center of the main volume. Does somebody have an idea of the problem? Thank you very much, Stephane BASA ////////////////////////////////////////////////////////////////////////// // main program // ////////////////////////////////////////////////////////////////////////// #include <iostream.h> #include "TROOT.h" #include "TApplication.h" #include "TCanvas.h" #include "TPad.h" #include "TTUBE.h" #include "TNode.h" #include "ANTLcm.h" extern void InitGui(); VoidFuncPtr_t initfuncs[] = { InitGui, 0 }; int Error; // needed by Motif TROOT root("hello","Hello World",initfuncs); int main(int argc, char **argv) { Int_t nb; // One application is defined (interactive mode) TApplication *theApp = new TApplication("App", &argc, argv); // We define a pad where we are going to work TCanvas *c1 = new TCanvas("Ant","The Ant Program", 200,10,700,780); TPad *mainpad = new TPad("mainpad","mainpad",0.02,0.02,0.98,0.98,41); mainpad->Draw(); mainpad->cd(); // Volume definition TTUBE *mother = new TTUBE("mother","Mother Volume","void",0.,300.,300.); TNode *mainnode = new TNode("mainnode","Main node","mother"); mainnode->Draw(); mainnode->cd(); for (nb=1;nb<=2;nb++) { ANTLcm *lcm = new ANTLcm(nb,30.,30.,30.,100-50*(nb-1),100-50*(nb-1),100-50*(nb-1)); lcm->Draw(); } mainnode->ls(); mainnode->Paint(); //To force the drawing mainpad->cd(); mainpad->Modified(); c1->Update(); // "Exit ROOT" will quit the app. theApp->Run(); return 0; } ////////////////////////////////////////////////////////////////////////// // ANTLcm.h // ////////////////////////////////////////////////////////////////////////// #ifndef ANTLcm_H #define ANTLcm_H #include "TObject.h" #include "TNode.h" #include "TBRIK.h" class ANTLcm: public TObject { private: Char_t title[20]; Char_t name[20]; Int_t num; Float_t XLength; Float_t YLength; Float_t ZLength; Double_t Xpos; Double_t Ypos; Double_t Zpos; TBRIK *brick; TNode *node; public: ANTLcm(Int_t,Float_t,Float_t,Float_t,Double_t,Double_t,Double_t); ANTLcm(); ~ANTLcm(); void Print(); //*MENU* Int_t DistancetoPrimitive(Int_t px, Int_t py); void ExecuteEvent(Int_t event, Int_t px, Int_t py); ClassDef(ANTLcm,1) //ANTLcm Local Controler Module class }; #endif ////////////////////////////////////////////////////////////////////////// // ANTLcm.cxx // ////////////////////////////////////////////////////////////////////////// #include "TCanvas.h" #include "TNode.h" #include "TBRIK.h" #include "ANTLcm.h" ClassImp(ANTLcm) //_____________________________________________________________________________ // Constructor ANTLcm::ANTLcm(Int_t i,Float_t LX,Float_t LY,Float_t LZ,Double_t X,Double_t Y,Double_t Z) { // Initialisation num = i ; // LCM number XLength = LX/2.; // Half length along X YLength = LY/2.; // Half length along Y ZLength = LZ/2.; // Half length along Z Xpos = X ; // X position in the mother volume Ypos = Y ; // Y position in the mother volume Zpos = Z ; // Z position in the mother volume // Define the title and the node name sprintf(name,"LCM%i",num); sprintf(title,"LCM %i",num); // Sphere initialisation brick = new TBRIK("brick","My brick","void",XLength,YLength,ZLength); // Set shapes attributes brick->SetLineColor(4); // Node initialisation node = new TNode(name,title,"brick",Xpos,Ypos,Zpos); //node->Draw("same"); } //_____________________________________________________________________________ // Default onstructor ANTLcm::ANTLcm() { //To be filled } //_____________________________________________________________________________ // Destructor ANTLcm::~ANTLcm() { //To be filled } //_____________________________________________________________________________ void ANTLcm::Print() { printf("LCM number %i \n",num); printf("Length along X=%f , Y=%f , Z=%f \n",XLength,YLength,ZLength); printf("Xpos=%f , Ypos=%f , Zpos=%f \n",Xpos,Ypos,Zpos); } //_____________________________________________________________________________ Int_t ANTLcm::DistancetoPrimitive(Int_t px, Int_t py) //*-*-*-*-*-*-*-*-*-*-*Compute distance from point px,py to a Node*-*-*-*-*-* //*-* =========================================== //*-* Compute the closest distance of approach from point px,py to this node. //*-* The distance is computed in pixels units. //*-* //*-* //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* { //*-*-*-*-*-*-*-*-*-*-*Compute distance from point px,py to a Node*-*-*-*-*-* //*-* =========================================== //*-* Compute the closest distance of approach from point px,py to this node. //*-* The distance is computed in pixels units. //*-* //*-* //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* Int_t dist; dist = node->DistancetoPrimitive(px,py); return dist; } //_____________________________________________________________________________ void ANTLcm::ExecuteEvent(Int_t event, Int_t px, Int_t py) { //*-*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-* //*-* ========================================= switch (event) { case kButton1Down: printf("je suis dans %s \n",title); break; case kMouseMotion: break; case kButton1Motion: break; case kButton1Up: break; } }
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:31 MET