Commit 09e3e3de authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Merge branch 'FIPPS_Spy' into 'preprod'

Add Fipps spy

See merge request !44
parents 92c24888 9baa2e00
Pipeline #38414 passed with stages
in 5 minutes and 45 seconds
#ifndef FSSetRangeUser_h
#define FSSetRangeUser_h
#include <TGFrame.h>
class FSMainWindow;
class TGNumberEntryField;
class FSSetRangeUser:public TGMainFrame
{
private:
FSMainWindow *fMain;
TGNumberEntryField *fNumberEntryMin[3],*fNumberEntryMax[3];
TGTextButton *fEnterbutton[3];
Bool_t fDoZ = false;
public:
FSSetRangeUser(const TGWindow *p, const TGWindow *m, UInt_t w, UInt_t h, Bool_t DoZ = false);
virtual ~FSSetRangeUser();
void CloseWindow();
void ApplyZoom();
void ButtonReleased();
void SetLimits(Double_t xmin,Double_t xmax,Double_t ymin,Double_t ymax,Double_t zmin,Double_t zmax);
ClassDef(FSSetRangeUser,0)// Set Peak Find Dialog
};
#endif
#include "FSShutter.h"
#include "TGLabel.h"
#include "TH1.h"
#include "TObjArray.h"
#include "FSMainWindow.h"
#include "FSGlobalCanvas.h"
FSShutter::FSShutter(const TGWindow *p, const TGWindow *m, UInt_t options) :
TGShutter(p,options)
{
fMain = const_cast<FSMainWindow *>(static_cast < FSMainWindow const * >(m));
fListOfCanvas = new TList;
fListOfCanvas->SetOwner();
fListOfShutteritem = new TList;
fListOfShutteritem->SetOwner();
TGCompositeFrame *container;
Int_t id = 1000;
fFIPPSShutteritem = new TGShutterItem(this, new TGHotString("FIPPS"), id);
fFIPPSShutteritem->ChangeSubframesBackground(FS_LightBlue);
container = (TGCompositeFrame*)fFIPPSShutteritem->GetContainer();
container->ChangeSubframesBackground(FS_Snow);
AddItem(fFIPPSShutteritem);
id = 2000;
fIFINShutteritem = new TGShutterItem(this, new TGHotString("IFIN"), id);
fIFINShutteritem->ChangeSubframesBackground(FS_LightBlue);
((TGCompositeFrame*)fIFINShutteritem->GetContainer())->ChangeSubframesBackground(FS_Snow);
AddItem(fIFINShutteritem);
id = 3000;
fTAGShutteritem = new TGShutterItem(this, new TGHotString("TAG"), id);
fTAGShutteritem->ChangeSubframesBackground(FS_LightBlue);
((TGCompositeFrame*)fTAGShutteritem->GetContainer())->ChangeSubframesBackground(FS_Snow);
AddItem(fTAGShutteritem);}
FSShutter::~FSShutter()
{
}
void FSShutter::GetType(TH1 *hist, CanvasTypes &Type, Int_t &Num)
{
if(hist==nullptr) return;
TString name = hist->GetName();
TObjArray *arr = name.Tokenize("_");
Num = ((TString)arr->Last()->GetName()).Atoi();
delete arr;
Type = CanvasTypes::kUndef;
if(name.Contains(fNames[kTAG])) Type = kTAG;
else if(name.Contains(fNames[kFIPPS_ACB])) Type = kFIPPS_ACB;
else if(name.Contains(fNames[kFIPPS_ACF])) Type = kFIPPS_ACF;
else if(name.Contains(fNames[kFIPPS_ACS])) Type = kFIPPS_ACS;
else if(name.Contains(fNames[kFIPPS])) Type = kFIPPS;
else if(name.Contains(fNames[kIFIN_AC])) Type = kIFIN_AC;
else if(name.Contains(fNames[kIFIN])) Type = kIFIN;
}
void FSShutter::SetSpectrum(TH1 *hist)
{
if(hist == nullptr) return;
Int_t DetNum;
CanvasTypes type;
GetType(hist,type,DetNum);
if(type==CanvasTypes::kUndef){
WARN_MESS<<"Unkown Type for hist: "<<hist->GetName()<<ENDL;
return;
}
FSGlobalCanvas *c = static_cast<FSGlobalCanvas*>(fListOfCanvas->FindObject(fNames[type]));
if(type == CanvasTypes::kFIPPS)
c = static_cast<FSGlobalCanvas*>(fListOfCanvas->FindObject(fNames[type]));
if(c == nullptr) c = NewGlobalCanvas(type);
if(c) c->AddSpectrum(hist);
}
FSGlobalCanvas* FSShutter::NewGlobalCanvas(CanvasTypes type)
{
FSGlobalCanvas *c = nullptr;
TGCompositeFrame *container = nullptr;
if(type==CanvasTypes::kFIPPS || type==CanvasTypes::kFIPPS_ACB || type==CanvasTypes::kFIPPS_ACF || type==CanvasTypes::kFIPPS_ACS) {
if(fListOfCanvas->FindObject(fNames[type]) == nullptr) {
container = (TGCompositeFrame*)fFIPPSShutteritem->GetContainer();
c = new FSGlobalCanvas(container,fMain,type);
fListOfCanvas->Add(c);
c->ChangeSubframesBackground(FS_LightRed);
container->AddFrame(c,new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 5, 20, 0, 0));
}
}
else if(type==CanvasTypes::kIFIN || type==CanvasTypes::kIFIN_AC) {
if(fListOfCanvas->FindObject(fNames[type]) == nullptr) {
container = (TGCompositeFrame*)fIFINShutteritem->GetContainer();
c = new FSGlobalCanvas(container,fMain,type);
fListOfCanvas->Add(c);
c->ChangeSubframesBackground(FS_LightRed);
container->AddFrame(c,new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 5, 20, 0, 0));
}
}
else if(type==CanvasTypes::kTAG) {
if(fListOfCanvas->FindObject(fNames[type]) == nullptr) {
container = (TGCompositeFrame*)fTAGShutteritem->GetContainer();
c = new FSGlobalCanvas(container,fMain,type);
fListOfCanvas->Add(c);
c->ChangeSubframesBackground(FS_LightRed);
container->AddFrame(c,new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 5, 20, 0, 0));
}
}
fMain->GetLeftTab()->MapSubwindows();
fMain->GetLeftTab()->MapWindow();
return c;
}
ClassImp(FSShutter)
#ifndef FSShutter_h
#define FSShutter_h
#include "TGShutter.h"
#include "FSGlobalCanvas.h"
class FSMainWindow;
class FSGlobalCanvas;
class TGShutterItem;
class FSShutter: public TGShutter
{
private:
FSMainWindow *fMain = nullptr;
TGShutterItem *fFIPPSShutteritem = nullptr;
TGShutterItem *fIFINShutteritem = nullptr;
TGShutterItem *fTAGShutteritem = nullptr;
TGShutter *fFIPPSShutter = nullptr;
TGShutter *fIFINShutter = nullptr;
TGShutter *fTAGShutter = nullptr;
TList *fListOfCanvas = nullptr;
TList *fListOfShutteritem=nullptr;
Int_t fDefaultShutterWidth;
public:
FSShutter(const TGWindow *p= 0, const TGWindow *m= 0, UInt_t options = kSunkenFrame);
~FSShutter();
void SetSpectrum(TH1 *hist);
void GetType(TH1 *hist, CanvasTypes &Type, Int_t &Num);
TList *GetListOfCanvases(){return fListOfCanvas;}
private:
FSGlobalCanvas *NewGlobalCanvas(CanvasTypes type);
ClassDef(FSShutter,0)
};
#endif
This diff is collapsed.
#ifndef FSTab_h
#define FSTab_h
#include "TGFrame.h"
#include "TGTab.h"
#include "TRootEmbeddedCanvas.h"
#include "TPad.h"
#include "TFile.h"
class FSMainWindow;
class TGStatusBar;
class TAxis;
class FSPad;
class myTGCompositeFrame : public TGCompositeFrame
{
private:
// class to creat TGCompositeFrame
// and memorize few associed information ( fCanvas,fNpadx,fNpady,TString fTabName;)
TRootEmbeddedCanvas *fCanvas; // first (0) canvas of tab
Int_t fNpadx; // n of pad in x of tab
Int_t fNpady; // n of pad in y of tab
TString fTabName;
public:
myTGCompositeFrame(const TGWindow* p = 0, UInt_t w = 1, UInt_t h = 1, UInt_t options = 0, Pixel_t back = GetDefaultFrameBackground()) :
TGCompositeFrame( p , w , h ,options , back ) {
fNpadx=0;
fNpady=0;
fCanvas=NULL;
fTabName="";
}
TRootEmbeddedCanvas* GetTRootEmbeddedCanvas() {
return fCanvas;
}
virtual TString GetTabName() {
return fTabName;
}
virtual void SetTabName(TString tabname) {
fTabName =tabname;
TGCompositeFrame::SetName( tabname.Data());
}
virtual Int_t GetNPadx() {
return fNpadx;
}
virtual Int_t GetNPady() {
return fNpady;
}
virtual void SetTRootEmbeddedCanvas(TRootEmbeddedCanvas* canvas) {
fCanvas=canvas;
}
virtual void SetNPadx(Int_t npadx) {
fNpadx=npadx;
}
virtual void SetNPady(Int_t npady) {
fNpady=npady;
}
virtual void SetInfo(TRootEmbeddedCanvas* canvas, TString tabname,
Int_t npadx, Int_t npady) {
if (npady<0)
SetNPady(npady);
if (npadx<0)
SetNPadx(npadx);
if (tabname)
SetTabName(tabname);
if (canvas)
SetTRootEmbeddedCanvas(canvas);
}
};
class FSTab : public TGTab
{
private:
FSMainWindow *fMain;
Bool_t fAutoMode;//if true: application add pages, else user set pages
Int_t fLastEventType;
Int_t fLastEventX;
Int_t fLastEventY;
TObject *fLastSelected = nullptr;
TAxis *fLastAxis = nullptr;
Bool_t fChangeRange = false;
Bool_t fDoY_TH2_Unzoom = false;
Float_t fScaleFact = 0.1;
Int_t fNTabsX;
Int_t fNTabsY;
Bool_t moved = false;
Double_t oldx, oldy;
Double_t xinit, yinit;
Double_t xmin, xmax, ymin, ymax;
FSPad * fCurrentPad = nullptr;
FSPad * fSelectedPad = nullptr;
Color_t fColor[72];
public:
FSTab(const TGWindow *p, TGMainFrame *f);
virtual ~FSTab();
virtual myTGCompositeFrame* AddTab(const char *text, Int_t nbPadX,
Int_t nbPadY);
Int_t GetNPads(){return fNTabsX*fNTabsY;}
virtual TRootEmbeddedCanvas* GetCurrentEmbeddedCanvas();
virtual TRootEmbeddedCanvas* GetEmbeddedCanvasAt(Int_t index);
virtual TCanvas* GetCanvasAt(Int_t index =0);
virtual TCanvas* GetCurrentCanvas();
virtual void CdFirstOrLastPad();
virtual void SetPageAction(Int_t id);
virtual void ComputePadXY(Int_t nbPads, Int_t *nbPadsX, Int_t *nbPadsY);
virtual void DivideCurrentPage(Int_t nPadX, Int_t nPadY);
virtual void MyDivide(TCanvas *canvas, Int_t nx, Int_t ny, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color = -1);
virtual void RemoveTab(Int_t tabIndex = -1);
virtual void RefreshTab();
virtual void ApplyPageLog(Bool_t logx, Bool_t logy, Bool_t logz, Bool_t on);
virtual void cd();
virtual TPad* GetSelectedPad();
virtual TPad* GetPad(Int_t notab, Int_t nopad);
virtual Int_t GetNoPad(Int_t level);
void UnZoom(Int_t axis, FSPad *pad=nullptr);
void UnZoomPage(Int_t axis);
void SetRangeUser(Int_t axis, Double_t min, Double_t max, FSPad *pad=nullptr);
void SetRangeUserPage(Int_t axis, Double_t min, Double_t max);
void HandleMovement(Int_t EventType, Int_t EventX, Int_t EventY, TObject *selected);
void ProcessedButtonEvent(Event_t *e);
void RangeChanged();
void UnZoomed();
ClassDef(FSTab,0)
};
#endif
#include "FSTimer.h"
#include "TGButton.h"
#include "TGNumberEntry.h"
#include "TGLabel.h"
#include "FSMainWindow.h"
#include "FSPad.h"
#include "FSToolBar.h"
FSTimer::FSTimer(const TGWindow *p, const TGWindow *m, UInt_t w, UInt_t h) :
TGMainFrame(p, w, h)
{
fMain = const_cast<FSMainWindow *>(static_cast < FSMainWindow const * >(m));
SetWindowName("Define Auto Refresh");
SetLayoutManager(new TGVerticalLayout(this));
TGGroupFrame *GroupFrame = new TGGroupFrame(this,"Timer");
AddFrame(GroupFrame,new TGLayoutHints(kLHintsTop | kLHintsExpandX | kLHintsExpandY,2,2,0,0));
GroupFrame->SetTextColor(FS_Red);
TGHorizontalFrame *HFrame = new TGHorizontalFrame(GroupFrame);
HFrame->AddFrame(new TGLabel(HFrame, "Use Timer : "),new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 5, 5, 0, 0));
fActiveButton = new TGCheckButton(HFrame, "", -1);
fActiveButton->Connect("Clicked()","FSTimer", this, "UpdateStatus()");
fActiveButton->SetState(kButtonUp);
HFrame->AddFrame(fActiveButton, new TGLayoutHints(kLHintsCenterY | kLHintsLeft,5,5,8,0));
HFrame->AddFrame(new TGLabel(HFrame,"Value (in sec): "),new TGLayoutHints(kLHintsCenterY | kLHintsLeft,5,5,8,0));
fTimerValueEntry = new TGNumberEntry(HFrame, 0, 8,-1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAPositive);
HFrame->AddFrame(fTimerValueEntry,new TGLayoutHints(kLHintsCenterY | kLHintsLeft| kLHintsExpandX,5,5,5,0));
fTimerValueEntry->Connect("ValueSet(Long_t)", "FSTimer", this, "UpdateStatus()");
GroupFrame->AddFrame(HFrame,new TGLayoutHints(kLHintsTop | kLHintsExpandX,2,2,2,2));
UpdateStatus();
Layout();
MapSubwindows();
MapWindow();
}
FSTimer::~FSTimer() {
Cleanup();
// all object added with AddFrame are already removed with Cleanup
if(fToolbar) fToolbar->SetTimerWindow(nullptr);
}
void FSTimer::UpdateStatus()
{
Bool_t DoRefresh = fActiveButton->GetState();
Float_t RefreshValue = fTimerValueEntry->GetNumber();
fTimerValueEntry->SetState(DoRefresh);
if(fToolbar){
fToolbar->AutoRefresh(DoRefresh,RefreshValue);
fToolbar->ToggleTimerIcon(DoRefresh);
}
}
void FSTimer::SetTimerStatus(Bool_t status, Int_t value){
fActiveButton->SetState(((EButtonState)status));
fTimerValueEntry->SetNumber(value);
UpdateStatus();
}
void FSTimer::CloseWindow()
{
UnmapWindow();
DeleteWindow();
}
ClassImp(FSTimer)
#ifndef FSTimer_h
#define FSTimer_h
#include <TGFrame.h>
class FSMainWindow;
class TGNumberEntry;
class TGCheckButton;
class FSToolBar;
class FSTimer:public TGMainFrame
{
private:
FSMainWindow *fMain;
TGNumberEntry *fTimerValueEntry;
TGCheckButton * fActiveButton;
public:
FSToolBar *fToolbar = nullptr;
public:
FSTimer(const TGWindow *p, const TGWindow *m, UInt_t w, UInt_t h);
virtual ~FSTimer();
void SetToolBar(FSToolBar *bar){fToolbar = bar;}
void CloseWindow();
void UpdateStatus();
void SetTimerStatus(Bool_t status, Int_t value);
ClassDef(FSTimer,0)// Set Peak Find Dialog
};
#endif
#include "FSToolBar.h"
#include "TGButton.h"
#include "TMap.h"
#include "KeySymbols.h"
#include "TGMsgBox.h"
#include "TFrame.h"
#include "TMath.h"
#include "FSMainWindow.h"
#include "FSPad.h"
#include "FSSetRangeUser.h"
#include "FSTimer.h"
#include "TTimer.h"
FSToolBar::FSToolBar(const TGWindow *p, UInt_t w, UInt_t h) :
TGToolBar(p,w,h)
{
fMain = const_cast<FSMainWindow *>(static_cast < FSMainWindow const * >(p));
TGPictureButton *pbut;
pbut = AddButton("../icons/switch-off-button-icon-16.png",M_SWITCH_FULL, kLHintsRight);
pbut->SetToolTipText("switch on to operate on the full page");
pbut = AddButton("../icons/refresh-icone-6554-32.png",M_REFRESH_PAD, kLHintsRight);
pbut->SetToolTipText("Refresh pad(s)");
fRefreshButton = AddButton("../icons/timer-32.png",M_TIMER, kLHintsRight);
fRefreshButton->SetToolTipText("Set timer for auto-refresh");
fTimer = new TTimer();
fTimer->Stop();
fTimer->Connect("Timeout()","FSToolBar",this,"TimeOut()");
TGMenuBar *LogBar = new TGMenuBar(this);
AddFrame(LogBar,new TGLayoutHints(kLHintsCenterY | kLHintsRight, 0, 0, 0, 0));
fLogPopup = new TGPopupMenu(gClient->GetRoot());
fLogPopup->AddEntry("",M_LOGX,0,gClient->GetPicture("../icons/LogX.xpm"));
fLogPopup->AddEntry("",M_LOGY,0,gClient->GetPicture("../icons/LogY.xpm"));
fLogPopup->AddEntry("",M_LOGZ,0,gClient->GetPicture("../icons/LogZ.xpm"));
fLogPopup->Connect("Activated(Int_t)", "FSToolBar", this, "ToggleLog(Int_t)");
LogBar->AddPopup("Log",fLogPopup,new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 0, 0, 0));
pbut = AddButton("../icons/find-search-zoom-icone-6310-32.png",M_ZOOM, kLHintsRight);
pbut->SetToolTipText("Zoom on axis");
}
void FSToolBar::ProcessedButtonEvent(Event_t *event)
{
char input[10];
UInt_t keysym;
gVirtualX->LookupString(event, input, sizeof(input), keysym);
if(event->fType == kButtonPress || event->fType == kButtonRelease)
return;
if(event->fType == kGKeyPress && keysym == kKey_Control)
fCtrl_On = true;
if((event->fType == kKeyRelease && keysym == kKey_Control) || event->fType == kLeaveNotify)
fCtrl_On = false;
}
FSToolBar::~FSToolBar()
{
}
TGPictureButton *FSToolBar::AddButton(TString PicturePath, ERootCanvasCommands command, ELayoutHints Align)
{
const TGPicture *pic = fClient->GetPicture(PicturePath);
TGLayoutHints *layout = new TGLayoutHints(kLHintsCenterY | Align, 5, 5, 2, 2);
fPictures->Add((TObject*)pic);
TGPictureButton *pbut = new TGPictureButton(this, pic, command);
fTrash->Add(pbut);
pbut->SetStyle(gClient->GetStyle());
AddFrame(pbut, layout);
pbut->AllowStayDown(kFALSE);
pbut->Associate(this);
fMapOfButtons->Add(pbut, (TObject*)((Long_t)command));
Connect(pbut, "Released()", "FSToolBar", this, "ButtonReleased()");
return pbut;
}
Bool_t FSToolBar::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
{
// Handle menu and other command generated by the user.
switch (GET_MSG(msg)) {
case kC_COMMAND:
switch (GET_SUBMSG(msg)) {
case kCM_BUTTON:
case kCM_MENU:
switch (parm1) {
case M_REFRESH_PAD:
RefreshPads();
break;
case M_TIMER:
DoRefresh();
break;
case M_SWITCH_FULL: