get rid of raw pointers for PFourierCanvas where it makes sense.
This commit is contained in:
@@ -55,7 +55,6 @@ ClassImpQ(PFourierCanvas)
|
||||
PFourierCanvas::PFourierCanvas()
|
||||
{
|
||||
fTimeout = 0;
|
||||
fTimeoutTimer = nullptr;
|
||||
|
||||
fBatchMode = false;
|
||||
fValid = false;
|
||||
@@ -69,18 +68,10 @@ PFourierCanvas::PFourierCanvas()
|
||||
fXaxisTitle = TString("");
|
||||
|
||||
fCurrentFourierPhase = 0.0;
|
||||
fCurrentFourierPhaseText = nullptr;
|
||||
|
||||
fStyle = nullptr;
|
||||
fImp = nullptr;
|
||||
fBar = nullptr;
|
||||
fPopupMain = nullptr;
|
||||
fPopupFourier = nullptr;
|
||||
|
||||
fMainCanvas = nullptr;
|
||||
fTitlePad = nullptr;
|
||||
fFourierPad = nullptr;
|
||||
fInfoPad = nullptr;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -112,12 +103,9 @@ PFourierCanvas::PFourierCanvas(std::vector<PFourier*> &fourier, PIntVector dataS
|
||||
fInitialXRange[1] = fourierXrange[1];
|
||||
|
||||
fTimeout = 0;
|
||||
fTimeoutTimer = nullptr;
|
||||
|
||||
fValid = false;
|
||||
|
||||
fCurrentFourierPhaseText = nullptr;
|
||||
|
||||
// generate fMarkerList and fColorList, since they are not provided
|
||||
TRandom rand;
|
||||
Int_t style, color;
|
||||
@@ -168,12 +156,9 @@ PFourierCanvas::PFourierCanvas(std::vector<PFourier*> &fourier, PIntVector dataS
|
||||
fInitialXRange[1] = fourierXrange[1];
|
||||
|
||||
fTimeout = 0;
|
||||
fTimeoutTimer = nullptr;
|
||||
|
||||
fValid = false;
|
||||
|
||||
fCurrentFourierPhaseText = nullptr;
|
||||
|
||||
// generate fMarkerList and fColorList, since they are not provided
|
||||
TRandom rand;
|
||||
Int_t style, color;
|
||||
@@ -196,70 +181,6 @@ PFourierCanvas::PFourierCanvas(std::vector<PFourier*> &fourier, PIntVector dataS
|
||||
gStyle->SetHistMinimumZero(kTRUE); // needed to enforce proper bar option handling
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Destructor
|
||||
*/
|
||||
PFourierCanvas::~PFourierCanvas()
|
||||
{
|
||||
if (fTimeoutTimer)
|
||||
delete fTimeoutTimer;
|
||||
|
||||
if (fCurrentFourierPhaseText)
|
||||
delete fCurrentFourierPhaseText;
|
||||
|
||||
/*
|
||||
if (fStyle) {
|
||||
delete fStyle;
|
||||
fStyle = 0;
|
||||
}
|
||||
*/
|
||||
if (fTitlePad) {
|
||||
fTitlePad->Clear();
|
||||
delete fTitlePad;
|
||||
fTitlePad = nullptr;
|
||||
}
|
||||
|
||||
if (fFourierHistos.size() > 0) {
|
||||
for (UInt_t i=0; i<fFourierHistos.size(); i++) {
|
||||
delete fFourierHistos[i].dataFourierRe;
|
||||
delete fFourierHistos[i].dataFourierIm;
|
||||
delete fFourierHistos[i].dataFourierPwr;
|
||||
delete fFourierHistos[i].dataFourierPhase;
|
||||
delete fFourierHistos[i].dataFourierPhaseOptReal;
|
||||
}
|
||||
fFourierHistos.clear();
|
||||
}
|
||||
|
||||
CleanupAverage();
|
||||
|
||||
/*
|
||||
if (fFourierPad) {
|
||||
fFourierPad->Clear();
|
||||
delete fFourierPad;
|
||||
fFourierPad = 0;
|
||||
}
|
||||
*/
|
||||
if (fInfoPad) {
|
||||
fInfoPad->Clear();
|
||||
delete fInfoPad;
|
||||
fInfoPad = nullptr;
|
||||
}
|
||||
|
||||
if (fLegAvgPerDataSet) {
|
||||
fLegAvgPerDataSet->Clear();
|
||||
delete fLegAvgPerDataSet;
|
||||
fLegAvgPerDataSet = nullptr;
|
||||
}
|
||||
|
||||
/*
|
||||
if (fMainCanvas) {
|
||||
delete fMainCanvas;
|
||||
fMainCanvas = nullptr;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Done (SIGNAL)
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -563,11 +484,7 @@ void PFourierCanvas::SetTimeout(Int_t timeout)
|
||||
if (fTimeout <= 0)
|
||||
return;
|
||||
|
||||
if (fTimeoutTimer) {
|
||||
delete fTimeoutTimer;
|
||||
fTimeoutTimer = nullptr;
|
||||
}
|
||||
fTimeoutTimer = new TTimer();
|
||||
fTimeoutTimer.reset(new TTimer());
|
||||
|
||||
fTimeoutTimer->Connect("Timeout()", "PFourierCanvas", this, "Done()");
|
||||
|
||||
@@ -831,7 +748,7 @@ void PFourierCanvas::CreateXaxisTitle()
|
||||
void PFourierCanvas::CreateStyle()
|
||||
{
|
||||
TString musrFTStyle("musrFTStyle");
|
||||
fStyle = new TStyle(musrFTStyle, musrFTStyle);
|
||||
fStyle = std::make_unique<TStyle>(musrFTStyle, musrFTStyle);
|
||||
fStyle->SetOptStat(0); // no statistics options
|
||||
fStyle->SetOptTitle(0); // no title
|
||||
fStyle->cd();
|
||||
@@ -990,21 +907,10 @@ void PFourierCanvas::InitFourierCanvas(const Char_t* title, Int_t wtopx, Int_t w
|
||||
fImp = nullptr;
|
||||
fBar = nullptr;
|
||||
fPopupMain = nullptr;
|
||||
fPopupFourier = nullptr;
|
||||
|
||||
fMainCanvas = nullptr;
|
||||
fTitlePad = nullptr;
|
||||
fFourierPad = nullptr;
|
||||
fInfoPad = nullptr;
|
||||
|
||||
// invoke canvas
|
||||
TString canvasName = TString("fMainCanvas");
|
||||
fMainCanvas = new TCanvas(canvasName.Data(), title, wtopx, wtopy, ww, wh);
|
||||
if (fMainCanvas == nullptr) {
|
||||
std::cerr << std::endl << "PFourierCanvas::PFourierCanvas: **PANIC ERROR**: Couldn't invoke " << canvasName.Data();
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
fMainCanvas = std::make_unique<TCanvas>(canvasName.Data(), title, wtopx, wtopy, ww, wh);
|
||||
|
||||
// add canvas menu if not in batch mode
|
||||
if (!fBatchMode) {
|
||||
@@ -1012,9 +918,9 @@ void PFourierCanvas::InitFourierCanvas(const Char_t* title, Int_t wtopx, Int_t w
|
||||
fBar = fImp->GetMenuBar();
|
||||
fPopupMain = fBar->AddPopup("MusrFT");
|
||||
|
||||
fPopupFourier = new TGPopupMenu();
|
||||
fPopupFourier = std::make_unique<TGPopupMenu>();
|
||||
|
||||
fPopupMain->AddPopup("&Fourier", fPopupFourier);
|
||||
fPopupMain->AddPopup("&Fourier", fPopupFourier.get());
|
||||
fPopupFourier->AddEntry("Show Real", P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_REAL);
|
||||
fPopupFourier->AddEntry("Show Imag", P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_IMAG);
|
||||
fPopupFourier->AddEntry("Show Real+Imag", P_MENU_ID_FOURIER+P_MENU_ID_FOURIER_REAL_AND_IMAG);
|
||||
@@ -1067,39 +973,25 @@ void PFourierCanvas::InitFourierCanvas(const Char_t* title, Int_t wtopx, Int_t w
|
||||
|
||||
// divide the canvas into sub pads
|
||||
// title pad
|
||||
fTitlePad = new TPaveText(0.0, YTITLE, 1.0, 1.0, "NDC");
|
||||
if (fTitlePad == nullptr) {
|
||||
std::cerr << std::endl << "PFourierCanvas::PFourierCanvas: **PANIC ERROR**: Couldn't invoke fTitlePad";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
fTitlePad = std::make_unique<TPaveText>(0.0, YTITLE, 1.0, 1.0, "NDC");
|
||||
|
||||
fTitlePad->SetFillColor(TColor::GetColor(255,255,255));
|
||||
fTitlePad->SetTextAlign(12); // middle, left
|
||||
fTitlePad->AddText(title);
|
||||
fTitlePad->Draw();
|
||||
|
||||
// fourier pad
|
||||
fFourierPad = new TPad("fFourierPad", "fFourierPad", 0.0, YINFO, 1.0, YTITLE);
|
||||
if (fFourierPad == nullptr) {
|
||||
std::cerr << std::endl << "PFourierCanvas::PFourierCanvas: **PANIC ERROR**: Couldn't invoke fFourierPad";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
fFourierPad = std::make_unique<TPad>("fFourierPad", "fFourierPad", 0.0, YINFO, 1.0, YTITLE);
|
||||
|
||||
fFourierPad->SetFillColor(TColor::GetColor(255,255,255));
|
||||
fFourierPad->Draw();
|
||||
|
||||
// info pad
|
||||
fInfoPad = new TLegend(0.0, 0.0, 1.0, YINFO, "NDC");
|
||||
if (fInfoPad == nullptr) {
|
||||
std::cerr << std::endl << "PFourierCanvas::PFourierCanvas: **PANIC ERROR**: Couldn't invoke fInfoPad";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
fInfoPad = std::make_unique<TLegend>(0.0, 0.0, 1.0, YINFO, "NDC");
|
||||
|
||||
fInfoPad->SetFillColor(TColor::GetColor(255,255,255));
|
||||
fInfoPad->SetTextAlign(12); // middle, left
|
||||
|
||||
fLegAvgPerDataSet = nullptr;
|
||||
|
||||
fValid = true;
|
||||
|
||||
if ((fFourier.size() != fDataSetTag.size()) && fAveragedViewPerDataSet) {
|
||||
@@ -1629,12 +1521,6 @@ void PFourierCanvas::PlotFourier()
|
||||
*/
|
||||
void PFourierCanvas::PlotFourierPhaseValue()
|
||||
{
|
||||
// check if phase TLatex object is present
|
||||
if (fCurrentFourierPhaseText) {
|
||||
delete fCurrentFourierPhaseText;
|
||||
fCurrentFourierPhaseText = nullptr;
|
||||
}
|
||||
|
||||
Double_t x, y;
|
||||
TString str;
|
||||
|
||||
@@ -1643,7 +1529,7 @@ void PFourierCanvas::PlotFourierPhaseValue()
|
||||
str += fCurrentFourierPhase;
|
||||
x = 0.7;
|
||||
y = 0.85;
|
||||
fCurrentFourierPhaseText = new TLatex();
|
||||
fCurrentFourierPhaseText.reset(new TLatex());
|
||||
fCurrentFourierPhaseText->SetNDC(kTRUE);
|
||||
fCurrentFourierPhaseText->SetText(x, y, str.Data());
|
||||
fCurrentFourierPhaseText->SetTextFont(62);
|
||||
@@ -1675,10 +1561,8 @@ void PFourierCanvas::PlotAverage()
|
||||
xmax = fInitialXRange[1];
|
||||
Double_t ymin=0.0, ymax=0.0;
|
||||
|
||||
if (fLegAvgPerDataSet) {
|
||||
if (fLegAvgPerDataSet.get()) {
|
||||
fLegAvgPerDataSet->Clear();
|
||||
delete fLegAvgPerDataSet;
|
||||
fLegAvgPerDataSet = nullptr;
|
||||
}
|
||||
|
||||
switch (fCurrentPlotView) {
|
||||
@@ -1799,7 +1683,7 @@ void PFourierCanvas::PlotAverage()
|
||||
}
|
||||
|
||||
if (fAveragedViewPerDataSet) { // plot all the rest
|
||||
fLegAvgPerDataSet = new TLegend(0.55, 0.4, 0.85, 0.6);
|
||||
fLegAvgPerDataSet = std::make_unique<TLegend>(0.55, 0.4, 0.85, 0.6);
|
||||
TString str = GetDataSetName(fFourierAverage[0].dataFourierPwr->GetTitle());
|
||||
TString label = TString::Format("<%s>", str.Data());
|
||||
fLegAvgPerDataSet->AddEntry(fFourierAverage[0].dataFourierPwr, label.Data());
|
||||
|
||||
Reference in New Issue
Block a user