Commit 1af4b51c authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Update new arrow style to prepare source treatment

parent c6bad647
#include "CXArrow.h"
#include "TLatex.h"
#include "TBox.h"
#include "TH1.h"
#include "TVirtualPad.h"
#include "CXFit.h"
CXArrow::CXArrow(CXFit *fit, Double_t E,Double_t y1 ,Double_t y2,Float_t arrowsize,Option_t *option) : TArrow(E, y1, E, y2, arrowsize, option)
......@@ -45,4 +51,62 @@ Int_t CXArrow::Compare(const TObject *obj) const
else return 0;
}
void CXArrow::SetText(TH1 *hist, TString text, TString tooltip)
{
Int_t XMinbin = hist->GetXaxis()->GetFirst();
Int_t XMaxbin = hist->GetXaxis()->GetLast();
Int_t XMin = hist->GetBinLowEdge(XMinbin);
Int_t XMax = hist->GetBinLowEdge(XMaxbin);
if(fBox) delete fBox;
fBox = new CXArrowBox(this);
fBox->SetX1(fX1-(XMax-XMin)/300.);
fBox->SetX2(fX1+(XMax-XMin)/300.);
fBox->SetY1(fY1);
fBox->SetY2(fY2);
fBox->SetFillStyle(0);
fBox->SetFillColor(0);
fBox->SetLineWidth(0);
fBox->SetLineColor(0);
fBox->SetLineStyle(3);
if(fLatex) delete fLatex;
fLatex = new TLatex(fX1,fY2,text);
fLatex->SetTextAngle(90);
fLatex->SetTextFont(132);
fLatex->SetTextSize(fTextSize);
fLatex->SetTextColor(hist->GetLineColor());
fLatex->SetBit(TObject::kCannotPick);
fLatex->Draw();
fBox->SetToolTipText(tooltip.Data(),500);
fBox->Draw();
Float_t MaxGlob = hist->GetMaximum();
Float_t Y = fLatex->GetY()-(gPad->AbsPixeltoY(fLatex->GetBBox().fY+fLatex->GetBBox().fWidth)-gPad->AbsPixeltoY(fLatex->GetBBox().fY));
if(gPad->GetUymax()< Y)
hist->GetYaxis()->SetRangeUser(gPad->GetUymin(),Y+MaxGlob/50.);
}
void CXArrow::ClearPad(TVirtualPad *pad)
{
if(pad==nullptr) pad = gPad;
pad->GetListOfPrimitives()->Remove(fLatex);
pad->GetListOfPrimitives()->Remove(fBox);
pad->GetListOfPrimitives()->Remove(this);
pad->Modified();
pad->Update();
}
void CXArrow::Paint(Option_t *option)
{
TArrow::Paint(option);
}
ClassImp(CXArrow);
......@@ -2,8 +2,15 @@
#define CXArrow_H
#include "TArrow.h"
#include "TBox.h"
class CXFit;
class TLatex;
class TBox;
class TH1;
class TVirtualPad;
class CXArrowBox;
class CXArrow : public TArrow
{
......@@ -13,6 +20,11 @@ private:
TList *fList = nullptr;
CXFit *fFit = nullptr;
TLatex *fLatex = nullptr;
CXArrowBox *fBox = nullptr;
Float_t fTextSize = 0.03;
public:
CXArrow(CXFit *fit, Double_t E,Double_t y1 ,Double_t y2,Float_t arrowsize=0.05,Option_t *option=">");
......@@ -29,6 +41,12 @@ public:
void RemoveArrow(); // *MENU*
void RemoveFit(); // *MENU*
void SetText(TH1 *hist, TString text, TString tooltip);
void ClearPad(TVirtualPad *pad = nullptr);
virtual void Paint(Option_t *option = "");
//! Sort
virtual Bool_t IsSortable() const {return kTRUE;}
virtual Int_t Compare(const TObject *obj) const;
......@@ -36,4 +54,18 @@ public:
ClassDef(CXArrow,0);
};
class CXArrowBox : public TBox
{
private:
CXArrow *fArrow = nullptr;
public:
CXArrowBox(CXArrow *arrow) : TBox() {fArrow = arrow;}
~CXArrowBox(){;}
void Clean(){if(fArrow) {fArrow->ClearPad(); delete fArrow; fArrow = nullptr;}}
ClassDef(CXArrowBox,0);
};
#endif
......@@ -196,8 +196,6 @@ CXHist1DPlayer::CXHist1DPlayer(const TGCompositeFrame *MotherFrame, UInt_t w, UI
HandleMyButton();
fListOfPSObjects = new TList;
fListOfFitObjects = new TList;
fListOfFitObjects->SetOwner();
}
......@@ -220,11 +218,12 @@ void CXHist1DPlayer::PeakSearchClear()
return;
}
while(fListOfPSObjects->GetEntries()) {
TObject *o = fListOfPSObjects->First();
pad->GetListOfPrimitives()->Remove(o);
fListOfPSObjects->Remove(o);
delete o;
for(int i=0 ; i<pad->GetListOfPrimitives()->GetEntries() ; i++) {
TObject *o = pad->GetListOfPrimitives()->At(i);
if(o->InheritsFrom(CXArrow::Class())) {
((CXArrow*)o)->ClearPad();
i--;
}
}
fMainWindow->RefreshPads();
......@@ -232,7 +231,7 @@ void CXHist1DPlayer::PeakSearchClear()
void CXHist1DPlayer::PeakSearch()
{
PeakSearchClear();
// PeakSearchClear();
gPad = fMainWindow->GetSelectedPad();
......@@ -253,6 +252,17 @@ void CXHist1DPlayer::PeakSearch()
Float_t Value = tspec->GetPositionY()[i];
Float_t MaxGlob = fCurrentHist->GetMaximum();
bool found = false;
for(int i=0 ; i<gPad->GetListOfPrimitives()->GetEntries() ; i++) {
TObject *o = gPad->GetListOfPrimitives()->At(i);
if(o->InheritsFrom(CXArrow::Class())) {
CXArrow *arr = ((CXArrow*)o);
if(TMath::Abs(arr->GetEnergy()-Energy)<0.1) found = true;
}
}
if(found) continue;
CXArrow *GammaArrow = new CXArrow(nullptr, Energy,(Value + MaxGlob/100.) ,(Value +MaxGlob/15.),0.01,"<|");
GammaArrow->SetAngle(40);
......@@ -260,28 +270,9 @@ void CXHist1DPlayer::PeakSearch()
GammaArrow->SetFillColor(fCurrentHist->GetLineColor());
GammaArrow->SetLineWidth(1);
GammaArrow->SetText(fCurrentHist,Form("%.2f",Energy),"tooltip");
GammaArrow->Draw();
GammaArrow->SetBit(TObject::kCannotPick);
TLatex *text = new TLatex(Energy, (Value +MaxGlob/15.)+MaxGlob/100.,Form("%.2f",Energy));
text->SetTextAngle(90);
text->SetTextColor(fCurrentHist->GetLineColor());
text->SetTextSize(0.02);
if(fMainWindow->GetCanvas()->GetNPads()>1)
text->SetTextSize(0.04);
text->SetTextFont(132);
text->Draw();
text->SetBit(TObject::kCannotPick);
Float_t Y = text->GetY()-(gPad->AbsPixeltoY(text->GetBBox().fY+text->GetBBox().fWidth)-gPad->AbsPixeltoY(text->GetBBox().fY));
if(gPad->GetUymax()< Y)
fCurrentHist->GetYaxis()->SetRangeUser(gPad->GetUymin(),Y+MaxGlob/50.);
fListOfPSObjects->Add(GammaArrow);
fListOfPSObjects->Add(text);
}
fMainWindow->RefreshPads();
......
......@@ -44,7 +44,6 @@ private:
TGNumberEntry *fSigmaSPEntry = nullptr;
TGNumberEntry *fThresholdSPEntry = nullptr;
TList *fListOfPSObjects = nullptr;
TList *fListOfFitObjects = nullptr;
vector<Float_t> fEnergies;
......
......@@ -62,6 +62,15 @@ CXLevelSchemePlayer::CXLevelSchemePlayer(const char* name, const char *title) :
if(gNDManager == nullptr)
gNDManager = new CXNDManager;
fListOfArrows = new TList;
fListOfArrows->SetOwner();
fListOfLatex = new TList;
fListOfLatex->SetOwner();
fListOfBoxes = new TList;
fListOfBoxes->SetOwner();
}
CXLevelSchemePlayer::~CXLevelSchemePlayer()
......@@ -95,21 +104,33 @@ void CXLevelSchemePlayer::DrawArrows(TString ListOfNuclei,TH1 *h)
fGuiLSPlayer->GetSpins(fMinSpin,fMaxSpin);
fGuiLSPlayer->GetLifeTime(fMinLifeTime,fMaxLifeTime);
if(fListOfArrows != nullptr)
delete fListOfArrows;
if(fListOfLatex != nullptr)
delete fListOfLatex;
if(fListOfBoxes != nullptr)
delete fListOfBoxes;
for(int i=0 ; i<fListOfArrows->GetEntries() ; i++) {
if(gPad->GetListOfPrimitives()->FindObject(fListOfArrows->At(i))) {
gPad->GetListOfPrimitives()->Remove(fListOfArrows->At(i));
fListOfArrows->RemoveAt(i);
gPad->GetListOfPrimitives()->Remove(fListOfLatex->At(i));
fListOfLatex->RemoveAt(i);
gPad->GetListOfPrimitives()->Remove(fListOfBoxes->At(i));
fListOfBoxes->RemoveAt(i);
i--;
}
}
fListOfArrows = new TList;
fListOfArrows->SetOwner();
// if(fListOfArrows != nullptr)
// delete fListOfArrows;
// if(fListOfLatex != nullptr)
// delete fListOfLatex;
// if(fListOfBoxes != nullptr)
// delete fListOfBoxes;
fListOfLatex = new TList;
fListOfLatex->SetOwner();
// fListOfArrows = new TList;
// fListOfArrows->SetOwner();
fListOfBoxes = new TList;
fListOfBoxes->SetOwner();
// fListOfLatex = new TList;
// fListOfLatex->SetOwner();
// fListOfBoxes = new TList;
// fListOfBoxes->SetOwner();
fCurrentHist = h;
......
......@@ -34,6 +34,7 @@
#include "CXSavedList.h"
#include "CXRadCubeTH1Proj.h"
#include "CXTH1Proj.h"
#include "CXArrow.h"
using namespace std;
......@@ -74,57 +75,72 @@ void CXMainWindow::Init()
fMenuView = new TGPopupMenu(gClient->GetRoot());
fMenuView->Connect("Activated(Int_t)", "CXMainWindow", this, "HandleMenu(Int_t)");
fMenuView->AddEntry("Browse Files", M_FileListUtility);
fMenuView->CheckEntry(M_FileListUtility);
fMenuView->AddEntry("Browse Files", M_FileListUtility,0,gClient->GetPicture("ed_open.png"));
// fMenuView->CheckEntry(M_FileListUtility);
IsFileListUtilityEnabled = true;
fMenuView->AddEntry("Hist1D Player", M_Hist1DPlayer);
fMenuView->CheckEntry(M_Hist1DPlayer);
IsHist1DPlayerEnabled= true;
fMenuView->AddEntry("Saved list", M_SavedList,0,gClient->GetPicture("bld_listbox.xpm"));
// fMenuView->CheckEntry(M_SavedList);
IsSavedListEnabled = true;
fMenuView->AddEntry("Hist2D Player", M_Hist2DPlayer);
fMenuView->CheckEntry(M_Hist2DPlayer);
IsHist2DPlayerEnabled= true;
fMenuView->AddSeparator();
fMenuView->AddEntry("Rad2D Player", M_Rad2DPlayer);
fMenuView->CheckEntry(M_Rad2DPlayer);
IsRad2DPlayerEnabled= true;
fMenuView->AddEntry("Show editor", M_Editor,0,gClient->GetPicture("bld_edit.png"));
// fMenuView->CheckEntry(M_Editor);
IsEditorEnabled = true;
fMenuView->AddEntry("RadCube Player", M_RadCubePlayer);
fMenuView->CheckEntry(M_RadCubePlayer);
IsRadCubePlayerEnabled= true;
//---------------- Menu Tools --------------------
fMenuTools = new TGPopupMenu(gClient->GetRoot());
fMenuTools->AddLabel("1D Tools...",gClient->GetPicture("h1_t.xpm"));
fMenuTools->AddSeparator();
fMenuView->AddEntry("LS Player", M_LSPlayerUtility);
fMenuView->CheckEntry(M_LSPlayerUtility);
fMenuTools->AddEntry("LS Player", M_LSPlayerUtility,0,gClient->GetPicture("levelscheme_t.png"));
// fMenuTools->CheckEntry(M_LSPlayerUtility);
IsLSPlayerToolEnabled = true;
fMenuView->AddEntry("background utility", M_BkdUtility);
fMenuView->CheckEntry(M_BkdUtility);
fMenuTools->AddEntry("Hist1D Player", M_Hist1DPlayer,0,gClient->GetPicture("FitTool.xpm"));
// fMenuTools->CheckEntry(M_Hist1DPlayer);
IsHist1DPlayerEnabled= true;
fMenuTools->AddEntry("background utility", M_BkdUtility,0,gClient->GetPicture("h1_t.xpm"));
// fMenuTools->CheckEntry(M_BkdUtility);
IsBkdUtilityEnabled = true;
fMenuView->AddEntry("Saved list", M_SavedList);
fMenuView->CheckEntry(M_SavedList);
IsSavedListEnabled = true;
fMenuTools->AddSeparator();
fMenuTools->AddLabel("2D Tools...",gClient->GetPicture("h2_t.xpm"));
fMenuTools->AddSeparator();
fMenuView->AddSeparator();
fMenuTools->AddEntry("Hist2D Player", M_Hist2DPlayer,0,gClient->GetPicture("h2_t.xpm"));
// fMenuTools->CheckEntry(M_Hist2DPlayer);
IsHist2DPlayerEnabled= true;
fMenuView->AddEntry("Show editor", M_Editor);
fMenuView->CheckEntry(M_Editor);
IsEditorEnabled = true;
fMenuTools->AddEntry("Rad2D Player", M_Rad2DPlayer,0,gClient->GetPicture("rw3.gif"));
// fMenuTools->CheckEntry(M_Rad2DPlayer);
IsRad2DPlayerEnabled= true;
//---------------- Menu Tools --------------------
fMenuTools->AddSeparator();
fMenuTools->AddLabel("3D Tools...",gClient->GetPicture("h3_t.xpm"));
fMenuTools->AddSeparator();
fMenuTools->AddEntry("RadCube Player", M_RadCubePlayer,0,gClient->GetPicture("rw3.gif"));
// fMenuTools->CheckEntry(M_RadCubePlayer);
IsRadCubePlayerEnabled= true;
fMenuTools = new TGPopupMenu(gClient->GetRoot());
fMenuTools->AddEntry("Gamma search", M_GammaSearch);
fMenuTools->AddSeparator();
fMenuTools->AddLabel("Others...");
fMenuTools->AddSeparator();
fMenuTools->AddEntry("Gamma search", M_GammaSearch,0,gClient->GetPicture("ed_find.png"));
fMenuTools->Connect("Activated(Int_t)", "CXMainWindow", this, "HandleMenu(Int_t)");
//---------------- Menu Options --------------------
fMenuOptions = new TGPopupMenu(gClient->GetRoot());
fMenuOptions->AddEntry("Show Stats", M_ShowStats);
fMenuOptions->AddEntry("Show Title", M_ShowTitle);
fMenuOptions->AddEntry("Show Stats", M_ShowStats,0,gClient->GetPicture("stats.png"));
fMenuOptions->AddEntry("Show Title", M_ShowTitle,0,gClient->GetPicture("eve_text.gif"));
gStyle->SetOptTitle(0);
gStyle->SetOptStat(0);
......@@ -338,13 +354,11 @@ void CXMainWindow::HandleMovement(Int_t EventType, Int_t EventX, Int_t EventY, T
/// Recuperation de la derniere position de la souris
if(EventType == kMouseMotion)
{
if(EventType == kMouseMotion) {
fCanvas->AbsPixeltoXY(EventX,EventY,fLastXPosition,fLastYPosition);
}
if(EventType == kKeyPress)
{
if(EventType == kKeyPress) {
if((EKeySym)EventY==kKey_f && !fCTRL) {
if(IsHist1DPlayerEnabled==false)
ToggleTab(IsHist1DPlayerEnabled,M_Hist1DPlayer,fHist1DPlayerTab,fHist1DPlayer->GetName());
......@@ -373,6 +387,9 @@ void CXMainWindow::HandleMovement(Int_t EventType, Int_t EventX, Int_t EventY, T
if((EKeySym)EventY==kKey_S && !fCTRL && selected && (selected->InheritsFrom("TH1") || selected->InheritsFrom("TGraph") || selected->InheritsFrom("TF1") )) {
AddToStoredSpectra(selected);
}
if((EKeySym)EventY==kKey_r && !fCTRL && selected && (selected->InheritsFrom(CXArrowBox::Class()))) {
((CXArrowBox*)selected)->Clean();
}
}
/// Don't work with the touch pad
......@@ -681,7 +698,11 @@ void CXMainWindow::ToggleTab(Bool_t &Enable, ETestCommandIdentifiers id, TGCompo
{
if(!Enable)
{
fMenuView->CheckEntry(id);
// if(fMenuView->GetEntry(id))
// fMenuView->CheckEntry(id);
// if(fMenuTools->GetEntry(id))
// fMenuTools->CheckEntry(id);
fMainTab->AddTab(name,tab);
fMainTab->SetTab(name);
......@@ -718,7 +739,11 @@ void CXMainWindow::ToggleTab(Bool_t &Enable, ETestCommandIdentifiers id, TGCompo
}
else
{
fMenuView->UnCheckEntry(id);
// if(fMenuView->GetEntry(id))
// fMenuView->UnCheckEntry(id);
// if(fMenuTools->GetEntry(id))
// fMenuTools->UnCheckEntry(id);
fMainTab->SetTab(name);
fMainTab->RemoveTab(fMainTab->GetCurrent());
}
......@@ -1261,6 +1286,10 @@ void CXMainWindow::DoDraw(TObject *obj, TString DrawOpt)
for(int i=0 ; i<canvas_in->GetListOfPrimitives()->GetEntries() ; i++){
TObject *o = canvas_in->GetListOfPrimitives()->At(i);
if(o->InheritsFrom(TPad::Class())) {
o->DrawClone();
}
if(idraw==0) {
idraw++;
if(o->InheritsFrom(TH2::Class()))
......
......@@ -135,6 +135,7 @@ protected:
Bool_t fCTRL = false;
TList *fListOfSavedGates = nullptr;
public:
CXGammaSearch *fGammaSearchWindow = nullptr;
......
......@@ -29,6 +29,7 @@
#pragma link C++ class CXRadCubeTH1Proj;
#pragma link C++ class CXSavedList;
#pragma link C++ class CXArrow;
#pragma link C++ class CXArrowBox;
#pragma link C++ class CXFit;
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment