TridCratePage Class Reference

#include <TridCratePage.h>

Inheritance diagram for TridCratePage:

TridPage PageABC List of all members.

Public Member Functions

 TridCratePage ()
virtual ~TridCratePage ()
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 ChannelToCoords (RawChannelId chan, TVector3 &pos, double &width, double &height)

Detailed Description

Definition at line 28 of file TridCratePage.h.


Constructor & Destructor Documentation

TridCratePage::TridCratePage (  ) 

Definition at line 59 of file TridCratePage.cxx.

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

00060   :    TridPage()
00061 { 
00062   // Default view.
00063   fViewModesSupported = kView2D | kView3D;
00064   fViewMode = kView2D;
00065   fWindowName = "TridCrate";
00066   fFullPOV.Set(1.0, 0, 0, 9, 90, 0 );  
00067   fAutoPOV.Set(1.0, 0, 0, 9, 90, 0 );  
00068 }

TridCratePage::~TridCratePage (  )  [virtual]

Definition at line 70 of file TridCratePage.cxx.

00071 { 
00072 }


Member Function Documentation

void TridCratePage::ChannelToCoords ( RawChannelId  chan,
TVector3 &  pos,
double &  width,
double &  height 
) [virtual]

Definition at line 96 of file TridCratePage.cxx.

References TridPage::fContext, RawChannelId::GetCrate(), VldContext::GetDetector(), RawChannelId::GetElecType(), RawChannelId::GetGeographicAddress(), RawChannelId::GetMasterChannel(), RawChannelId::GetVaAdcSel(), RawChannelId::GetVarcId(), RawChannelId::GetVmm(), Detector::kFar, ElecType::kQIE, kSizeCrate_x, kSizeCrate_y, kSizeMaster_x, kSizeMaster_y, kSizeMinder_x, kSizeMinder_y, kSizeVarc_x, kSizeVarc_y, kSizeVfb_x, kSizeVfb_y, kSizeVmm_x, kSizeVmm_y, ElecType::kVA, and TridPage::PlaceInBox().

Referenced by CreateSketches().

00100 {
00101   // 
00102   // Finds 2d coords of a channel in my map space.
00103   //
00104   int ix, iy;
00105   double x = 0;
00106   double y = 0;
00107   if(chan.GetElecType()==ElecType::kQIE) {
00108   
00109     // QIE
00110 
00111     // Offset into pixel
00112     x = kSizeMinder_x/2;
00113     y = kSizeMinder_y/2;
00114 
00115     //Which minder in master.
00116     x += PlaceInBox(kSizeMaster_x,kSizeMinder_x);
00117     y += PlaceInBox(kSizeMaster_y,kSizeMinder_y,chan.GetMasterChannel(),8);
00118     
00119     // Which master in crate
00120     x += PlaceInBox(kSizeCrate_x,kSizeMaster_x,chan.GetGeographicAddress()-9,12); // Masters in slots 9 to 20
00121     y += PlaceInBox(kSizeCrate_y,kSizeMaster_y);
00122     
00123     width = kSizeMinder_x;
00124     height = kSizeMinder_y;
00125 
00126   }  else if(chan.GetElecType()==ElecType::kVA) {  
00127       
00128     // VA electronics
00129     
00130     // Offset into pixel
00131     x=kSizeVfb_x/2.;
00132     y=kSizeVfb_y/2.;
00133 
00134     // Which Vfb in Vmm
00135     ix = chan.GetVaAdcSel();
00136     x += PlaceInBox(kSizeVmm_x,kSizeVfb_x,ix,2);
00137     y += PlaceInBox(kSizeVmm_y,kSizeVfb_y,0,1);
00138     
00139     // Which vmm in varc.
00140     iy = chan.GetVmm();
00141     x += PlaceInBox(kSizeVarc_x,kSizeVmm_x,0,1);
00142     y += PlaceInBox(kSizeVarc_y,kSizeVmm_y,iy,6);
00143     
00144     // Which varc in crate
00145     x+= PlaceInBox(kSizeCrate_x,kSizeVarc_x,chan.GetVarcId(),4);
00146     y+= PlaceInBox(kSizeCrate_y,kSizeVarc_y,0,1);
00147 
00148     width  = kSizeVfb_x;
00149     height = kSizeVfb_y;
00150   }
00151   
00152   // Which crate.
00153   if(fContext.GetDetector()==Detector::kFar) {
00154     ix = chan.GetCrate() / 2;
00155     iy = - chan.GetCrate() % 2;
00156   } else {
00157     iy = 0;
00158     ix = chan.GetCrate();
00159   }
00160   
00161   x+= (double)ix * kSizeCrate_x;
00162   y+= (double)iy * kSizeCrate_y;
00163 
00164   // put into xz plane instead of xy plane.
00165   pos.SetXYZ(x,0,y);
00166   return;
00167 }

void TridCratePage::CreateModels (  )  [virtual]

Reimplemented from TridPage.

Definition at line 169 of file TridCratePage.cxx.

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

00170 {
00171   fModels.Clear();
00172   fTridControl->ClearPicked();
00173   fTridControl->ClearSelected();
00174 
00175   TridModelMaker maker;
00176   maker.Prepare(&(fMint->GetJobC().Mom));
00177   maker.CreateChannelModels(&(fMint->GetJobC().Mom),fModels);
00178 
00179 }

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

Reimplemented from TridPage.

Definition at line 81 of file TridCratePage.cxx.

References TridPage::fGuiBox, TridPage::fTridControl, Msg::kDebug, kSizeCrate_x, kSizeCrate_y, TridPage::kView2D, max, min, and MSG.

00082 {
00083   TridPOV min(0,             0,-kSizeCrate_y,   0, 0,-180);
00084   TridPOV max(kSizeCrate_x*8,0,+kSizeCrate_y,1000,90, 180);
00085   
00086   if(mode==kView2D) {
00087     MSG("TriD",Msg::kDebug) << "Changing to 2D" << endl;
00088     return new TridFlatGLFrame(this,*fGuiBox,fTridControl,min,max,1.5);
00089   };
00090 
00091   MSG("TriD",Msg::kDebug) << "Changing to 3D" << endl;
00092   return new TridGLFrame(this,*fGuiBox,fTridControl,min,max);
00093 }

void TridCratePage::CreateScenery (  )  [virtual]

Reimplemented from TridPage.

Definition at line 234 of file TridCratePage.cxx.

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

00235 {
00236   TridSketch::SetDefaultColor(fTridControl->GetForegroundColor());
00237   TridSketch::StartScenery();
00238 
00239     // Put a black quad behind everything so mouse movement works better.
00240   TridSketch* backplane = new TridSketchPlane
00241     ( TVector3(kSizeCrate_x* 4., -1.0, 0.0),
00242       kv_x, kSizeCrate_x * 10,
00243       kv_z, kSizeCrate_y * 4 
00244       );
00245   backplane->SetColor(fTridControl->GetBackgroundColor());
00246   //fGLFrame->AddSketch(backplane);
00247 
00248 
00249   // Create the scenery.
00250   TridSketch* l;
00251   TridSketch::SetDefaultColor(1,1,1);
00252 
00253   l = new TridSketchLine( TVector3(0,             0,0),
00254                           TVector3(8*kSizeCrate_x,0,0) );
00255   fGLFrame->AddSketch(l);
00256   
00257   l = new TridSketchLine( TVector3(0,             0,kSizeCrate_y),
00258                           TVector3(8*kSizeCrate_x,0,kSizeCrate_y) );
00259   fGLFrame->AddSketch(l);
00260 
00261   if(fContext.GetDetector()==Detector::kFar) {
00262     l = new TridSketchLine( TVector3(0,             0, -kSizeCrate_y),
00263                             TVector3(8*kSizeCrate_x,0, -kSizeCrate_y) );
00264     fGLFrame->AddSketch(l);
00265   }
00266 
00267 
00268   for(int i=0;i<9;i++) {
00269     TVector3 top(kSizeCrate_x * i, 0, kSizeCrate_y );
00270     TVector3 bottom(kSizeCrate_x * i, 0, 0 );
00271     if(fContext.GetDetector()==Detector::kFar)  bottom.SetXYZ(kSizeCrate_x * i, 0, -kSizeCrate_y );
00272     
00273     l = new TridSketchLine( bottom, top );
00274     l->SetColor(1,1,1);
00275     fGLFrame->AddSketch(l); 
00276   }
00277 
00278   for (int i =0; i<8;i++) {
00279     char buff[20];
00280     TridSketchText* txt;
00281 
00282     if(fContext.GetDetector()==Detector::kFar) 
00283       sprintf(buff,"Crate %d",i*2);
00284     else 
00285       sprintf(buff,"Crate %d",i);
00286       
00287     txt = new TridSketchText( TVector3( kSizeCrate_x * (i+0.5), 0, kSizeCrate_y *1.2 ),
00288                               -kv_z, kv_y,
00289                               buff);
00290     txt->SetScale(0.15);
00291     txt->SetThickness(0.001);
00292     fGLFrame->AddSketch(txt);
00293 
00294     if(fContext.GetDetector()==Detector::kFar) {
00295       sprintf(buff,"Crate %d",i*2 + 1);
00296       txt = new TridSketchText( TVector3( kSizeCrate_x * (i+0.5),  0, -kSizeCrate_y *1.2 ),
00297                                 -kv_z, kv_y,
00298                                 buff);
00299       txt->SetScale(0.15);
00300       txt->SetThickness(0.001);
00301       fGLFrame->AddSketch(txt);
00302     }
00303   }
00304 
00305   TridSketch::StopScenery();
00306 }

void TridCratePage::CreateSketches (  )  [virtual]

Reimplemented from TridPage.

Definition at line 182 of file TridCratePage.cxx.

References TridModelList::AssociateModel(), ChannelToCoords(), TridModelList::ClearAssociations(), TridPage::fAutoPOV, TridModelCrate::fChannel, TridPage::fContext, TridPage::fFullPOV, TridPage::fGLFrame, TridPage::fModels, VldContext::GetDetector(), TridModel::GetEarliestTime(), TridSketch::GetId(), TridModelList::GetIterator(), TridModel::GetOccupancy(), Detector::kCalDet, Msg::kError, Detector::kFar, kv_x(), kv_y(), kv_z(), TridPage::ModifySketches(), MSG, TridModelItr::Next(), TridPOV::Set(), and TridSketch::SetTime().

00183 {  
00184   fModels.ClearAssociations();
00185 
00186   TridModel* basemodel;
00187   TridModelItr itr = fModels.GetIterator();
00188   while( (basemodel = itr.Next()) ) {    
00189     // Make a new sketch for this model.
00190     TridModelCrate* model = dynamic_cast<TridModelCrate*>(basemodel);
00191     if(model==NULL){
00192       MSG("TriD",Msg::kError) << "CreateSketches() -> Unknown model type!" << endl;
00193       continue;
00194     }
00195 
00196     TVector3 pos;
00197     double w,h;
00198     ChannelToCoords(model->fChannel,pos,w,h);
00199     w *=0.9;
00200     h *=0.9;
00201     
00202     double depth = 0.2*model->GetOccupancy();
00203     pos.SetY(depth/2);
00204     
00205     TridSketch* sk = new TridSketchBox(pos,
00206                                        kv_x, w/2.,
00207                                        kv_z, h/2.,
00208                                        kv_y, depth/2.
00209                                        );
00210     sk->SetTime(model->GetEarliestTime());
00211     //float c = model->GetOccupancy() / 4;
00212     //sk->SetColor(GetColor(c));
00213     
00214     fGLFrame->AddSketch(sk);  
00215     fModels.AssociateModel(model,sk->GetId());    
00216   }
00217 
00218   // Add color and trans info.
00219   ModifySketches();
00220   
00221   if(fContext.GetDetector()==Detector::kCalDet) {
00222      fFullPOV.Set(1.0, 0, 0, 9, 90, 0 );  
00223      fAutoPOV.Set(1.0, 0, 0, 9, 90, 0 );  
00224   } else if(fContext.GetDetector()==Detector::kFar) {    
00225      fFullPOV.Set(8.0, 0, 0, 12, 90, 0 );
00226      fAutoPOV.Set(8.0, 0, 0, 12, 90, 0 );
00227   } else {
00228      fFullPOV.Set(4.0, 0, 0, 12, 90, 0 );
00229      fAutoPOV.Set(4.0, 0, 0, 12, 90, 0 );
00230   }
00231   
00232 }

TObject * TridCratePage::Init ( Mint mint,
PageDisplay pageDisplay,
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 74 of file TridCratePage.cxx.

References TridPage::Init(), Msg::kDebug, and MSG.

00075 {
00076   MSG("TriD",Msg::kDebug) << "TridCratePage: Init()\n";
00077   return TridPage::Init(mint, pageDisplay, box);
00078 }


The documentation for this class was generated from the following files:
Generated on Thu Jul 10 22:53:48 2014 for loon by  doxygen 1.4.7