diff --git a/src/classes/PMusrCanvas.cpp b/src/classes/PMusrCanvas.cpp index 8413042c..7d640e27 100644 --- a/src/classes/PMusrCanvas.cpp +++ b/src/classes/PMusrCanvas.cpp @@ -168,28 +168,7 @@ cout << "~PMusrCanvas() called. fMainCanvas name=" << fMainCanvas->GetName() << } //-------------------------------------------------------------------------- -// InitFourier -//-------------------------------------------------------------------------- -/** - *
Initializes the Fourier structure. - */ -void PMusrCanvas::InitFourier() -{ - fFourier.fFourierBlockPresent = false; // fourier block present - fFourier.fUnits = FOURIER_UNIT_FIELD; // fourier untis - fFourier.fFourierPower = 0; // no zero padding - fFourier.fApodization = FOURIER_APOD_NONE; // no apodization - fFourier.fPlotTag = FOURIER_PLOT_REAL_AND_IMAG; // initial plot tag, plot real and imaginary part - fFourier.fPhase = 0.0; // fourier phase 0° - for (unsigned int i=0; i<2; i++) { - fFourier.fRangeForPhaseCorrection[i] = -1.0; // frequency range for phase correction, default: {-1, -1} = NOT GIVEN - fFourier.fPlotRange[i] = -1.0; // fourier plot range, default: {-1, -1} = NOT GIVEN - } - fFourier.fPhaseIncrement = 1.0; // fourier phase increment -} - -//-------------------------------------------------------------------------- -// SetMsrHandler +// SetMsrHandler (public) //-------------------------------------------------------------------------- /** *
Keep the msr-handler object pointer and fill the Fourier structure if present. @@ -230,256 +209,7 @@ void PMusrCanvas::SetMsrHandler(PMsrHandler *msrHandler) } //-------------------------------------------------------------------------- -// CreateStyle -//-------------------------------------------------------------------------- -/** - *
Set styles for the canvas. Perhaps one could transfer them to the startup-file in the future. - */ -void PMusrCanvas::CreateStyle() -{ - fStyle = new TStyle("musrStyle", "musrStyle"); - fStyle->SetOptStat(0); // no statistics options - fStyle->SetOptTitle(0); // no title - fStyle->cd(); -} - -//-------------------------------------------------------------------------- -// InitMusrCanvas -//-------------------------------------------------------------------------- -/** - *
- * - * \param title - * \param wtopx - * \param wtopy - * \param ww - * \param wh - */ -void PMusrCanvas::InitMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh) -{ - fValid = false; - fDifferenceView = false; - fCurrentPlotView = PV_DATA; - fPlotType = -1; - - fImp = 0; - fBar = 0; - fPopupMain = 0; - fPopupSave = 0; - fPopupFourier = 0; - - fMainCanvas = 0; - fTitlePad = 0; - fDataTheoryPad = 0; - fParameterTheoryPad = 0; - fInfoPad = 0; - - // invoke canvas - TString canvasName = TString("fMainCanvas"); - canvasName += fPlotNumber; - fMainCanvas = new TCanvas(canvasName.Data(), title, wtopx, wtopy, ww, wh); - if (fMainCanvas == 0) { - cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke " << canvasName.Data(); - cout << endl; - return; - } - - // add canvas menu - fImp = (TRootCanvas*)fMainCanvas->GetCanvasImp(); - fBar = fImp->GetMenuBar(); - fPopupMain = fBar->AddPopup("&Musrfit"); - - fPopupFourier = new TGPopupMenu(); - fPopupMain->AddPopup("&Fourier", fPopupFourier); - fPopupFourier->AddEntry("Show Real", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_REAL); - fPopupFourier->AddEntry("Show Imag", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_IMAG); - fPopupFourier->AddEntry("Show Real+Imag", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_REAL_AND_IMAG); - fPopupFourier->AddEntry("Show Power", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PWR); - fPopupFourier->AddEntry("Show Phase", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE); - fPopupFourier->AddSeparator(); - fPopupFourier->AddEntry("Phase +", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS); - fPopupFourier->AddEntry("Phase -", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS); - - fPopupMain->AddEntry("&Difference", P_MENU_ID_DIFFERENCE+P_MENU_PLOT_OFFSET*fPlotNumber); - fPopupMain->AddSeparator(); - - fPopupSave = new TGPopupMenu(); - fPopupSave->AddEntry("Save ascii", P_MENU_ID_SAVE_DATA+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_SAVE_ASCII); - fPopupSave->AddEntry("Save db", P_MENU_ID_SAVE_DATA+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_SAVE_DB); - - fPopupMain->AddPopup("&Save Data", fPopupSave); - fBar->MapSubwindows(); - fBar->Layout(); - - fPopupMain->Connect("TGPopupMenu", "Activated(Int_t)", "PMusrCanvas", this, "HandleMenuPopup(Int_t)"); - - // divide the canvas into 4 pads - // title pad - fTitlePad = new TPaveText(0.0, YTITLE, 1.0, 1.0, "NDC"); - if (fTitlePad == 0) { - cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fTitlePad"; - cout << endl; - return; - } - fTitlePad->SetFillColor(TColor::GetColor(255,255,255)); - fTitlePad->SetTextAlign(12); // middle, left - fTitlePad->AddText(title); - fTitlePad->Draw(); - - // data/theory pad - fDataTheoryPad = new TPad("dataTheoryCanvas", "dataTheoryCanvas", 0.0, YINFO, XTHEO, YTITLE); - if (fDataTheoryPad == 0) { - cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fDataTheoryPad"; - cout << endl; - return; - } - fDataTheoryPad->SetFillColor(TColor::GetColor(255,255,255)); - fDataTheoryPad->Draw(); - - // parameter/theory pad - fParameterTheoryPad = new TPaveText(XTHEO, 0.1, 1.0, YTITLE, "NDC"); - if (fParameterTheoryPad == 0) { - cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fParameterTheoryPad"; - cout << endl; - return; - } - fParameterTheoryPad->SetFillColor(TColor::GetColor(255,255,255)); - fParameterTheoryPad->SetTextAlign(13); // top, left - fParameterTheoryPad->SetTextFont(102); // courier bold, scalable so that greek parameters will be plotted properly - - // info pad - fInfoPad = new TLegend(0.0, 0.0, 1.0, YINFO, "NDC"); - if (fInfoPad == 0) { - cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fInfoPad"; - cout << endl; - return; - } - fInfoPad->SetFillColor(TColor::GetColor(255,255,255)); - fInfoPad->SetTextAlign(12); // middle, left - - fValid = true; - - fMainCanvas->cd(); - fMainCanvas->Show(); - fMainCanvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "PMusrCanvas", - this, "HandleCmdKey(Int_t,Int_t,Int_t,TObject*)"); - -// cout << "this " << this << endl; -// cout << "fMainCanvas " << fMainCanvas << endl; -// cout << "fTitlePad " << fTitlePad << endl; -// cout << "fDataTheoryPad " << fDataTheoryPad << endl; -// cout << "fParameterTheoryPad " << fParameterTheoryPad << endl; -// cout << "fInfoPad " << fInfoPad << endl; -} - -//-------------------------------------------------------------------------- -// Done (SIGNAL) -//-------------------------------------------------------------------------- -/** - *
- * - */ -void PMusrCanvas::Done(Int_t status) -{ - Emit("Done(Int_t)", status); -} - -//-------------------------------------------------------------------------- -// HandleCmdKey (SLOT) -//-------------------------------------------------------------------------- -/** - *
- * - */ -void PMusrCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected) -{ - if (event != kKeyPress) - return; - -// cout << ">this " << this << endl; -// cout << ">fMainCanvas " << fMainCanvas << endl; -// cout << ">selected " << selected << endl; -// -//cout << "x : " << (char)x << endl; -//cout << "px: " << (char)fMainCanvas->GetEventX() << endl; - - if (x == 'q') { - Done(0); - } else if (x == 'd') { - HandleDifference(); - } else if (x == 'f') { - if (fPlotType != MSR_PLOT_NON_MUSR) { - HandleFourier(-1); - } - } else if (x == '+') { - IncrementFourierPhase(); - } else if (x == '-') { - DecrementFourierPhase(); - } else { - // do all the necessary stuff **TO BE DONE** - fMainCanvas->Update(); - } -} - -//-------------------------------------------------------------------------- -// HandleMenuPopup (SLOT) -//-------------------------------------------------------------------------- -/** - *
- * - */ -void PMusrCanvas::HandleMenuPopup(Int_t id) -{ - if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_REAL) { - fPopupFourier->UnCheckEntries(); - fPopupFourier->CheckEntry(id); - HandleFourier(FOURIER_PLOT_REAL); - } else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_IMAG) { - fPopupFourier->UnCheckEntries(); - fPopupFourier->CheckEntry(id); - HandleFourier(FOURIER_PLOT_IMAG); - } else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_REAL_AND_IMAG) { - fPopupFourier->UnCheckEntries(); - fPopupFourier->CheckEntry(id); - HandleFourier(FOURIER_PLOT_REAL_AND_IMAG); - } else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PWR) { - fPopupFourier->UnCheckEntries(); - fPopupFourier->CheckEntry(id); - HandleFourier(FOURIER_PLOT_POWER); - } else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE) { - fPopupFourier->UnCheckEntries(); - fPopupFourier->CheckEntry(id); - HandleFourier(FOURIER_PLOT_PHASE); - } else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS) { - IncrementFourierPhase(); - } else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS) { - DecrementFourierPhase(); - } else if (id == P_MENU_ID_DIFFERENCE+P_MENU_PLOT_OFFSET*fPlotNumber) { - HandleDifference(); - } else if (id == P_MENU_ID_SAVE_DATA+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_SAVE_ASCII) { - SaveDataAscii(); - } else if (id == P_MENU_ID_SAVE_DATA+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_SAVE_DB) { - SaveDataDb(); - } -} - -//-------------------------------------------------------------------------- -// LastCanvasClosed (SLOT) -//-------------------------------------------------------------------------- -/** - *
- * - */ -void PMusrCanvas::LastCanvasClosed() -{ -// cout << endl << ">> in last canvas closed check ..."; - if (gROOT->GetListOfCanvases()->IsEmpty()) { - Done(0); - } -} - -//-------------------------------------------------------------------------- -// UpdateParamTheoryPad +// UpdateParamTheoryPad (public) //-------------------------------------------------------------------------- /** *
@@ -585,7 +315,7 @@ void PMusrCanvas::UpdateParamTheoryPad() } //-------------------------------------------------------------------------- -// UpdateDataTheoryPad +// UpdateDataTheoryPad (public) //-------------------------------------------------------------------------- /** *
@@ -708,7 +438,7 @@ cout << endl; } //-------------------------------------------------------------------------- -// UpdateInfoPad +// UpdateInfoPad (public) //-------------------------------------------------------------------------- /** *
@@ -811,7 +541,299 @@ void PMusrCanvas::UpdateInfoPad() } //-------------------------------------------------------------------------- -// InitDataSet +// Done (SIGNAL) +//-------------------------------------------------------------------------- +/** + *
+ * + */ +void PMusrCanvas::Done(Int_t status) +{ + Emit("Done(Int_t)", status); +} + +//-------------------------------------------------------------------------- +// HandleCmdKey (SLOT) +//-------------------------------------------------------------------------- +/** + *
+ * + */ +void PMusrCanvas::HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected) +{ + if (event != kKeyPress) + return; + +// cout << ">this " << this << endl; +// cout << ">fMainCanvas " << fMainCanvas << endl; +// cout << ">selected " << selected << endl; +// +//cout << "x : " << (char)x << endl; +//cout << "px: " << (char)fMainCanvas->GetEventX() << endl; + + if (x == 'q') { + Done(0); + } else if (x == 'd') { + HandleDifference(); + } else if (x == 'f') { + if (fPlotType != MSR_PLOT_NON_MUSR) { + HandleFourier(-1); + } + } else if (x == '+') { + if (fCurrentPlotView != PV_DATA) + IncrementFourierPhase(); + } else if (x == '-') { + if (fCurrentPlotView != PV_DATA) + DecrementFourierPhase(); + } else { + fMainCanvas->Update(); + } + + // check if phase increment/decrement needs to be ghost + if (fCurrentPlotView == PV_DATA) { + fPopupFourier->DisableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS); + fPopupFourier->DisableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS); + } else { + fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS); + fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS); + } +} + +//-------------------------------------------------------------------------- +// HandleMenuPopup (SLOT) +//-------------------------------------------------------------------------- +/** + *
+ * + */ +void PMusrCanvas::HandleMenuPopup(Int_t id) +{ + if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_REAL) { + fPopupFourier->UnCheckEntries(); + fPopupFourier->CheckEntry(id); + fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS); + fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS); + HandleFourier(FOURIER_PLOT_REAL); + } else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_IMAG) { + fPopupFourier->UnCheckEntries(); + fPopupFourier->CheckEntry(id); + fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS); + fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS); + HandleFourier(FOURIER_PLOT_IMAG); + } else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_REAL_AND_IMAG) { + fPopupFourier->UnCheckEntries(); + fPopupFourier->CheckEntry(id); + fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS); + fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS); + HandleFourier(FOURIER_PLOT_REAL_AND_IMAG); + } else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PWR) { + fPopupFourier->UnCheckEntries(); + fPopupFourier->CheckEntry(id); + fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS); + fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS); + HandleFourier(FOURIER_PLOT_POWER); + } else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE) { + fPopupFourier->UnCheckEntries(); + fPopupFourier->CheckEntry(id); + fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS); + fPopupFourier->EnableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS); + HandleFourier(FOURIER_PLOT_PHASE); + } else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS) { + IncrementFourierPhase(); + } else if (id == P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS) { + DecrementFourierPhase(); + } else if (id == P_MENU_ID_DIFFERENCE+P_MENU_PLOT_OFFSET*fPlotNumber) { + HandleDifference(); + } else if (id == P_MENU_ID_SAVE_DATA+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_SAVE_ASCII) { + SaveDataAscii(); + } else if (id == P_MENU_ID_SAVE_DATA+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_SAVE_DB) { + SaveDataDb(); + } +} + +//-------------------------------------------------------------------------- +// LastCanvasClosed (SLOT) +//-------------------------------------------------------------------------- +/** + *
+ * + */ +void PMusrCanvas::LastCanvasClosed() +{ +// cout << endl << ">> in last canvas closed check ..."; + if (gROOT->GetListOfCanvases()->IsEmpty()) { + Done(0); + } +} + +//-------------------------------------------------------------------------- +// CreateStyle (private) +//-------------------------------------------------------------------------- +/** + *
Set styles for the canvas. Perhaps one could transfer them to the startup-file in the future. + */ +void PMusrCanvas::CreateStyle() +{ + fStyle = new TStyle("musrStyle", "musrStyle"); + fStyle->SetOptStat(0); // no statistics options + fStyle->SetOptTitle(0); // no title + fStyle->cd(); +} + +//-------------------------------------------------------------------------- +// InitFourier (private) +//-------------------------------------------------------------------------- +/** + *
Initializes the Fourier structure. + */ +void PMusrCanvas::InitFourier() +{ + fFourier.fFourierBlockPresent = false; // fourier block present + fFourier.fUnits = FOURIER_UNIT_FIELD; // fourier untis + fFourier.fFourierPower = 0; // no zero padding + fFourier.fApodization = FOURIER_APOD_NONE; // no apodization + fFourier.fPlotTag = FOURIER_PLOT_REAL_AND_IMAG; // initial plot tag, plot real and imaginary part + fFourier.fPhase = 0.0; // fourier phase 0° + for (unsigned int i=0; i<2; i++) { + fFourier.fRangeForPhaseCorrection[i] = -1.0; // frequency range for phase correction, default: {-1, -1} = NOT GIVEN + fFourier.fPlotRange[i] = -1.0; // fourier plot range, default: {-1, -1} = NOT GIVEN + } + fFourier.fPhaseIncrement = 1.0; // fourier phase increment +} + +//-------------------------------------------------------------------------- +// InitMusrCanvas (private) +//-------------------------------------------------------------------------- +/** + *
+ * + * \param title + * \param wtopx + * \param wtopy + * \param ww + * \param wh + */ +void PMusrCanvas::InitMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh) +{ + fValid = false; + fDifferenceView = false; + fCurrentPlotView = PV_DATA; + fPlotType = -1; + + fImp = 0; + fBar = 0; + fPopupMain = 0; + fPopupSave = 0; + fPopupFourier = 0; + + fMainCanvas = 0; + fTitlePad = 0; + fDataTheoryPad = 0; + fParameterTheoryPad = 0; + fInfoPad = 0; + + // invoke canvas + TString canvasName = TString("fMainCanvas"); + canvasName += fPlotNumber; + fMainCanvas = new TCanvas(canvasName.Data(), title, wtopx, wtopy, ww, wh); + if (fMainCanvas == 0) { + cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke " << canvasName.Data(); + cout << endl; + return; + } + + // add canvas menu + fImp = (TRootCanvas*)fMainCanvas->GetCanvasImp(); + fBar = fImp->GetMenuBar(); + fPopupMain = fBar->AddPopup("&Musrfit"); + + fPopupFourier = new TGPopupMenu(); + fPopupMain->AddPopup("&Fourier", fPopupFourier); + fPopupFourier->AddEntry("Show Real", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_REAL); + fPopupFourier->AddEntry("Show Imag", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_IMAG); + fPopupFourier->AddEntry("Show Real+Imag", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_REAL_AND_IMAG); + fPopupFourier->AddEntry("Show Power", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PWR); + fPopupFourier->AddEntry("Show Phase", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE); + fPopupFourier->AddSeparator(); + fPopupFourier->AddEntry("Phase +", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS); + fPopupFourier->AddEntry("Phase -", P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS); + fPopupFourier->DisableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_PLUS); + fPopupFourier->DisableEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE_MINUS); + + fPopupMain->AddEntry("&Difference", P_MENU_ID_DIFFERENCE+P_MENU_PLOT_OFFSET*fPlotNumber); + fPopupMain->AddSeparator(); + + fPopupSave = new TGPopupMenu(); + fPopupSave->AddEntry("Save ascii", P_MENU_ID_SAVE_DATA+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_SAVE_ASCII); + fPopupSave->AddEntry("Save db", P_MENU_ID_SAVE_DATA+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_SAVE_DB); + + fPopupMain->AddPopup("&Save Data", fPopupSave); + fBar->MapSubwindows(); + fBar->Layout(); + + fPopupMain->Connect("TGPopupMenu", "Activated(Int_t)", "PMusrCanvas", this, "HandleMenuPopup(Int_t)"); + + // divide the canvas into 4 pads + // title pad + fTitlePad = new TPaveText(0.0, YTITLE, 1.0, 1.0, "NDC"); + if (fTitlePad == 0) { + cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fTitlePad"; + cout << endl; + return; + } + fTitlePad->SetFillColor(TColor::GetColor(255,255,255)); + fTitlePad->SetTextAlign(12); // middle, left + fTitlePad->AddText(title); + fTitlePad->Draw(); + + // data/theory pad + fDataTheoryPad = new TPad("dataTheoryCanvas", "dataTheoryCanvas", 0.0, YINFO, XTHEO, YTITLE); + if (fDataTheoryPad == 0) { + cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fDataTheoryPad"; + cout << endl; + return; + } + fDataTheoryPad->SetFillColor(TColor::GetColor(255,255,255)); + fDataTheoryPad->Draw(); + + // parameter/theory pad + fParameterTheoryPad = new TPaveText(XTHEO, 0.1, 1.0, YTITLE, "NDC"); + if (fParameterTheoryPad == 0) { + cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fParameterTheoryPad"; + cout << endl; + return; + } + fParameterTheoryPad->SetFillColor(TColor::GetColor(255,255,255)); + fParameterTheoryPad->SetTextAlign(13); // top, left + fParameterTheoryPad->SetTextFont(102); // courier bold, scalable so that greek parameters will be plotted properly + + // info pad + fInfoPad = new TLegend(0.0, 0.0, 1.0, YINFO, "NDC"); + if (fInfoPad == 0) { + cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fInfoPad"; + cout << endl; + return; + } + fInfoPad->SetFillColor(TColor::GetColor(255,255,255)); + fInfoPad->SetTextAlign(12); // middle, left + + fValid = true; + + fMainCanvas->cd(); + fMainCanvas->Show(); + fMainCanvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "PMusrCanvas", + this, "HandleCmdKey(Int_t,Int_t,Int_t,TObject*)"); + +// cout << "this " << this << endl; +// cout << "fMainCanvas " << fMainCanvas << endl; +// cout << "fTitlePad " << fTitlePad << endl; +// cout << "fDataTheoryPad " << fDataTheoryPad << endl; +// cout << "fParameterTheoryPad " << fParameterTheoryPad << endl; +// cout << "fInfoPad " << fInfoPad << endl; +} + +//-------------------------------------------------------------------------- +// InitDataSet (private) //-------------------------------------------------------------------------- /** *
@@ -838,7 +860,7 @@ void PMusrCanvas::InitDataSet(PMusrCanvasDataSet &dataSet) } //-------------------------------------------------------------------------- -// InitDataSet +// InitDataSet (private) //-------------------------------------------------------------------------- /** *
@@ -865,7 +887,7 @@ void PMusrCanvas::InitDataSet(PMusrCanvasNonMusrDataSet &dataSet) } //-------------------------------------------------------------------------- -// CleanupDataSet +// CleanupDataSet (private) //-------------------------------------------------------------------------- /** *
@@ -937,7 +959,7 @@ void PMusrCanvas::CleanupDataSet(PMusrCanvasDataSet &dataSet) } //-------------------------------------------------------------------------- -// CleanupDataSet +// CleanupDataSet (private) //-------------------------------------------------------------------------- /** *
@@ -1009,7 +1031,7 @@ void PMusrCanvas::CleanupDataSet(PMusrCanvasNonMusrDataSet &dataSet) } //-------------------------------------------------------------------------- -// HandleDataSet +// HandleDataSet (private) //-------------------------------------------------------------------------- /** *
@@ -1099,7 +1121,7 @@ void PMusrCanvas::HandleDataSet(unsigned int plotNo, unsigned int runNo, PRunDat } //-------------------------------------------------------------------------- -// HandleNonMusrDataSet +// HandleNonMusrDataSet (private) //-------------------------------------------------------------------------- /** *
@@ -1174,7 +1196,7 @@ void PMusrCanvas::HandleNonMusrDataSet(unsigned int plotNo, unsigned int runNo, } //-------------------------------------------------------------------------- -// HandleDifference +// HandleDifference (private) //-------------------------------------------------------------------------- /** *
@@ -1192,109 +1214,115 @@ void PMusrCanvas::HandleDifference()
fPopupMain->UnCheckEntry(P_MENU_ID_DIFFERENCE+P_MENU_PLOT_OFFSET*fPlotNumber);
// difference plot wished hence feed difference data and plot them
- if (fDifferenceView && (fCurrentPlotView == PV_DATA)) {
- // check if it is necessary to calculate diff data
- if ((fPlotType != MSR_PLOT_NON_MUSR) && (fData[0].diff == 0)) {
- TH1F *diffHisto;
- TString name;
- // loop over all histos
- for (unsigned int i=0; i
+ *
+ * \param tag
+ */
+void PMusrCanvas::HandleFourier(int tag)
+{
+ // if fourier was invoked via the 'f' cmd key, take the default plot tag
+ if (tag == -1) { // called via cmd key 'f'
+ tag = fFourier.fPlotTag;
+ switch (tag) {
+ case FOURIER_PLOT_REAL:
+ fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_REAL);
+ break;
+ case FOURIER_PLOT_IMAG:
+ fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_IMAG);
+ break;
+ case FOURIER_PLOT_REAL_AND_IMAG:
+ fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_REAL_AND_IMAG);
+ break;
+ case FOURIER_PLOT_POWER:
+ fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PWR);
+ break;
+ case FOURIER_PLOT_PHASE:
+ fPopupFourier->CheckEntry(P_MENU_ID_FOURIER+P_MENU_PLOT_OFFSET*fPlotNumber+P_MENU_ID_FOURIER_PHASE);
+ break;
+ default:
+ break;
+ }
+ }
+
+
+ // if the current view is a data plot, fourier needs to be calculated
+ if (fCurrentPlotView == PV_DATA) {
+ if (!fDifferenceView) { // data view
+ // delete fourier components
+ for (unsigned int i=0; i
@@ -1342,7 +1669,7 @@ double PMusrCanvas::CalculateDiff(const double x, const double y, TH1F *theo)
}
//--------------------------------------------------------------------------
-// CalculateDiff
+// CalculateDiff (private)
//--------------------------------------------------------------------------
/**
*
@@ -1366,7 +1693,7 @@ double PMusrCanvas::CalculateDiff(const double x, const double y, TGraphErrors *
}
//--------------------------------------------------------------------------
-// FindBin
+// FindBin (private)
//--------------------------------------------------------------------------
/**
* Analog to FindBin for histograms (TH1F) but here for TGraphErrors.
@@ -1395,7 +1722,7 @@ Int_t PMusrCanvas::FindBin(const double x, TGraphErrors *graph)
}
//--------------------------------------------------------------------------
-// GetGlobalMaximum
+// GetGlobalMaximum (private)
//--------------------------------------------------------------------------
/**
* returns the global maximum of a histogram
@@ -1419,7 +1746,7 @@ double PMusrCanvas::GetGlobalMaximum(TH1F* histo)
}
//--------------------------------------------------------------------------
-// GetGlobalMinimum
+// GetGlobalMinimum (private)
//--------------------------------------------------------------------------
/**
* returns the global minimum of a histogram
@@ -1443,7 +1770,7 @@ double PMusrCanvas::GetGlobalMinimum(TH1F* histo)
}
//--------------------------------------------------------------------------
-// PlotData
+// PlotData (private)
//--------------------------------------------------------------------------
/**
*
@@ -1453,6 +1780,9 @@ void PMusrCanvas::PlotData()
{
fDataTheoryPad->cd();
+ // uncheck fourier menu entries
+ fPopupFourier->UnCheckEntries();
+
if (fPlotType < 0) // plot type not defined
return;
@@ -1541,7 +1871,7 @@ void PMusrCanvas::PlotData()
}
//--------------------------------------------------------------------------
-// PlotDifference
+// PlotDifference (private)
//--------------------------------------------------------------------------
/**
*
@@ -1589,7 +1919,7 @@ cout << endl << ">> going to plot diff spectra ... (" << fData[0].diff->GetNbins
}
//--------------------------------------------------------------------------
-// PlotFourier
+// PlotFourier (private)
//--------------------------------------------------------------------------
/**
*
@@ -2115,7 +2445,7 @@ cout << endl << ">> in PlotFourier() ..." << endl;
}
//--------------------------------------------------------------------------
-// PlotFourierPhaseValue
+// PlotFourierPhaseValue (private)
//--------------------------------------------------------------------------
/**
*
@@ -2151,7 +2481,89 @@ void PMusrCanvas::PlotFourierPhaseValue()
}
//--------------------------------------------------------------------------
-// SaveDataAscii
+// IncrementFourierPhase (private)
+//--------------------------------------------------------------------------
+/**
+ *
+ *
+ * \param tag
+ */
+void PMusrCanvas::IncrementFourierPhase()
+{
+ double re, im;
+ const double cp = TMath::Cos(fFourier.fPhaseIncrement/180.0*TMath::Pi());
+ const double sp = TMath::Sin(fFourier.fPhaseIncrement/180.0*TMath::Pi());
+
+ fCurrentFourierPhase += fFourier.fPhaseIncrement;
+ PlotFourierPhaseValue();
+
+ for (unsigned int i=0; i
+ *
+ * \param tag
+ */
+void PMusrCanvas::DecrementFourierPhase()
+{
+ double re, im;
+ const double cp = TMath::Cos(fFourier.fPhaseIncrement/180.0*TMath::Pi());
+ const double sp = TMath::Sin(fFourier.fPhaseIncrement/180.0*TMath::Pi());
+
+ fCurrentFourierPhase -= fFourier.fPhaseIncrement;
+ PlotFourierPhaseValue();
+
+ for (unsigned int i=0; i
@@ -2638,7 +3050,7 @@ void PMusrCanvas::SaveDataAscii()
}
//--------------------------------------------------------------------------
-// SaveDataDb
+// SaveDataDb (private)
//--------------------------------------------------------------------------
/**
*
@@ -3281,379 +3693,3 @@ void PMusrCanvas::SaveDataDb()
cout << endl << ">> Data windows saved in db format ..." << endl;
}
-
-//--------------------------------------------------------------------------
-// HandleFourier
-//--------------------------------------------------------------------------
-/**
- *
- *
- * \param tag
- */
-void PMusrCanvas::HandleFourier(int tag)
-{
- // if fourier was invoked via the 'f' cmd key, take the default plot tag
- if (tag == -1) { // called via cmd key 'f'
- tag = fFourier.fPlotTag;
- }
-
-
- // if the current view is a data plot, fourier needs to be calculated
- if (fCurrentPlotView == PV_DATA) {
- if (!fDifferenceView) { // data view
- // delete fourier components
- for (unsigned int i=0; i
- *
- * \param tag
- */
-void PMusrCanvas::IncrementFourierPhase()
-{
- double re, im;
- const double cp = TMath::Cos(fFourier.fPhaseIncrement/180.0*TMath::Pi());
- const double sp = TMath::Sin(fFourier.fPhaseIncrement/180.0*TMath::Pi());
-
- fCurrentFourierPhase += fFourier.fPhaseIncrement;
- PlotFourierPhaseValue();
-
- for (unsigned int i=0; i
- *
- * \param tag
- */
-void PMusrCanvas::DecrementFourierPhase()
-{
- double re, im;
- const double cp = TMath::Cos(fFourier.fPhaseIncrement/180.0*TMath::Pi());
- const double sp = TMath::Sin(fFourier.fPhaseIncrement/180.0*TMath::Pi());
-
- fCurrentFourierPhase -= fFourier.fPhaseIncrement;
- PlotFourierPhaseValue();
-
- for (unsigned int i=0; i