TridPageSlice Class Reference

#include <TridPageSlice.h>

Inheritance diagram for TridPageSlice:
TridPage PageABC

List of all members.

Public Member Functions

 TridPageSlice ()
virtual ~TridPageSlice ()
virtual TObject * Init (Mint *mint, PageDisplay *pageDisplay, GuiBox &box)
virtual TridGLFrameCreateNewGLFrame (TridPage::ViewMode_t mode)
virtual void CreateModels ()
virtual void CreateSketches ()
virtual void CreateScenery ()
virtual void ModifySketches ()

Private Member Functions

TVector3 SliceColor (int c)

Detailed Description

Definition at line 28 of file TridPageSlice.h.


Constructor & Destructor Documentation

TridPageSlice::TridPageSlice (  ) 

Definition at line 27 of file TridPageSlice.cxx.

References TridPage::fAutoPOV, TridPage::fFullPOV, TridPage::fViewMode, TridPage::fViewModesSupported, TridPage::fWindowName, kHeight, TridPage::kView2D, TridPage::kView3D, kWidth, and TridPOV::Set().

00027                              : TridPage()
00028 {
00029   // Default view.
00030   fViewModesSupported = kView2D | kView3D;
00031   fViewMode = kView2D;
00032   fWindowName = "TridSlice";
00033   fFullPOV.Set(kWidth*0.5, 0, -kHeight*0.5, 9, 90, 0 );  
00034   fAutoPOV.Set(kWidth*0.5, 0, -kHeight*0.5, 9, 90, 0 );  
00035 }

TridPageSlice::~TridPageSlice (  )  [virtual]

Definition at line 37 of file TridPageSlice.cxx.

00038 {
00039 }


Member Function Documentation

void TridPageSlice::CreateModels (  )  [virtual]

Reimplemented from TridPage.

Definition at line 63 of file TridPageSlice.cxx.

References TridModelList::Clear(), TridModelMaker::CreateSliceModels(), TridPage::fMint, TridPage::fModels, TridPage::fTridControl, Mint::GetJobC(), JobC::Mom, and TridModelMaker::Prepare().

00064 {
00065   fModels.Clear();
00066   fTridControl->ClearPicked();
00067   fTridControl->ClearSelected();
00068 
00069   TridModelMaker maker;
00070   maker.Prepare(&(fMint->GetJobC().Mom));
00071   maker.CreateSliceModels(&(fMint->GetJobC().Mom),fModels);
00072 }

TridGLFrame * TridPageSlice::CreateNewGLFrame ( TridPage::ViewMode_t  mode  )  [virtual]

Reimplemented from TridPage.

Definition at line 48 of file TridPageSlice.cxx.

References TridPage::fGuiBox, TridPage::fTridControl, Msg::kDebug, kHeight, TridPage::kView2D, kWidth, max, min, and MSG.

00049 {
00050   TridPOV min(-kWidth   ,0, -kHeight,        0, 0,-180);
00051   TridPOV max(kWidth*2  ,0, +kHeight*2,   1000,90, 180);
00052   
00053   if(mode==kView2D) {
00054     MSG("TriD",Msg::kDebug) << "Changing to 2D" << endl;
00055     return new TridFlatGLFrame(this,*fGuiBox,fTridControl,min,max,1.5);
00056   };
00057 
00058   MSG("TriD",Msg::kDebug) << "Changing to 3D" << endl;
00059   return new TridGLFrame(this,*fGuiBox,fTridControl,min,max);
00060 }

void TridPageSlice::CreateScenery (  )  [virtual]

Reimplemented from TridPage.

Definition at line 161 of file TridPageSlice.cxx.

References TridPage::fContext, TridPage::fGLFrame, Form(), TridPage::fTridControl, VldContext::GetDetector(), Detector::kFar, kHeight, kv_x(), kv_y(), kv_z(), kWidth, TridSketch::SetColor(), TridSketch::SetDefaultColor(), TridSketchText::SetScale(), TridSketchText::SetThickness(), TridSketch::StartScenery(), and TridSketch::StopScenery().

00162 {  
00163   TridSketch::SetDefaultColor(fTridControl->GetForegroundColor());
00164   TridSketch::StartScenery();
00165       // Put a black quad behind everything so mouse movement works better.
00166 
00167   
00168   TridSketch* backplane = new TridSketchPlane
00169     ( TVector3(kWidth* 0.5, -1.0, kHeight*0.5),
00170       kv_x, kWidth  * 4,
00171       kv_z, kHeight * 4 
00172       );
00173   backplane->SetColor(fTridControl->GetBackgroundColor());
00174   fGLFrame->AddSketch(backplane);
00175   
00176 
00177   TridSketch* l;
00178 
00179   l = new TridSketchLine( TVector3(0, -0.1, 0),
00180                           TVector3(0, -0.1, -kHeight) );
00181   fGLFrame->AddSketch(l);
00182 
00183   l = new TridSketchLine( TVector3(0,      -0.1, 0),
00184                           TVector3(kWidth, -0.1, 0) );
00185   fGLFrame->AddSketch(l);
00186 
00187   TridSketchText* txt;
00188   for(int i=0;i<=10;i+=2) {
00189     l = new TridSketchLine( TVector3((double)i,      -0.1, 0),
00190                             TVector3((double)i,      -0.1, 0.1)
00191                             );
00192     fGLFrame->AddSketch(l);
00193 
00194     txt = new TridSketchText( TVector3((double)i, -0.1, 0.5), -kv_z, kv_y, 
00195                               Form("%d us",i) );
00196     txt->SetScale(0.2);
00197     txt->SetThickness(0.005);
00198     fGLFrame->AddSketch(txt);
00199   }
00200   
00201   l = new TridSketchLine( TVector3(   0, -0.1, 0 ),
00202                           TVector3(-0.2, -0.1, 0 ) );
00203   fGLFrame->AddSketch(l);
00204 
00205   txt = new TridSketchText( TVector3(-0.5, -0.1, 0), -kv_z, kv_y, "Plane 0");
00206   txt->SetScale(0.2);
00207   txt->SetThickness(0.005);
00208   fGLFrame->AddSketch(txt);
00209 
00210   l = new TridSketchLine( TVector3(   0, -0.1, -kHeight ),
00211                           TVector3(-0.2, -0.1, -kHeight ) );
00212   fGLFrame->AddSketch(l);
00213 
00214   txt = new TridSketchText( TVector3(-1.0, -0.1, -kHeight), -kv_z, kv_y, 
00215                             (fContext.GetDetector()==Detector::kFar)?("Plane 295"):("Plane 120"));
00216   txt->SetScale(0.2);
00217   txt->SetThickness(0.005);
00218   fGLFrame->AddSketch(txt);
00219   
00220 
00221   TridSketch::StopScenery();
00222 }

void TridPageSlice::CreateSketches (  )  [virtual]

Reimplemented from TridPage.

Definition at line 81 of file TridPageSlice.cxx.

References TridModelList::AssociateModel(), TridModelList::ClearAssociations(), MuELoss::e, TridPage::fContext, TridPage::fGLFrame, TridModelSlice::fHits, TridPage::fModels, VldContext::GetDetector(), TridModel::GetEarliestTime(), TridSketch::GetId(), TridModelList::GetIterator(), TridModel::GetLatestTime(), Detector::kFar, kHeight, kv_x(), kv_y(), kv_z(), Msg::kWarning, kWidth, MSG, TridModelItr::Next(), TridSketch::SetColor(), TridSketch::SetTime(), and SliceColor().

00082 {  
00083   fModels.ClearAssociations();
00084 
00085   TridModel* basemodel;
00086 
00087   // First, loop through to get the start/stop times.
00088   double tlow = 1e19;
00089   double thigh = -1e19;
00090   Int_t  nslices = 0;
00091 
00092   TridModelItr itr1 = fModels.GetIterator();
00093   while( (basemodel = itr1.Next()) ) {    
00094     // Make a new sketch for this model.
00095     TridModelSlice* slice = dynamic_cast<TridModelSlice*>(basemodel);
00096     if(slice) {
00097       nslices++;
00098       cout << nslices << " " << slice->GetEarliestTime() << " " << slice->GetLatestTime() << endl;
00099       if(slice->GetEarliestTime()<tlow) tlow = slice->GetEarliestTime();
00100       if(slice->GetLatestTime()>thigh)  thigh = slice->GetLatestTime();     
00101     }
00102   }
00103 
00104   if(nslices==0) return;
00105   if(tlow>1) {
00106     MSG("TriD",Msg::kWarning) << "Strange slice times. tlow=" << tlow << " thigh=" << thigh << std::endl;
00107   }
00108 
00109   thigh = tlow + 10.0e-6; // 10 us.
00110 
00111   // Set Z limits
00112   double zlow=0;
00113   double zhigh=120; // plane 120 
00114   if(fContext.GetDetector()==Detector::kFar) {
00115     zhigh = 294;
00116   }
00117 
00118   int icolor = 0;
00119 
00120   // Now loop through again to draw.
00121   TridModelItr itr2 = fModels.GetIterator();
00122   while( (basemodel = itr2.Next()) ) {    
00123     // Make a new sketch for this model.
00124     TridModelSlice* slice = dynamic_cast<TridModelSlice*>(basemodel);
00125 
00126     if(slice) {
00127       //       cout << "Drawing slice " << slice->GetSlice() << endl;
00128       //       cout << "  Hits: " << slice->fHits.size() << endl; 
00129       //       cout << "  Time start: " << slice->GetEarliestTime()-tlow << endl;
00130       //       cout << "  Time start: " << slice->GetLatestTime()  -tlow << endl;
00131       //       cout << "  Color: " << icolor << endl;
00132       
00133       for(UInt_t i=0; i< slice->fHits.size(); i++) {
00134         double z = slice->fHits[i].fPlane - zlow;
00135         double t = slice->fHits[i].fTime - tlow;
00136         double x = (t) /(thigh-tlow) * kWidth;
00137         double y = (z) /(zhigh-zlow) * kHeight;
00138         double w = (50e-9) /(thigh-tlow) * kWidth;   // duration of a hit
00139         double h = (2)      /(zhigh-zlow) * kHeight;
00140 
00141         cout << "   Hit: " << z << "\t" << t 
00142           << "\t" << x << "\t" << y << endl;
00143         double depth = 0.1;
00144         
00145         TVector3 pos(x+w*0.5,0,-(y+h*0.5));
00146         TridSketch* sk = new TridSketchBox(pos,
00147                                            kv_x, w*0.5,
00148                                            kv_z, h*0.5,
00149                                            kv_y, depth/2.);
00150         sk->SetTime(t);
00151         sk->SetColor(SliceColor(icolor));
00152         fGLFrame->AddSketch(sk);
00153         fModels.AssociateModel(slice,sk->GetId());
00154       }
00155       
00156     }
00157     icolor++;
00158   }
00159 }

TObject * TridPageSlice::Init ( Mint mint,
PageDisplay pd,
GuiBox box 
) [virtual]

Implement to fill box with whatever your page displays. If the page wishes to return a class to the initializer, then return an object which inherits from TObject, o.w. just return 0.

Reimplemented from TridPage.

Definition at line 42 of file TridPageSlice.cxx.

References Msg::kDebug, and MSG.

00043 {
00044   MSG("TriD",Msg::kDebug) << "TridPageSlice: Init()\n";
00045   return TridPage::Init(mint, pageDisplay, box);
00046 }

void TridPageSlice::ModifySketches (  )  [virtual]

Reimplemented from TridPage.

Definition at line 225 of file TridPageSlice.cxx.

References TridPage::fColorHistogram, TridPage::fGLFrame, TridPage::fModels, TridPage::fTransHistogram, TridPage::fTridControl, TridModel::GetId(), TridModelList::GetModelFromSketch(), TridModel::GetSlice(), TridModel::GetSortKey(), Msg::kError, MSG, TridSketchListItr::Next(), and SliceColor().

00226 {
00227   // Go through all models. Modify their sketches to match the current
00228   // transparency and color maps.
00229 
00230   fColorHistogram->Reset();
00231   fTransHistogram->Reset();
00232 
00233   int nsketches =0;
00234 
00235   TridSketchListItr itr = fGLFrame->GetIterator();
00236   while( TridSketch* sketch = itr.Next() ) {
00237     int sketchnum = sketch->GetId();
00238     TridModel* model = fModels.GetModelFromSketch(sketchnum);
00239 
00240     if((sketch)&&(model)) {
00241       nsketches++;
00242  
00243       Double_t trans_x = fTridControl->GetRangedModelTrans(model);
00244       Double_t color_x = fTridControl->GetRangedModelColor(model);
00245       fColorHistogram->Fill(color_x);
00246       fTransHistogram->Fill(trans_x);
00247       sketch->SetTransparency(trans_x);
00248 
00249       // set color by number:
00250       sketch->SetColor(SliceColor(model->GetSlice()));
00251 
00252      // If picked, shine as white.
00253      if(fTridControl->IsPicked(model))
00254        sketch->SetColor(1,1,1);
00255      
00256      // Ditto selected.
00257      if(fTridControl->IsSelected(model))
00258        sketch->SetColor(1,1,1);
00259          
00260 
00261     } else {
00262       if(!(sketch->IsScenery())) {
00263         MSG("TriD",Msg::kError) << "Cannot find sketch or model "
00264                                 << " ModelAdd:"     << model 
00265                                 << " Model ID:"     << ((model) ? (model->GetId()) : 0)
00266                                 << " ModelKey:"     << ((model) ? (model->GetSortKey()) : 0)
00267                                 << " SketchNumber:" << sketchnum
00268                                 << " SketchAddr: " << sketch << endl;
00269         //if(model) model->Print();
00270       }
00271     }
00272   }
00273 }

TVector3 TridPageSlice::SliceColor ( int  c  )  [private]

Definition at line 74 of file TridPageSlice.cxx.

References TridPage::GetColor().

Referenced by CreateSketches(), and ModifySketches().

00075 {
00076   // what color should slice c of n be?
00077   float f = (c%5)/4.;
00078   return GetColor(f);
00079 }


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1