Diana Software
QGPlotEditButtonsFrame.cc
Go to the documentation of this file.
2 #include <iostream>
3 #include <list>
4 #include <typeinfo>
5 #include "QGCanvasWindow.hh"
6 #include "QGPlot.hh"
7 #include "QGPlotEditWindow.hh"
8 #include "QGPlotListWindow.hh"
9 #include "TGButton.h"
10 #include "TGComboBox.h"
11 #include "TGLabel.h"
12 #include "TGPicture.h"
13 #include "TGTextEntry.h"
14 
15 // Images
16 #include "ImageDelete.xpm"
17 #include "ImageDraw.xpm"
18 #include "ImageDuplicate.xpm"
19 #include "ImageErase.xpm"
20 #include "ImageNameSmall.xpm"
21 
23 
24 using std::list;
25 using std::string;
26 using std::vector;
27 
29 TGCompositeFrame(p, w, h),
30 fPlotEditWindow(p)
31 {
32  SetCleanup(kDeepCleanup);
33 
34  fDrawEraseFrame = new TGHorizontalFrame(this, w, 25);
35  AddFrame(fDrawEraseFrame, new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0));
36 
37  fDrawButton = new TGPictureButton(fDrawEraseFrame, gClient->GetPicturePool()->GetPicture("Draw", (char**)ImageDraw));
38  fDrawEraseFrame->AddFrame(fDrawButton, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 0, 0, 0, 0));
39  fDrawButton->SetToolTipText("Draw the plot");
40  fDrawButton->Connect("Clicked()", "QGPlotEditButtonsFrame", this, "HandleDrawButton()");
41 
42  fEraseButton = new TGPictureButton(fDrawEraseFrame, gClient->GetPicturePool()->GetPicture("Erase", (char**)ImageErase));
43  fDrawEraseFrame->AddFrame(fEraseButton, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 0, 0, 0, 0));
44  fEraseButton->SetToolTipText("Erase the plot");
45  fEraseButton->Connect("Clicked()", "QGPlotEditButtonsFrame", this, "HandleEraseButton()");
46 
47  fWindowFrame = new TGHorizontalFrame(this, w, 25);
48  AddFrame(fWindowFrame, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 0));
49 
50  fWindowLabel = new TGLabel(fWindowFrame, "Window:");
51  fWindowFrame->AddFrame(fWindowLabel, new TGLayoutHints(kLHintsCenterY, 0, 0, 0, 0));
52 
53  fWindowDropDownBox = new TGComboBox(fWindowFrame);
54  fWindowFrame->AddFrame(fWindowDropDownBox, new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 5, 0, 0, 0));
55  fWindowDropDownBox->Resize(fWindowDropDownBox->GetDefaultWidth(), 25);
57 
58  fNameDeleteDuplicateFrame = new TGHorizontalFrame(this, w, 25);
59  AddFrame(fNameDeleteDuplicateFrame, new TGLayoutHints(kLHintsCenterX, 0, 0, 2, 0));
60 
61  fNameButton = new TGPictureButton(fNameDeleteDuplicateFrame, gClient->GetPicturePool()->GetPicture("NameSmall", (char**)ImageNameSmall));
62  fNameDeleteDuplicateFrame->AddFrame(fNameButton, new TGLayoutHints(kLHintsCenterY, 0, 0, 0, 0));
63  fNameButton->SetToolTipText("Set the plot name");
64  fNameButton->Connect("Clicked()", "QGPlotEditButtonsFrame", this, "HandleNameButton()");
65 
66  fNameEntryBox = new TGTextEntry(fNameDeleteDuplicateFrame);
67  fNameDeleteDuplicateFrame->AddFrame(fNameEntryBox, new TGLayoutHints(kLHintsCenterY, 0, 0, 0, 0));
68  fNameEntryBox->Resize(fNameEntryBox->GetDefaultWidth(), 25);
69  fNameEntryBox->SetToolTipText("Enter a new name for the plot and press Return. Leave blank to cancel.");
70  fNameEntryBox->Connect("ReturnPressed()", "QGPlotEditButtonsFrame", this, "HandleNameEntryBox()");
71 
72  fDeleteButton = new TGPictureButton(fNameDeleteDuplicateFrame, gClient->GetPicturePool()->GetPicture("Delete", (char**)ImageDelete));
73  fNameDeleteDuplicateFrame->AddFrame(fDeleteButton, new TGLayoutHints(kLHintsCenterY, 0, 0, 0, 0));
74  fDeleteButton->SetToolTipText("Delete the plot");
75  fDeleteButton->Connect("Clicked()", "QGPlotEditButtonsFrame", this, "HandleDeleteButton()");
76 
77  fDuplicateButton = new TGPictureButton(fNameDeleteDuplicateFrame, gClient->GetPicturePool()->GetPicture("Duplicate", (char**)ImageDuplicate));
78  fNameDeleteDuplicateFrame->AddFrame(fDuplicateButton, new TGLayoutHints(kLHintsCenterY, 0, 0, 0, 0));
79  fDuplicateButton->SetToolTipText("Make a duplicate of the plot");
80  fDuplicateButton->Connect("Clicked()", "QGPlotEditButtonsFrame", this, "HandleDuplicateButton()");
81 }
82 
84 {
85  Cleanup();
86 }
87 
89 {
90  fWindowDropDownBox->RemoveAll();
91  Int_t id = 0;
92  list<QGWindow*>::const_iterator windowIter;
93  for (windowIter = QGWindow::GetWindows().begin(); windowIter != QGWindow::GetWindows().end(); ++windowIter) {
94  const QGWindow *window = *windowIter;
95  if (typeid(*window) == typeid(QGCanvasWindow)) {
96  fWindowDropDownBox->AddEntry(window->GetWindowName(), id++);
97  }
98  }
101  string windowName = fPlotEditWindow->GetPlot()->GetCanvasWindow()->GetWindowName();
102  if (fWindowDropDownBox->FindEntry(windowName.c_str())) {
103  fWindowDropDownBox->Select(fWindowDropDownBox->FindEntry(windowName.c_str())->EntryId());
104  }
105  }
106  }
107 }
108 
110 {
111  string name = "";
112  if (fWindowDropDownBox && fWindowDropDownBox->GetSelectedEntry()) {
113  name = fWindowDropDownBox->GetSelectedEntry()->GetTitle();
114  }
115  return name;
116 }
117 
119 {
121  delete fPlotEditWindow->GetPlot();
122 }
123 
125 {
128 }
129 
131 {
134 }
135 
137 {
139 }
140 
142 {
143  if (fNameDeleteDuplicateFrame->IsVisible(fNameEntryBox)) {
145  } else {
150  fNameDeleteDuplicateFrame->Resize(fNameDeleteDuplicateFrame->GetDefaultSize());
151  fNameEntryBox->SetFocus();
152  fNameEntryBox->SelectAll();
153  }
154 }
155 
157 {
158  string newName = fNameEntryBox->GetText();
159  if (newName != "") {
160  fPlotEditWindow->GetPlot()->SetName(newName.c_str());
161  newName = fPlotEditWindow->GetPlot()->GetName();
162  string windowName = "Diana GUI: " + newName;
163  fPlotEditWindow->SetWindowName(windowName.c_str());
165  }
169  fNameDeleteDuplicateFrame->Resize(fNameDeleteDuplicateFrame->GetDefaultSize());
170 }
171 
173 {
178  fNameDeleteDuplicateFrame->Resize(fNameDeleteDuplicateFrame->GetDefaultSize());
179 }
ClassImp(QObject)
Window containing a ROOT canvas.
Frame to hold control buttons for plot edit window.
void HandleEraseButton()
Handle erase button.
void HandleDrawButton()
Handle draw button.
virtual ~QGPlotEditButtonsFrame()
Destructor.
TGPictureButton * fNameButton
Name button.
TGLabel * fWindowLabel
Window label.
void HandleNameEntryBox()
Handle name entry box.
TGTextEntry * fNameEntryBox
Name entry box.
void HandleDuplicateButton()
Handle duplicate button.
void ShowDefaultDisplay()
Show default display.
QGPlotEditWindow * fPlotEditWindow
Pointer to parent plot edit window.
TGPictureButton * fDeleteButton
Delete button.
std::string GetCanvasWindowName()
Get name of selected canvas window.
TGPictureButton * fDrawButton
Draw button.
TGPictureButton * fDuplicateButton
Duplicate button.
void HandleNameButton()
Handle name button.
TGHorizontalFrame * fWindowFrame
Horizontal frame for selecting canvas window.
TGComboBox * fWindowDropDownBox
Drop down box for selection canvas window.
TGPictureButton * fEraseButton
Erase button.
TGHorizontalFrame * fNameDeleteDuplicateFrame
Horizontal frame for Name/Delete/Duplicate buttons.
QGPlotEditButtonsFrame(QGPlotEditWindow *p, UInt_t w=100, UInt_t h=100)
Constructor.
void HandleDeleteButton()
Handle delete button.
TGHorizontalFrame * fDrawEraseFrame
Horizontal frame for Draw/Erase buttons.
void FillWindowDropDownBox()
Fill drop down box with names of canvas windows.
Base class for plot edit windows.
virtual QGPlot * GetPlot()=0
Get pointer to plot, pure virtual function must be overriden by derived classes.
static void Update()
Update the plot list.
virtual const char * GetName() const
Get plot name, should be overridden by derived classes.
Definition: QGPlot.cc:144
virtual void Duplicate()
Duplicate the plot, should be overridden by derived classes.
Definition: QGPlot.cc:82
virtual void Plot()
Plot this in the associated canvas window, generating it if necessary.
Definition: QGPlot.cc:195
virtual QGCanvasWindow * GetCanvasWindow() const
Get pointer to the canvas window to which the plot is associated.
Definition: QGPlot.hh:60
virtual void SetName(const char *name=0)
Set plot name.
Definition: QGPlot.cc:240
virtual void Erase()
Erase plot, should be overridden by derived classes.
Definition: QGPlot.cc:88
Base class for GUI windows.
Definition: QGWindow.hh:15
static const std::list< QGWindow * > & GetWindows()
Get collection of windows.
Definition: QGWindow.hh:27
virtual void SetWindowName(const char *name=0)
Set name of window.
Definition: QGWindow.cc:52