--- eventviewer/flight/src/FEVpamevcontrol.cpp 2007/11/08 11:05:35 1.5 +++ eventviewer/flight/src/FEVpamevcontrol.cpp 2012/04/13 08:07:31 1.13 @@ -104,7 +104,7 @@ cvar = &var; thefigure = &figure; // - cframe1 = new TGCompositeFrame(this, 280, 40, kVerticalFrame); + cframe1 = new TGCompositeFrame(this, 280, 60, kVerticalFrame); TGCompositeFrame *cframe2 = new TGCompositeFrame(this, 280, 60, kVerticalFrame); TGCompositeFrame *cframe3 = new TGCompositeFrame(this, 280, 60, kVerticalFrame); TGCompositeFrame *cframe4 = new TGCompositeFrame(this, 280, 60, kVerticalFrame); @@ -115,18 +115,18 @@ TGGroupFrame *jumpf = new TGGroupFrame(cframe3, "Jump to"); TGGroupFrame *savef = new TGGroupFrame(cframe4, "Save figure as"); // - TGHorizontalFrame *htexts = new TGHorizontalFrame(savef,400,800); - TGHorizontalFrame *htextsl = new TGHorizontalFrame(cframe4,400,800); - TGHorizontalFrame *htext = new TGHorizontalFrame(inputf,400,800); - TGHorizontalFrame *htext2 = new TGHorizontalFrame(inputf,400,800); - TGHorizontalFrame *htext3 = new TGHorizontalFrame(jumpf,400,800); - TGHorizontalFrame *htext4 = new TGHorizontalFrame(jumpf,400,80); - TGHorizontalFrame *hframe = new TGHorizontalFrame(this,400,800); + TGHorizontalFrame *htexts = new TGHorizontalFrame(savef,300,800); + TGHorizontalFrame *htextsl = new TGHorizontalFrame(cframe4,300,800); + TGHorizontalFrame *htext = new TGHorizontalFrame(inputf,300,800); + TGHorizontalFrame *htext2 = new TGHorizontalFrame(inputf,300,800); + TGHorizontalFrame *htext3 = new TGHorizontalFrame(jumpf,300,800); + TGHorizontalFrame *htext4 = new TGHorizontalFrame(jumpf,300,80); + TGHorizontalFrame *hframe = new TGHorizontalFrame(this,300,800); for (Int_t fr=0; fr<12; fr++) hframedec[fr] = new TGHorizontalFrame(gf, 7, 7); - TGHorizontalFrame *hframe3 = new TGHorizontalFrame(gf2, 280, 40); + TGHorizontalFrame *hframe3 = new TGHorizontalFrame(gf2, 280, 60); TGHorizontalFrame *hframe4 = new TGHorizontalFrame(gf2,280,10); - TGVerticalFrame *hframe5 = new TGVerticalFrame(hframe4, 280, 40); - TGHorizontalFrame *hfrprog = new TGHorizontalFrame(this,400,800); + TGVerticalFrame *hframe5 = new TGVerticalFrame(hframe4, 280, 60); + TGHorizontalFrame *hfrprog = new TGHorizontalFrame(this,300,800); // TGTextEntry *fText = new TGTextEntry(htext, new TGTextBuffer(20),-1); fText->SetText(cvar->thefilename.Data()); @@ -288,16 +288,23 @@ fchkinfo = new TGCheckButton(hframe3, "Infos"); fchkinfo->Connect("Clicked()","PAMevcontrol",this,"chkinfo()"); if ( cvar->INFOS ) fchkinfo->SetState(kButtonDown); - hframe3->AddFrame(fchkinfo, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,0,5,5,5)); + hframe3->AddFrame(fchkinfo, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,0,1,5,5)); // fchknames = new TGCheckButton(hframe3, "Names"); fchknames->Connect("Clicked()","PAMevcontrol",this,"chknames()"); if ( cvar->VINFOS ) fchknames->SetState(kButtonDown); - hframe3->AddFrame(fchknames, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,5,5,5,5)); + hframe3->AddFrame(fchknames, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,0,1,5,5)); + fchkpalette = new TGCheckButton(hframe3, "Palette"); fchkpalette->Connect("Clicked()","PAMevcontrol",this,"chkpalette()"); if ( cvar->PALETTE) fchkpalette->SetState(kButtonDown); - hframe3->AddFrame(fchkpalette, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,10,5,5,5)); + hframe3->AddFrame(fchkpalette, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,0,2,5,5)); + + fchktrigger = new TGCheckButton(hframe3, "Trigger"); + fchktrigger->Connect("Clicked()","PAMevcontrol",this,"chktrigger()"); + if ( cvar->PATTRIG) fchktrigger->SetState(kButtonDown); + hframe3->AddFrame(fchktrigger, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsCenterY|kLHintsExpandX,1,2,5,5)); + gf2->AddFrame(hframe3, new TGLayoutHints(kLHintsExpandX)); // TGVButtonGroup *group = new TGVButtonGroup(hframe4); @@ -441,26 +448,131 @@ // } +void PAMevcontrol::Refresh(){ + // bah + return; + this->Clear(); + MapSubwindows(); + // Initialize the layout algorithm + Resize(GetDefaultSize()); + // Map main frame + MapWindow(); +} + void PAMevcontrol::DIALOG(Int_t ty, TString warn){ // - // ty = 0 -> INFO, ty = 1 -> WARNING, ty = 3 -> ERROR + // ty = 0 -> INFO, ty = 1 -> WARNING, ty = 2 -> ERROR // Int_t retval; TString title; EMsgBoxIcon mb_icon = kMBIconStop; - if ( ty == 0 ){ + if ( ty == 2 || ty == 3 ){ + if ( ty == 2 ){ + title="ERROR!!"; + mb_icon = kMBIconStop; + new TGMsgBox(gClient->GetRoot(), this, title.Data(), warn.Data(), mb_icon, kMBOk, &retval); + } else { + title="HELP"; + mb_icon = kMBIconQuestion; + new TGMsgBox(gClient->GetRoot(), this, title.Data(), warn.Data(), mb_icon, kMBOk, &retval); + }; + } else { + if ( ty == 0 ){ title="INFO"; mb_icon = kMBIconAsterisk; - }; - if ( ty == 1 ){ + }; + if ( ty == 1 ){ title="WARNING!"; mb_icon = kMBIconExclamation; + }; + if ( ty == 4 ){ + title="DATA"; + mb_icon = kMBIconExclamation; + }; + const TGPicture *icon_pic; + switch (mb_icon) { + case kMBIconStop: + icon_pic = gClient->GetPicture("mb_stop_s.xpm"); + if (!icon_pic) Error("TGMsgBox", "mb_stop_s.xpm not found"); + break; + + case kMBIconQuestion: + icon_pic = gClient->GetPicture("mb_question_s.xpm"); + if (!icon_pic) Error("TGMsgBox", "mb_question_s.xpm not found"); + break; + + case kMBIconExclamation: + icon_pic = gClient->GetPicture("mb_exclamation_s.xpm"); + if (!icon_pic) Error("TGMsgBox", "mb_exclamation_s.xpm not found"); + break; + + case kMBIconAsterisk: + icon_pic = gClient->GetPicture("mb_asterisk_s.xpm"); + if (!icon_pic) Error("TGMsgBox", "mb_asterisk_s.xpm not found"); + break; + + default: + icon_pic = 0; + break; + } + // + if ( ty == 4 ){// non funziona il recupero dei puntatori a questi oggetti come e` possibile? + // gObjectTable->Print(); + TGLabel *la=dynamic_cast(gDirectory->FindObject("la")); + TGHorizontalFrame *fLabelFrame=dynamic_cast(gDirectory->FindObject("fLabelFrame")); + TGTransientFrame *compofra=dynamic_cast(gDirectory->FindObject("compofra")); + if ( la ) la->Delete(); + if ( fLabelFrame ) fLabelFrame->Delete(); + if ( compofra ){ + compofra->DestroyWindow(); + compofra->Delete(); + }; + }; + TGTransientFrame *compofra = new TGTransientFrame(gClient->GetRoot(), 0, 200, 80, kHorizontalFrame); + TGHorizontalFrame *fIconFrame = NULL; + TGIcon *fIcon = NULL; + if ( ty != 4 ){ + compofra->DontCallClose(); + fIconFrame = new TGHorizontalFrame(compofra, 98, 78); + fIcon = new TGIcon(fIconFrame, icon_pic, icon_pic->GetWidth(), icon_pic->GetHeight()); + fIconFrame->AddFrame(fIcon, new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 1, 1, 1, 1)); + compofra->AddFrame(fIconFrame, new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 1, 1, 1, 1)); + }; + // + TGHorizontalFrame *fLabelFrame = new TGHorizontalFrame(compofra, 98, 78); + TGLabel *la=new TGLabel(fLabelFrame,warn.Data()); + la->SetTextJustify(kLHintsCenterX); + fLabelFrame->AddFrame(la, new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 1, 1, 1, 1)); + compofra->AddFrame(fLabelFrame, new TGLayoutHints(kLHintsCenterX|kLHintsCenterY, 1, 1, 1, 1)); + // + compofra->SetWindowName(title.Data()); + compofra->MapSubwindows(); + if ( ty != 4 ){ + compofra->Resize(compofra->GetDefaultWidth(),80); + } else { + compofra->Resize(compofra->GetDefaultSize()); + }; + compofra->CenterOnParent(); + compofra->MapWindow(); + // + if ( ty != 4 ){ + Int_t kkk = 0; + while ( kkk < 200 ){ + gSystem->ProcessEvents(); + gSystem->Sleep(10); + kkk++; + }; + }; + if ( compofra && ty != 4 ){ + la->Delete(); + fLabelFrame->Delete(); + if ( fIcon ) fIcon->Delete(); + if ( fIconFrame ) fIconFrame->Delete(); + compofra->DestroyWindow(); + compofra->Delete(); + }; }; - if ( ty == 2 ){ - title="ERROR!!"; - mb_icon = kMBIconStop; - }; - new TGMsgBox(gClient->GetRoot(), this, title.Data(), warn.Data(), mb_icon, kMBOk, &retval); + // } void PAMevcontrol::refreshdec(Int_t n){ @@ -569,6 +681,7 @@ TGTextEntry *entry = (TGTextEntry*)gTQSender; TString text = entry->GetText(); cvar->thefilename=text.Data(); + cvar->i = 0; cvar->nevents = 0; cvar->firstevno = 0; cvar->lastevno = 0; @@ -601,11 +714,18 @@ cout<<"PSW "<IsConnected() ){ // - // Starting from level2 + // Retrieve the file // if ( clev->file == 2 ){ + // + // Starting from level2 + // GL_ROOT glroot = GL_ROOT(); if( !glroot.Query_GL_ROOT(cvar->idroot,dbc) ){ // @@ -624,24 +744,89 @@ cvar->thefilter=""; cvar->selex = true; }; - cvar->i = -(cvar->EVF + cvar->i -1); + cvar->i = cvar->EVF + cvar->i ; //cvar->refresh = true; // cvar->file = 0; // - } else { + } else { stringstream warning; warning.str(""); warning << " Problems getting Level0 file "; DIALOG(2,warning.str().c_str()); }; - } else { + } else { // // starting from L0 // - stringstream warning; - warning.str(""); - warning << " Not yet implemented "; - DIALOG(2,warning.str().c_str()); + stringstream query; + query.str(""); + query << " SELECT ID FROM GL_ROOT WHERE NAME='"<< gSystem->BaseName(cvar->thefilename.Data()) <<"' order by INSERT_TIME desc limit 1;"; + // printf(" query is %s \n",query.str().c_str()); + pResult = dbc->Query(query.str().c_str()); + Row = pResult->Next(); + UInt_t idrl0 = 0; + if ( Row ){ + idrl0 = (UInt_t)atoll(Row->GetField(0)); + }; + // + query.str(""); + query << " SELECT ID,ID_ROOT_L2,EV_FROM FROM GL_RUN WHERE EV_FROM<="<i<<" AND EV_TO>="<< cvar->i<<" AND ID_ROOT_L0="<< idrl0 <<";"; + // printf(" query is %s \n",query.str().c_str()); + pResult = dbc->Query(query.str().c_str()); + Row = pResult->Next(); + UInt_t idrl2 = 0; + UInt_t idrlun = 0; + UInt_t evfrom = 0; + if ( Row ){ + idrlun = (UInt_t)atoll(Row->GetField(0)); + idrl2 = (UInt_t)atoll(Row->GetField(1)); + evfrom = (UInt_t)atoll(Row->GetField(2)); + }; + // + query.str(""); + query << " SELECT ID,NEVENTS FROM GL_RUN WHERE ID_ROOT_L2="<< idrl2 <<" order by RUNHEADER_TIME asc;"; + // printf(" query is %s \n",query.str().c_str()); + pResult = dbc->Query(query.str().c_str()); + Row = pResult->Next(); + UInt_t coren = 0; + while ( Row ){ + if ( (UInt_t)atoll(Row->GetField(0)) == idrlun ) break; + coren += (UInt_t)atoll(Row->GetField(1)); + Row = pResult->Next(); + }; + coren += cvar->i - evfrom; + // + GL_ROOT glroot = GL_ROOT(); + if( !glroot.Query_GL_ROOT(idrl2,dbc) ){ + // + cvar->i = coren; + // + cvar->thefilename= glroot.PATH + glroot.NAME; + cvar->nevents = 0; + cvar->firstevno = 0; + cvar->lastevno = 0; + if ( cvar->fl0 ) { + cvar->fl0 = false; + ffl0->SetState(kButtonUp); + }; + cvar->restart = true; + cvar->waitforever = false; + // + if ( cvar->thefilter != "" ){ + cvar->thefilter=""; + cvar->selex = true; + }; + // + } else { + stringstream warning; + warning.str(""); + warning << " Problems getting Level2 file "; + DIALOG(2,warning.str().c_str()); + }; + // stringstream warning; + // warning.str(""); + // warning << " Not yet implemented "; + // DIALOG(2,warning.str().c_str()); }; // } else { @@ -687,7 +872,9 @@ void PAMevcontrol::RefreshButtons() { if ( cvar->jumprog ){ jbwc1->SetState(kButtonDown); + jbwc0->SetState(kButtonUp); } else { + jbwc1->SetState(kButtonUp); jbwc0->SetState(kButtonDown); }; if ( cvar->fl0 ){ @@ -698,9 +885,12 @@ // if ( cvar->tracknds4) ftrks4->SetState(kButtonDown); if ( cvar->bw ){ bwc1->SetState(kButtonDown); + bwc0->SetState(kButtonUp); } else { bwc0->SetState(kButtonDown); + bwc1->SetState(kButtonUp); }; + if ( cvar->PATTRIG) fchktrigger->SetState(kButtonDown); else fchktrigger->SetState(kButtonUp); if ( cvar->PALETTE) fchkpalette->SetState(kButtonDown); else fchkpalette->SetState(kButtonUp); if ( cvar->VINFOS ) fchknames->SetState(kButtonDown); else fchknames->SetState(kButtonUp); if ( cvar->INFOS ) fchkinfo->SetState(kButtonDown); else fchkinfo->SetState(kButtonUp); @@ -1153,6 +1343,16 @@ cvar->goon = true; } +void PAMevcontrol::chktrigger() { + if ( cvar->PATTRIG ) { + cvar->PATTRIG = 0; + } else { + cvar->PATTRIG = 1; + }; + cvar->i--; + cvar->goon = true; +} + void PAMevcontrol::next() { SetSearching(); if ( cvar->i == cvar->nevents-1 ) {