Diana Software
QGPlotListWindow.cc
Go to the documentation of this file.
1 #include "QGPlotListWindow.hh"
2 #include <iostream>
3 #include <list>
4 #include "QGPlot.hh"
6 #include "TGButton.h"
7 #include "TGCanvas.h"
8 #include "TGFrame.h"
9 
11 
12 using std::list;
13 using std::map;
14 
16 
18 {
19  if (!fMe) fMe = new QGPlotListWindow();
20  return fMe;
21 }
22 
23 QGPlotListWindow::QGPlotListWindow(const TGWindow *p, UInt_t w, UInt_t h) :
24 QGWindow(p, w, h)
25 {
26  SetWindowName("Plots List");
27 
28  fScrollableFrame = new TGCanvas(this);
29  fScrollableFrame->SetCleanup(kDeepCleanup);
30  fContainerFrame = new TGVerticalFrame(fScrollableFrame->GetViewPort());
31  fContainerFrame->SetCleanup(kDeepCleanup);
32  fScrollableFrame->SetContainer(fContainerFrame);
33 
34  /*
35  for (int i = 0; i < 10; ++i) {
36  TGTextButton *tb = new TGTextButton(fScrollableFrame->GetContainer(), "TextButton");
37  fScrollableFrame->AddFrame(tb, new TGLayoutHints(kLHintsCenterX, 20, 20, 20, 20));
38  }
39  */
40 
41  //QGPlotListEntryFrame *plef = new QGPlotListEntryFrame(fScrollableFrame->GetContainer());
42  //fScrollableFrame->AddFrame(plef, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
43 
44  AddFrame(fScrollableFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
45 
47 
48  Resize(GetDefaultSize());
49  MapSubwindows();
50  Resize(w, h);
51  MapWindow();
52 }
53 
55 {
56  /*std::map<QGPlot*, QGPlotListEntryFrame*>::iterator entryIter;
57  for (entryIter = fEntries.begin(); entryIter != fEntries.end(); ++entryIter) {
58  delete entryIter->second;
59  }*/
60  fContainerFrame->Cleanup();
61  Cleanup();
62  fMe = 0;
63 }
64 
66 {
67  if (plot) {
68  fEntries[plot] = new QGPlotListEntryFrame(fScrollableFrame->GetContainer());
69  fEntries[plot]->SetPlot(plot);
70  fScrollableFrame->AddFrame(fEntries[plot], new TGLayoutHints(kLHintsExpandX, 0, 0, 5, 0));
71  }
72 }
73 
74 void QGPlotListWindow::Clear(Option_t* opt)
75 
76 {
77  map<QGPlot*, QGPlotListEntryFrame*>::iterator entryIter;
78  for (entryIter = fEntries.begin(); entryIter != fEntries.end(); ++entryIter) {
79  RemoveEntry(entryIter->first);
80  //fContainerFrame->RemoveFrame(entryIter->second);
81  //entryIter->second->DestroyWindow();
82  //delete entryIter->second;
83  }
84  fEntries.clear();
85 }
86 
88 {
89  const list<QGPlot*>& plots = QGPlot::GetPlots();
90  list<QGPlot*>::const_iterator plotIter;
91  for (plotIter = plots.begin(); plotIter != plots.end(); ++plotIter) {
92  AddEntry(*plotIter);
93  }
94 }
95 
97 {
98  MapSubwindows();
99 }
100 
102 {
103  if (fEntries.count(plot) != 0) {
104  fContainerFrame->RemoveFrame(fEntries[plot]);
105  fEntries[plot]->DestroyWindow();
106  delete fEntries[plot];
107  fEntries.erase(plot);
108  }
109 }
110 
112 {
113  if (IsVisible()) {
114  fMe->Clear();
116  fMe->Refresh();
117  }
118 }
119 
ClassImp(QObject)
Class for entries in the plot list.
Singleton class for plot list window.
std::map< QGPlot *, QGPlotListEntryFrame * > fEntries
Map from plots to entries.
TGCanvas * fScrollableFrame
Scrollable frame.
void RemoveEntry(QGPlot *plot)
Remove entry for plot.
static bool IsVisible()
Returns true if the plot list window exists.
void AddEntry(QGPlot *plot)
Add entry for plot.
QGPlotListWindow(const TGWindow *p=0, UInt_t w=450, UInt_t h=300)
Private constructor.
void Refresh()
Refresh the contents of the window.
virtual ~QGPlotListWindow()
Destructor.
static QGPlotListWindow * Instance()
Singleton.
static void Update()
Update the plot list.
static QGPlotListWindow * fMe
Singleton.
void GeneratePlotList()
Generate list of plots.
void Clear(Option_t *opt="")
Clear the plot list.
TGVerticalFrame * fContainerFrame
Container frame for scrollable frame.
Base class for GUI plots including histograms, scatter plots, pulses, and graphical cuts.
Definition: QGPlot.hh:21
static const std::list< QGPlot * > & GetPlots()
Get collection of plots.
Definition: QGPlot.hh:84
Base class for GUI windows.
Definition: QGWindow.hh:15
virtual void SetWindowName(const char *name=0)
Set name of window.
Definition: QGWindow.cc:52
std::string Resize(const std::string &s, size_t len)
resize a string to len, adding spaces if necessary