19 #include "TGFileDialog.h"
30 using std::stringstream;
34 fCurrentCalibrationWindow(0), fCurrentCanvasWindow(0), fCurrentPlot(0)
45 TString dir(sessionDirectory.c_str());
47 fi.fIniDir = StrDup(dir);
48 const char *filetypes[] = {
"GUI session files" ,
"*.gui",
50 fi.fFileTypes = filetypes;
51 new TGFileDialog(gClient->GetRoot(), 0, kFDOpen, &fi);
54 string currentDirectory = fi.fIniDir;
55 if (currentDirectory != sessionDirectory) {
64 if (textFileHandler->
ReadFile(filename)) {
65 const vector<pair<string, string> >& lines = textFileHandler->
GetLines();
66 vector<pair<string, string> >::const_iterator lineIter;
67 for (lineIter = lines.begin(); lineIter != lines.end(); ++lineIter) {
68 const string& key = lineIter->first;
69 const string& value = lineIter->second;
127 cout <<
"Unable to read file " << filename << endl;
129 delete textFileHandler;
135 TString dir(sessionDirectory.c_str());
137 fi.fIniDir = StrDup(dir);
138 const char *filetypes[] = {
"GUI session files" ,
"*.gui",
140 fi.fFileTypes = filetypes;
141 new TGFileDialog(gClient->GetRoot(), 0, kFDSave, &fi);
143 TString filename(fi.fFilename);
144 TString extension(fi.fFileTypes[fi.fFileTypeIdx+1]);
145 extension.Remove(TString::kLeading,
'*');
146 if (!filename.EndsWith(extension)) {
147 filename.Append(extension);
150 string currentDirectory = fi.fIniDir;
151 if (currentDirectory != sessionDirectory) {
164 list<QGWindow*>::const_iterator windowIter;
165 for (windowIter = windows.begin(); windowIter != windows.end(); ++windowIter) {
167 string name = canvasWindow->GetWindowName();
168 vector<string> filenames = canvasWindow->GetFileHandler()->GetFilenames();
171 vector<string>::const_iterator fileIter;
172 for (fileIter = filenames.begin(); fileIter != filenames.end(); ++fileIter) {
181 list<QGPlot*>::const_iterator plotIter;
182 for (plotIter = plots.begin(); plotIter != plots.end(); ++plotIter) {
183 string name = (*plotIter)->GetName();
184 string xVariable = (*plotIter)->GetXVariable();
185 string xUnits = (*plotIter)->GetXUnits();
186 string yVariable = (*plotIter)->GetYVariable();
187 string yUnits = (*plotIter)->GetYUnits();
188 bool superimpose = (*plotIter)->IsSuperimposeSet();
189 const vector<string>& cuts = (*plotIter)->GetCuts();
190 vector<string>::const_iterator cutIter;
197 if (histogram->IsXMinSet()) {
198 Double_t
min = histogram->GetXMin();
201 if (histogram->IsXMaxSet()) {
202 Double_t
max = histogram->GetXMax();
205 if (histogram->IsNumberOfBinsSet()) {
206 Int_t numberOfBins = histogram->GetNumberOfBins();
212 for (cutIter = cuts.begin(); cutIter != cuts.end(); ++ cutIter) {
235 for (cutIter = cuts.begin(); cutIter != cuts.end(); ++ cutIter) {
245 Int_t eventIndex = pulse->GetEventIndex();
247 const string& orderVariable = pulse->GetOrderVariable();
248 if (orderVariable !=
"") {
251 const string& samplesVariable = pulse->GetSamplesLabel();
252 if (samplesVariable !=
"") {
258 for (cutIter = cuts.begin(); cutIter != cuts.end(); ++ cutIter) {
273 for (Int_t vertex = 0; vertex < graphicalCut->GetN() - 1; ++vertex) {
274 stringstream vertexStream;
275 vertexStream.precision(16);
276 vertexStream << graphicalCut->GetX()[vertex] <<
" , " << graphicalCut->GetY()[vertex] << flush;
280 if ((*plotIter)->GetCanvasWindow()) {
281 string canvasWindowName = (*plotIter)->GetCanvasWindow()->GetWindowName();
289 delete textFileHandler;
#define NUMBER_OF_BINS_KEY
#define ORDER_VARIABLE_KEY
#define GRAPHICAL_CUT_KEY
#define CANVAS_WINDOW_NAME_KEY
#define CALIBRATION_WINDOW_KEY
#define CANVAS_WINDOW_KEY
#define PULSE_VARIABLE_KEY
double min(const Diana::QVector &v)
Used to select amplitude windows for calibration peaks.
void SetProperty(const std::string &key, const std::string &value)
Set property (used for opening a session)
Window containing a ROOT canvas.
void SetProperty(std::string key, std::string value)
Set property (used for opening a session)
void SetSessionDirectory(const std::string &directory)
Set session directory.
static QGDefaultsHandler * Instance()
Singleton.
const std::string & GetSessionDirectory()
Get session directory.
Class for graphical cuts.
Class for GUI histograms.
static void Update()
Update the plot list.
static const std::list< QGPlot * > & GetPlots()
Get collection of plots.
virtual void SetCanvasWindow(QGCanvasWindow *window)
Set the canvas window to which the plot is associated.
virtual void SetProperty(const std::string &key, const std::string &value)
Set property (used for opening a session)
virtual void AutoSetStyle()
Automatically set the plot style, should be overridden by derived classes.
virtual void SetName(const char *name=0)
Set plot name.
Class for GUI pulse plots.
Class for GUI scatter plots.
Class to handle saving and opening sessions.
QGCanvasWindow * fCurrentCanvasWindow
Current canvas window being created by OpenSession.
virtual ~QGSessionHandler()
Destructor.
QGCalibrationWindow * fCurrentCalibrationWindow
Current calibration window being created by OpenSession.
QGSessionHandler()
Constructor.
std::map< std::string, QGCanvasWindow * > fCanvasWindowsMap
Collection of canvas windows created by OpenSession.
void SaveSession()
Save session.
void OpenSession(QGCanvasWindow *window=0)
Open session.
QGPlot * fCurrentPlot
Current plot being created by OpenSession.
Class to handle input and output for text files.
const std::vector< std::pair< std::string, std::string > > & GetLines()
Get the lines of the file as key, value pairs.
bool ReadFile(std::string filename)
Read file, returns true if successful.
bool WriteFile(std::string filename)
Write file, returns true if successful.
void AppendLine(std::string key="", std::string value="")
Append a key and value to the file.
static const std::list< QGWindow * > & GetWindows()
Get collection of windows.
virtual void SetWindowName(const char *name=0)
Set name of window.