12 #include "TGFileDialog.h"
13 #include "TGPicture.h"
14 #include "TGTextEdit.h"
18 #include "ImagePaste.xpm"
19 #include "ImageSave.xpm"
26 using std::stringstream;
35 AddFrame(
fTextEditor,
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 0));
38 AddFrame(
fButtonsFrame,
new TGLayoutHints(kLHintsCenterX, 5, 5, 5, 5));
41 fPasteButton->Connect(
"Clicked()",
"QGCutsEditorWindow",
this,
"HandlePasteButton()");
46 fSaveButton->Connect(
"Clicked()",
"QGCutsEditorWindow",
this,
"HandleSaveButton()");
47 fSaveButton->SetToolTipText(
"Save these cuts as well as any graphical cuts to file");
63 if (cuts.size() != 0) {
70 vector<string>::const_iterator cutIter;
71 for (cutIter = cuts.begin(); cutIter != cuts.end(); ++cutIter) {
72 string cut =
" (" + *cutIter +
")";
74 if (cutIter + 1 != cuts.end()) {
87 TString dir(cutsDirectory.c_str());
89 fi.fIniDir = StrDup(dir);
90 const char *filetypes[] = {
"GUI session files" ,
"*.gui",
92 fi.fFileTypes = filetypes;
93 new TGFileDialog(gClient->GetRoot(), 0, kFDSave, &fi);
95 TString filename(fi.fFilename);
96 TString extension(fi.fFileTypes[fi.fFileTypeIdx+1]);
97 extension.Remove(TString::kLeading,
'*');
98 if (!filename.EndsWith(extension)) {
99 filename.Append(extension);
101 Save(filename.Data());
102 string currentDirectory = fi.fIniDir;
103 if (currentDirectory != cutsDirectory) {
121 list<QGPlot*>::const_iterator plotIter;
122 for (plotIter = plots.begin(); plotIter != plots.end(); ++plotIter) {
124 string name = graphicalCut->GetName();
125 string xVariable = graphicalCut->GetXVariable();
126 string yVariable = graphicalCut->GetYVariable();
131 for (Int_t vertex = 0; vertex < graphicalCut->GetN() - 1; ++vertex) {
132 stringstream vertexStream;
133 vertexStream.precision(16);
134 vertexStream << graphicalCut->GetX()[vertex] <<
" , " << graphicalCut->GetY()[vertex] << flush;
142 textFileHandler->
WriteFile(filename.c_str());
143 delete textFileHandler;
#define GRAPHICAL_CUT_KEY
Window used to manage writing cuts to a file.
TGPictureButton * fPasteButton
Paste button.
QGCutsEditorWindow(const TGWindow *p=0, UInt_t w=600, UInt_t h=600)
Constructor.
TGTextEdit * fTextEditor
Text editor.
TGPictureButton * fSaveButton
Save button.
void HandleSaveButton()
Handle save button.
void Save(const std::string &filename)
Save cuts to file.
virtual ~QGCutsEditorWindow()
Destructor.
void HandlePasteButton()
Handle paste button.
TGHorizontalFrame * fButtonsFrame
Buttons frame.
static const std::vector< std::string > & GetCopiedCuts()
Get copied cuts.
void SetCutsDirectory(const std::string &directory)
Set cuts directory.
const std::string & GetCutsDirectory()
Get cuts directory.
static QGDefaultsHandler * Instance()
Singleton.
Class for graphical cuts.
static const std::list< QGPlot * > & GetPlots()
Get collection of plots.
Class to handle input and output for text files.
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.
Base class for GUI windows.
virtual void SetWindowName(const char *name=0)
Set name of window.
std::string Resize(const std::string &s, size_t len)
resize a string to len, adding spaces if necessary