get rid of raw pointers for PFourierCanvas where it makes sense.
This commit is contained in:
parent
18f077c6e7
commit
1c8c1a8d0f
@ -55,7 +55,6 @@ ClassImpQ(PFourierCanvas)
|
|||||||
PFourierCanvas::PFourierCanvas()
|
PFourierCanvas::PFourierCanvas()
|
||||||
{
|
{
|
||||||
fTimeout = 0;
|
fTimeout = 0;
|
||||||
fTimeoutTimer = nullptr;
|
|
||||||
|
|
||||||
fBatchMode = false;
|
fBatchMode = false;
|
||||||
fValid = false;
|
fValid = false;
|
||||||
@ -69,18 +68,10 @@ PFourierCanvas::PFourierCanvas()
|
|||||||
fXaxisTitle = TString("");
|
fXaxisTitle = TString("");
|
||||||
|
|
||||||
fCurrentFourierPhase = 0.0;
|
fCurrentFourierPhase = 0.0;
|
||||||
fCurrentFourierPhaseText = nullptr;
|
|
||||||
|
|
||||||
fStyle = nullptr;
|
|
||||||
fImp = nullptr;
|
fImp = nullptr;
|
||||||
fBar = nullptr;
|
fBar = nullptr;
|
||||||
fPopupMain = 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];
|
fInitialXRange[1] = fourierXrange[1];
|
||||||
|
|
||||||
fTimeout = 0;
|
fTimeout = 0;
|
||||||
fTimeoutTimer = nullptr;
|
|
||||||
|
|
||||||
fValid = false;
|
fValid = false;
|
||||||
|
|
||||||
fCurrentFourierPhaseText = nullptr;
|
|
||||||
|
|
||||||
// generate fMarkerList and fColorList, since they are not provided
|
// generate fMarkerList and fColorList, since they are not provided
|
||||||
TRandom rand;
|
TRandom rand;
|
||||||
Int_t style, color;
|
Int_t style, color;
|
||||||
@ -168,12 +156,9 @@ PFourierCanvas::PFourierCanvas(std::vector<PFourier*> &fourier, PIntVector dataS
|
|||||||
fInitialXRange[1] = fourierXrange[1];
|
fInitialXRange[1] = fourierXrange[1];
|
||||||
|
|
||||||
fTimeout = 0;
|
fTimeout = 0;
|
||||||
fTimeoutTimer = nullptr;
|
|
||||||
|
|
||||||
fValid = false;
|
fValid = false;
|
||||||
|
|
||||||
fCurrentFourierPhaseText = nullptr;
|
|
||||||
|
|
||||||
// generate fMarkerList and fColorList, since they are not provided
|
// generate fMarkerList and fColorList, since they are not provided
|
||||||
TRandom rand;
|
TRandom rand;
|
||||||
Int_t style, color;
|
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
|
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)
|
// Done (SIGNAL)
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@ -563,11 +484,7 @@ void PFourierCanvas::SetTimeout(Int_t timeout)
|
|||||||
if (fTimeout <= 0)
|
if (fTimeout <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fTimeoutTimer) {
|
fTimeoutTimer.reset(new TTimer());
|
||||||
delete fTimeoutTimer;
|
|
||||||
fTimeoutTimer = nullptr;
|
|
||||||
}
|
|
||||||
fTimeoutTimer = new TTimer();
|
|
||||||
|
|
||||||
fTimeoutTimer->Connect("Timeout()", "PFourierCanvas", this, "Done()");
|
fTimeoutTimer->Connect("Timeout()", "PFourierCanvas", this, "Done()");
|
||||||
|
|
||||||
@ -831,7 +748,7 @@ void PFourierCanvas::CreateXaxisTitle()
|
|||||||
void PFourierCanvas::CreateStyle()
|
void PFourierCanvas::CreateStyle()
|
||||||
{
|
{
|
||||||
TString musrFTStyle("musrFTStyle");
|
TString musrFTStyle("musrFTStyle");
|
||||||
fStyle = new TStyle(musrFTStyle, musrFTStyle);
|
fStyle = std::make_unique<TStyle>(musrFTStyle, musrFTStyle);
|
||||||
fStyle->SetOptStat(0); // no statistics options
|
fStyle->SetOptStat(0); // no statistics options
|
||||||
fStyle->SetOptTitle(0); // no title
|
fStyle->SetOptTitle(0); // no title
|
||||||
fStyle->cd();
|
fStyle->cd();
|
||||||
@ -990,21 +907,10 @@ void PFourierCanvas::InitFourierCanvas(const Char_t* title, Int_t wtopx, Int_t w
|
|||||||
fImp = nullptr;
|
fImp = nullptr;
|
||||||
fBar = nullptr;
|
fBar = nullptr;
|
||||||
fPopupMain = nullptr;
|
fPopupMain = nullptr;
|
||||||
fPopupFourier = nullptr;
|
|
||||||
|
|
||||||
fMainCanvas = nullptr;
|
|
||||||
fTitlePad = nullptr;
|
|
||||||
fFourierPad = nullptr;
|
|
||||||
fInfoPad = nullptr;
|
|
||||||
|
|
||||||
// invoke canvas
|
// invoke canvas
|
||||||
TString canvasName = TString("fMainCanvas");
|
TString canvasName = TString("fMainCanvas");
|
||||||
fMainCanvas = new TCanvas(canvasName.Data(), title, wtopx, wtopy, ww, wh);
|
fMainCanvas = std::make_unique<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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add canvas menu if not in batch mode
|
// add canvas menu if not in batch mode
|
||||||
if (!fBatchMode) {
|
if (!fBatchMode) {
|
||||||
@ -1012,9 +918,9 @@ void PFourierCanvas::InitFourierCanvas(const Char_t* title, Int_t wtopx, Int_t w
|
|||||||
fBar = fImp->GetMenuBar();
|
fBar = fImp->GetMenuBar();
|
||||||
fPopupMain = fBar->AddPopup("MusrFT");
|
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 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 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);
|
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
|
// divide the canvas into sub pads
|
||||||
// title pad
|
// title pad
|
||||||
fTitlePad = new TPaveText(0.0, YTITLE, 1.0, 1.0, "NDC");
|
fTitlePad = std::make_unique<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->SetFillColor(TColor::GetColor(255,255,255));
|
fTitlePad->SetFillColor(TColor::GetColor(255,255,255));
|
||||||
fTitlePad->SetTextAlign(12); // middle, left
|
fTitlePad->SetTextAlign(12); // middle, left
|
||||||
fTitlePad->AddText(title);
|
fTitlePad->AddText(title);
|
||||||
fTitlePad->Draw();
|
fTitlePad->Draw();
|
||||||
|
|
||||||
// fourier pad
|
// fourier pad
|
||||||
fFourierPad = new TPad("fFourierPad", "fFourierPad", 0.0, YINFO, 1.0, YTITLE);
|
fFourierPad = std::make_unique<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->SetFillColor(TColor::GetColor(255,255,255));
|
fFourierPad->SetFillColor(TColor::GetColor(255,255,255));
|
||||||
fFourierPad->Draw();
|
fFourierPad->Draw();
|
||||||
|
|
||||||
// info pad
|
// info pad
|
||||||
fInfoPad = new TLegend(0.0, 0.0, 1.0, YINFO, "NDC");
|
fInfoPad = std::make_unique<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->SetFillColor(TColor::GetColor(255,255,255));
|
fInfoPad->SetFillColor(TColor::GetColor(255,255,255));
|
||||||
fInfoPad->SetTextAlign(12); // middle, left
|
fInfoPad->SetTextAlign(12); // middle, left
|
||||||
|
|
||||||
fLegAvgPerDataSet = nullptr;
|
|
||||||
|
|
||||||
fValid = true;
|
fValid = true;
|
||||||
|
|
||||||
if ((fFourier.size() != fDataSetTag.size()) && fAveragedViewPerDataSet) {
|
if ((fFourier.size() != fDataSetTag.size()) && fAveragedViewPerDataSet) {
|
||||||
@ -1629,12 +1521,6 @@ void PFourierCanvas::PlotFourier()
|
|||||||
*/
|
*/
|
||||||
void PFourierCanvas::PlotFourierPhaseValue()
|
void PFourierCanvas::PlotFourierPhaseValue()
|
||||||
{
|
{
|
||||||
// check if phase TLatex object is present
|
|
||||||
if (fCurrentFourierPhaseText) {
|
|
||||||
delete fCurrentFourierPhaseText;
|
|
||||||
fCurrentFourierPhaseText = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Double_t x, y;
|
Double_t x, y;
|
||||||
TString str;
|
TString str;
|
||||||
|
|
||||||
@ -1643,7 +1529,7 @@ void PFourierCanvas::PlotFourierPhaseValue()
|
|||||||
str += fCurrentFourierPhase;
|
str += fCurrentFourierPhase;
|
||||||
x = 0.7;
|
x = 0.7;
|
||||||
y = 0.85;
|
y = 0.85;
|
||||||
fCurrentFourierPhaseText = new TLatex();
|
fCurrentFourierPhaseText.reset(new TLatex());
|
||||||
fCurrentFourierPhaseText->SetNDC(kTRUE);
|
fCurrentFourierPhaseText->SetNDC(kTRUE);
|
||||||
fCurrentFourierPhaseText->SetText(x, y, str.Data());
|
fCurrentFourierPhaseText->SetText(x, y, str.Data());
|
||||||
fCurrentFourierPhaseText->SetTextFont(62);
|
fCurrentFourierPhaseText->SetTextFont(62);
|
||||||
@ -1675,10 +1561,8 @@ void PFourierCanvas::PlotAverage()
|
|||||||
xmax = fInitialXRange[1];
|
xmax = fInitialXRange[1];
|
||||||
Double_t ymin=0.0, ymax=0.0;
|
Double_t ymin=0.0, ymax=0.0;
|
||||||
|
|
||||||
if (fLegAvgPerDataSet) {
|
if (fLegAvgPerDataSet.get()) {
|
||||||
fLegAvgPerDataSet->Clear();
|
fLegAvgPerDataSet->Clear();
|
||||||
delete fLegAvgPerDataSet;
|
|
||||||
fLegAvgPerDataSet = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (fCurrentPlotView) {
|
switch (fCurrentPlotView) {
|
||||||
@ -1799,7 +1683,7 @@ void PFourierCanvas::PlotAverage()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fAveragedViewPerDataSet) { // plot all the rest
|
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 str = GetDataSetName(fFourierAverage[0].dataFourierPwr->GetTitle());
|
||||||
TString label = TString::Format("<%s>", str.Data());
|
TString label = TString::Format("<%s>", str.Data());
|
||||||
fLegAvgPerDataSet->AddEntry(fFourierAverage[0].dataFourierPwr, label.Data());
|
fLegAvgPerDataSet->AddEntry(fFourierAverage[0].dataFourierPwr, label.Data());
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#define _PFOURIERCANVAS_H_
|
#define _PFOURIERCANVAS_H_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <TObject.h>
|
#include <TObject.h>
|
||||||
#include <TQObject.h>
|
#include <TQObject.h>
|
||||||
@ -99,7 +100,6 @@ class PFourierCanvas : public TObject, public TQObject
|
|||||||
const Int_t fourierPlotOpt, Double_t fourierXrange[2], Double_t phase,
|
const Int_t fourierPlotOpt, Double_t fourierXrange[2], Double_t phase,
|
||||||
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh,
|
Int_t wtopx, Int_t wtopy, Int_t ww, Int_t wh,
|
||||||
const PIntVector markerList, const PIntVector colorList, const Bool_t batch);
|
const PIntVector markerList, const PIntVector colorList, const Bool_t batch);
|
||||||
virtual ~PFourierCanvas();
|
|
||||||
|
|
||||||
virtual void Done(Int_t status=0); // *SIGNAL*
|
virtual void Done(Int_t status=0); // *SIGNAL*
|
||||||
virtual void HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected); // SLOT
|
virtual void HandleCmdKey(Int_t event, Int_t x, Int_t y, TObject *selected); // SLOT
|
||||||
@ -133,27 +133,27 @@ class PFourierCanvas : public TObject, public TQObject
|
|||||||
PFourierCanvasDataList fFourierHistos; ///< keeps all the Fourier histos
|
PFourierCanvasDataList fFourierHistos; ///< keeps all the Fourier histos
|
||||||
PFourierCanvasDataList fFourierAverage; ///< keeps the average of the Fourier histos
|
PFourierCanvasDataList fFourierAverage; ///< keeps the average of the Fourier histos
|
||||||
Double_t fCurrentFourierPhase; ///< keeps the current Fourier phase (real/imag)
|
Double_t fCurrentFourierPhase; ///< keeps the current Fourier phase (real/imag)
|
||||||
TLatex *fCurrentFourierPhaseText; ///< used in Re/Im Fourier to show the current phase in the pad
|
std::unique_ptr<TLatex> fCurrentFourierPhaseText; ///< used in Re/Im Fourier to show the current phase in the pad
|
||||||
|
|
||||||
TStyle *fStyle; ///< A collection of all graphics attributes
|
std::unique_ptr<TStyle> fStyle; ///< A collection of all graphics attributes
|
||||||
|
|
||||||
TTimer *fTimeoutTimer; ///< timeout timer in order to terminate if no action is taking place for too long
|
std::unique_ptr<TTimer> fTimeoutTimer; ///< timeout timer in order to terminate if no action is taking place for too long
|
||||||
|
|
||||||
PIntVector fMarkerList; ///< list of markers
|
PIntVector fMarkerList; ///< list of markers
|
||||||
PIntVector fColorList; ///< list of colors
|
PIntVector fColorList; ///< list of colors
|
||||||
|
|
||||||
// canvas menu related variables
|
// canvas menu related variables
|
||||||
TRootCanvas *fImp; ///< ROOT native GUI version of main window with menubar and drawing area
|
TRootCanvas *fImp; ///< ROOT native GUI version of main window with menubar and drawing area
|
||||||
TGMenuBar *fBar; ///< menu bar
|
TGMenuBar *fBar; ///< menu bar
|
||||||
TGPopupMenu *fPopupMain; ///< popup menu MusrFT in the main menu bar
|
TGPopupMenu *fPopupMain; ///< popup menu MusrFT in the main menu bar
|
||||||
TGPopupMenu *fPopupFourier; ///< popup menu of the MusrFT/Fourier sub menu
|
std::unique_ptr<TGPopupMenu> fPopupFourier; ///< popup menu of the MusrFT/Fourier sub menu
|
||||||
|
|
||||||
// canvas related variables
|
// canvas related variables
|
||||||
TCanvas *fMainCanvas; ///< main canvas
|
std::unique_ptr<TCanvas> fMainCanvas; ///< main canvas
|
||||||
TPaveText *fTitlePad; ///< title pad used to display a title
|
std::unique_ptr<TPaveText> fTitlePad; ///< title pad used to display a title
|
||||||
TPad *fFourierPad; ///< fourier pad used to display the fourier
|
std::unique_ptr<TPad> fFourierPad; ///< fourier pad used to display the fourier
|
||||||
TLegend *fInfoPad; ///< info pad used to display a legend of the data plotted
|
std::unique_ptr<TLegend> fInfoPad; ///< info pad used to display a legend of the data plotted
|
||||||
TLegend *fLegAvgPerDataSet; ///< legend used for averaged per data set view
|
std::unique_ptr<TLegend> fLegAvgPerDataSet; ///< legend used for averaged per data set view
|
||||||
|
|
||||||
virtual void CreateXaxisTitle();
|
virtual void CreateXaxisTitle();
|
||||||
virtual void CreateStyle();
|
virtual void CreateStyle();
|
||||||
|
@ -1540,7 +1540,7 @@ Int_t main(Int_t argc, Char_t *argv[])
|
|||||||
}
|
}
|
||||||
// check that everything is ok
|
// check that everything is ok
|
||||||
if (ok)
|
if (ok)
|
||||||
app.Run(true); // true needed that Run will return after quit so that cleanup works
|
app.Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
return PMUSR_SUCCESS;
|
return PMUSR_SUCCESS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user