diff --git a/src/classes/PMusrCanvas.cpp b/src/classes/PMusrCanvas.cpp index a0c18d38..0f75f35c 100644 --- a/src/classes/PMusrCanvas.cpp +++ b/src/classes/PMusrCanvas.cpp @@ -132,7 +132,7 @@ PMusrCanvas::PMusrCanvas(const int number, const char* title, */ PMusrCanvas::~PMusrCanvas() { -cout << "~PMusrCanvas() called. fMainCanvas name=" << fMainCanvas->GetName() << endl; +//cout << "~PMusrCanvas() called. fMainCanvas name=" << fMainCanvas->GetName() << endl; // cleanup if (fStyle) { delete fStyle; @@ -180,10 +180,8 @@ cout << "~PMusrCanvas() called. fMainCanvas name=" << fMainCanvas->GetName() << fMultiGraphDiff = 0; } if (fNonMusrData.size() > 0) { -/* for (unsigned int i=0; iGetMsrParamList(); @@ -344,6 +342,7 @@ void PMusrCanvas::UpdateParamTheoryPad() fTheoryPad->AddText(0.03, ypos, functions[i].fLine.Data()); } + fParameterPad->Draw(); fTheoryPad->Draw(); fMainCanvas->cd(); @@ -900,6 +899,52 @@ void PMusrCanvas::LastCanvasClosed() } } +//-------------------------------------------------------------------------- +// SaveGraphicsAndQuit +//-------------------------------------------------------------------------- +/** + *

+ * + * \param graphicsFormat One of the supported graphics formats. + */ +void PMusrCanvas::SaveGraphicsAndQuit(char *fileName, char *graphicsFormat) +{ + cout << endl << ">> SaveGraphicsAndQuit: will dump the canvas into a graphics output file (" << graphicsFormat << ") ..."<< endl; + + TString str(fileName); + Int_t idx = -1; + Int_t size = 0; + char ext[32]; + + if (str.Contains(".msr")) { + idx = str.Index(".msr"); + size = 4; + } + if (str.Contains(".mlog")) { + idx = str.Index(".mlog"); + size = 5; + } + + if (idx == -1) { + cout << endl << "PMusrCanvas::SaveGraphicsAndQuit **ERROR**: fileName (" << fileName << ") is invalid." << endl; + return; + } + + sprintf(ext, "_%d", fPlotNumber); + str.Replace(idx, size, ext, strlen(ext)); + idx += strlen(ext); + size = strlen(ext); + sprintf(ext, ".%s", graphicsFormat); + str.Replace(idx, size, ext, strlen(ext)); + + cout << endl << ">> SaveGraphicsAndQuit: " << str.Data() << endl; + + fMainCanvas->SaveAs(str.Data()); + + if (fPlotNumber == static_cast(fMsrHandler->GetMsrPlotList()->size()) - 1) + Done(0); +} + //-------------------------------------------------------------------------- // CreateStyle (private) //-------------------------------------------------------------------------- @@ -908,7 +953,9 @@ void PMusrCanvas::LastCanvasClosed() */ void PMusrCanvas::CreateStyle() { - fStyle = new TStyle("musrStyle", "musrStyle"); + TString musrStyle("musrStyle"); + musrStyle += fPlotNumber; + fStyle = new TStyle(musrStyle, musrStyle); fStyle->SetOptStat(0); // no statistics options fStyle->SetOptTitle(0); // no title fStyle->cd(); @@ -1073,6 +1120,7 @@ void PMusrCanvas::InitMusrCanvas(const char* title, Int_t wtopx, Int_t wtopy, In fMainCanvas->cd(); fMainCanvas->Show(); + fMainCanvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "PMusrCanvas", this, "HandleCmdKey(Int_t,Int_t,Int_t,TObject*)"); @@ -1308,6 +1356,8 @@ void PMusrCanvas::HandleDataSet(unsigned int plotNo, unsigned int runNo, PRunDat // create histo specific infos name = fMsrHandler->GetMsrRunList()->at(runNo).fRunName[0] + "_DataRunNo"; name += (int)runNo; + name += "_"; + name += fPlotNumber; start = data->fDataTimeStart - data->fDataTimeStep/2.0; end = data->fDataTimeStart + data->fValue.size()*data->fDataTimeStep + data->fDataTimeStep/2.0; @@ -1344,6 +1394,8 @@ void PMusrCanvas::HandleDataSet(unsigned int plotNo, unsigned int runNo, PRunDat // create histo specific infos name = fMsrHandler->GetMsrRunList()->at(runNo).fRunName[0] + "_TheoRunNo"; name += (int)runNo; + name += "_"; + name += fPlotNumber; start = data->fTheoryTimeStart - data->fTheoryTimeStep/2.0; end = data->fTheoryTimeStart + data->fTheory.size()*data->fTheoryTimeStep + data->fTheoryTimeStep/2.0; @@ -1833,14 +1885,14 @@ cout << endl << ">> data scale = " << scale; */ double PMusrCanvas::FindOptimalFourierPhase() { -cout << endl << ">> in FindOptimalFourierPhase ... "; +//cout << endl << ">> in FindOptimalFourierPhase ... "; // check that Fourier is really present if ((fData[0].dataFourierRe == 0) || (fData[0].dataFourierIm == 0)) return 0.0; - double minPhase, x, valIm, val_xMin, val_xMax; - double minIm, maxIm, asymmetry; + Double_t minPhase, x, valIm, val_xMin = 0.0, val_xMax = 0.0; + Double_t minIm = 0.0, maxIm = 0.0, asymmetry; // get min/max of the imaginary part for phase = 0.0 as a starting point minPhase = 0.0; bool first = true; @@ -2873,22 +2925,22 @@ void PMusrCanvas::PlotFourierPhaseValue() double x, y; TString str; - // plot Fourier phase - str = TString("phase = "); - str += fCurrentFourierPhase; - x = 0.7; - y = 0.85; - fCurrentFourierPhaseText = new TLatex(); - fCurrentFourierPhaseText->SetNDC(kTRUE); - fCurrentFourierPhaseText->SetText(x, y, str.Data()); - fCurrentFourierPhaseText->SetTextFont(62); - fCurrentFourierPhaseText->SetTextSize(0.03); + // plot Fourier phase + str = TString("phase = "); + str += fCurrentFourierPhase; + x = 0.7; + y = 0.85; + fCurrentFourierPhaseText = new TLatex(); + fCurrentFourierPhaseText->SetNDC(kTRUE); + fCurrentFourierPhaseText->SetText(x, y, str.Data()); + fCurrentFourierPhaseText->SetTextFont(62); + fCurrentFourierPhaseText->SetTextSize(0.03); - fDataTheoryPad->cd(); + fDataTheoryPad->cd(); - fCurrentFourierPhaseText->Draw(); + fCurrentFourierPhaseText->Draw(); - fDataTheoryPad->Update(); + fDataTheoryPad->Update(); } //-------------------------------------------------------------------------- diff --git a/src/classes/PMusrT0.cpp b/src/classes/PMusrT0.cpp index 451df77e..4bd088e1 100644 --- a/src/classes/PMusrT0.cpp +++ b/src/classes/PMusrT0.cpp @@ -324,7 +324,7 @@ void PMusrT0::InitDataAndBkg() // add lines // t0 line - int t0Bin; + Int_t t0Bin = 0; switch (fDetectorTag) { case DETECTOR_TAG_FORWARD: t0Bin = fMsrHandler->GetMsrRunList()->at(fRunNo).fT0[0 + fAddRunNo * fAddRunOffset/2]; diff --git a/src/classes/PRunNonMusr.cpp b/src/classes/PRunNonMusr.cpp index 2394cebf..84d9d785 100644 --- a/src/classes/PRunNonMusr.cpp +++ b/src/classes/PRunNonMusr.cpp @@ -302,8 +302,8 @@ bool PRunNonMusr::PrepareViewData() // followed: the smallest x-interval found will be used to for the fXTheory resolution // which is 1000 function points. The function will be calculated from the smallest // xmin found up to the largest xmax found. - double xMin, xMax; - double xAbsMin, xAbsMax; + Double_t xMin = 0.0, xMax = 0.0; + Double_t xAbsMin = 0.0, xAbsMax = 0.0; bool first = true; // cout << endl << ">> plotList->size()=" << plotList->size(); for (unsigned int i=0; isize(); i++) { diff --git a/src/include/PMusrCanvas.h b/src/include/PMusrCanvas.h index 293680fc..709ce007 100644 --- a/src/include/PMusrCanvas.h +++ b/src/include/PMusrCanvas.h @@ -172,6 +172,8 @@ class PMusrCanvas : public TObject, public TQObject virtual void HandleMenuPopup(Int_t id); // SLOT virtual void LastCanvasClosed(); // SLOT + virtual void SaveGraphicsAndQuit(char *fileName, char *graphicsFormat); + private: Bool_t fValid; Bool_t fDifferenceView; /// tag showing that the shown data, fourier, are the difference between data and theory diff --git a/src/musrview.cpp b/src/musrview.cpp index 3b5a9a37..28be6a18 100644 --- a/src/musrview.cpp +++ b/src/musrview.cpp @@ -58,14 +58,13 @@ void musrview_syntax() cout << endl << "usage: musrview [--] | --version | --help"; cout << endl << " : msr/mlog input file"; cout << endl << " 'musrview ' will execute musrview"; - cout << endl << ">> ----- NOT YET IMPLEMENTED ----- << "; cout << endl << " --: "; cout << endl << " will produce a graphics-output-file without starting a root session."; - cout << endl << " the name is based on the , e.g. 3310.msr -> 3310.png"; + cout << endl << " the name is based on the , e.g. 3310.msr -> 3310_0.png"; cout << endl << " supported graphic-format-extension:"; cout << endl << " eps, pdf, gif, jpg, png, svg, xpm, root"; - cout << endl << " example: musrview 3310.msr --png, will produce a file 3310.png"; - cout << endl << ">> ----- NOT YET IMPLEMENTED ----- << "; + cout << endl << " example: musrview 3310.msr --png, will produce a files 3310_X.png"; + cout << endl << " where 'X' stands for the plot number (starting form 0)"; cout << endl << " 'musrview' or 'musrview --help' will show this help"; cout << endl << " 'musrview --version' will print the musrview version"; cout << endl << endl; @@ -79,8 +78,10 @@ int main(int argc, char *argv[]) bool success = true; char fileName[128]; bool graphicsOutput = false; - char graphicsExtension[32]; + char graphicsExtension[128]; + + // check input arguments switch (argc) { case 1: show_syntax = true; @@ -291,6 +292,10 @@ cout << endl; musrCanvas->Connect("Done(Int_t)", "TApplication", &app, "Terminate(Int_t)"); + if (graphicsOutput) { + musrCanvas->SaveGraphicsAndQuit(fileName, graphicsExtension); + } + // keep musrCanvas objects canvasVector.push_back(musrCanvas); } @@ -300,24 +305,24 @@ cout << endl; app.Run(true); // true needed that Run will return after quit so that cleanup works // clean up -cout << endl << "clean up canvas vector ..."; +//cout << endl << "clean up canvas vector ..."; char canvasName[32]; for (unsigned int i=0; i> canvasName=" << canvasName << ", canvasVector[" << i << "]=" << canvasVector[i]; +//cout << endl << ">> canvasName=" << canvasName << ", canvasVector[" << i << "]=" << canvasVector[i]; if (gROOT->GetListOfCanvases()->FindObject(canvasName) != 0) { -cout << endl << ">> canvasName=" << canvasName << ", found ..."; -cout << endl; +//cout << endl << ">> canvasName=" << canvasName << ", found ..."; +//cout << endl; canvasVector[i]->~PMusrCanvas(); } else { -cout << endl << ">> canvasName=" << canvasName << ", NOT found ..."; -cout << endl; +//cout << endl << ">> canvasName=" << canvasName << ", NOT found ..."; +//cout << endl; } } canvasVector.empty(); } -cout << endl; +//cout << endl; // clean up plotList.clear();