From 761f6571b17efdb6475d9c5b54cea6b8cadc1305 Mon Sep 17 00:00:00 2001 From: nemu Date: Mon, 23 Feb 2009 07:18:13 +0000 Subject: [PATCH] splitted parameter/theory pad for a potentially better handling for long theory lines, long paramter lists, long ... --- src/classes/PMusrCanvas.cpp | 83 ++++++++++++++++++++++++++----------- src/include/PMusrCanvas.h | 3 +- 2 files changed, 61 insertions(+), 25 deletions(-) diff --git a/src/classes/PMusrCanvas.cpp b/src/classes/PMusrCanvas.cpp index 0ed84eae..4f165679 100644 --- a/src/classes/PMusrCanvas.cpp +++ b/src/classes/PMusrCanvas.cpp @@ -67,7 +67,8 @@ PMusrCanvas::PMusrCanvas() fMainCanvas = 0; fTitlePad = 0; fDataTheoryPad = 0; - fParameterTheoryPad = 0; + fParameterPad = 0; + fTheoryPad = 0; fInfoPad = 0; fMultiGraphData = 0; @@ -146,10 +147,15 @@ cout << "~PMusrCanvas() called. fMainCanvas name=" << fMainCanvas->GetName() << delete fDataTheoryPad; fDataTheoryPad = 0; } - if (fParameterTheoryPad) { - fParameterTheoryPad->Clear(); - delete fParameterTheoryPad; - fParameterTheoryPad = 0; + if (fParameterPad) { + fParameterPad->Clear(); + delete fParameterPad; + fParameterPad = 0; + } + if (fTheoryPad) { + fTheoryPad->Clear(); + delete fTheoryPad; + fTheoryPad = 0; } if (fInfoPad) { fInfoPad->Clear(); @@ -241,7 +247,7 @@ void PMusrCanvas::UpdateParamTheoryPad() TString str; char cnum[128]; int maxLength = 0; - Double_t ypos; + Double_t ypos, yoffset; int idx; // add parameters ------------------------------------------------------------ @@ -253,6 +259,15 @@ void PMusrCanvas::UpdateParamTheoryPad() maxLength = param[i].fName.Length(); } maxLength += 2; + + // calculate yoffset based on the number of parameters + if (param.size() > 20) + yoffset = 1.0 / (param.size()+1); + else + yoffset = 0.05; + +cout << endl << ">> yoffset parameter = " << yoffset; + // add parameters to the pad for (unsigned int i=0; iAddText(0.03, ypos, str.Data()); + ypos = 0.98-i*yoffset; +cout << endl << ">> ypos = " << ypos; + fParameterPad->AddText(0.03, ypos, str.Data()); } // add theory ------------------------------------------------------------ - ypos -= 0.025; PMsrLines theory = *fMsrHandler->GetMsrTheory(); + if (theory.size() > 20) + yoffset = 1.0/(theory.size()+1); + else + yoffset = 0.05; +cout << endl << ">> yoffset theory = " << yoffset << endl; for (unsigned int i=1; iAddText(0.03, ypos, str.Data()); + ypos = 0.98 - i*yoffset; + fTheoryPad->AddText(0.03, ypos, str.Data()); } // add functions -------------------------------------------------------- - ypos -= 0.025; + ypos -= 0.05; PMsrLines functions = *fMsrHandler->GetMsrFunctions(); for (unsigned int i=1; iAddText(0.03, ypos, functions[i].fLine.Data()); + ypos -= 0.05; + fTheoryPad->AddText(0.03, ypos, functions[i].fLine.Data()); } - fParameterTheoryPad->Draw(); + fParameterPad->Draw(); + fTheoryPad->Draw(); fMainCanvas->cd(); fMainCanvas->Update(); } @@ -943,7 +964,8 @@ void PMusrCanvas::InitMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, In fMainCanvas = 0; fTitlePad = 0; fDataTheoryPad = 0; - fParameterTheoryPad = 0; + fParameterPad = 0; + fTheoryPad = 0; fInfoPad = 0; // invoke canvas @@ -1015,16 +1037,28 @@ void PMusrCanvas::InitMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, In 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"; + // parameter pad + fParameterPad = new TPaveText(XTHEO, 0.5, 1.0, YTITLE, "NDC"); + if (fParameterPad == 0) { + cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fParameterPad"; 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 + fParameterPad->SetFillColor(TColor::GetColor(255,255,255)); + fParameterPad->SetTextAlign(13); // top, left + fParameterPad->SetTextFont(102); // courier bold, scalable so that greek parameters will be plotted properly + + // theory pad + fTheoryPad = new TPaveText(XTHEO, 0.1, 1.0, 0.5, "NDC"); + if (fTheoryPad == 0) { + cout << endl << "PMusrCanvas::PMusrCanvas: **PANIC ERROR**: Couldn't invoke fTheoryPad"; + cout << endl; + return; + } + fTheoryPad->SetFillColor(TColor::GetColor(255,255,255)); + fTheoryPad->SetTextAlign(13); // top, left + fTheoryPad->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"); @@ -1047,7 +1081,8 @@ void PMusrCanvas::InitMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, In // cout << "fMainCanvas " << fMainCanvas << endl; // cout << "fTitlePad " << fTitlePad << endl; // cout << "fDataTheoryPad " << fDataTheoryPad << endl; -// cout << "fParameterTheoryPad " << fParameterTheoryPad << endl; +// cout << "fParameterPad " << fParameterPad << endl; +// cout << "fTheoryPad " << fTheoryPad << endl; // cout << "fInfoPad " << fInfoPad << endl; } diff --git a/src/include/PMusrCanvas.h b/src/include/PMusrCanvas.h index c3c5f30c..293680fc 100644 --- a/src/include/PMusrCanvas.h +++ b/src/include/PMusrCanvas.h @@ -195,7 +195,8 @@ class PMusrCanvas : public TObject, public TQObject TCanvas *fMainCanvas; TPaveText *fTitlePad; TPad *fDataTheoryPad; - TPaveText *fParameterTheoryPad; + TPaveText *fParameterPad; + TPaveText *fTheoryPad; TLegend *fInfoPad; #ifndef __MAKECINT__