Public Member Functions | Private Member Functions | Private Attributes | List of all members
evdb::PrintDialog Class Reference

#include <PrintDialog.h>

Inheritance diagram for evdb::PrintDialog:

Public Member Functions

 PrintDialog ()
 
 ~PrintDialog ()
 
void CloseWindow ()
 
void PrintToFile ()
 
void Cancel ()
 

Private Member Functions

 ClassDef (PrintDialog, 0)
 

Private Attributes

TGCompositeFrame * fPrintFrame [10]
 
TGCheckButton * fPrintableCB [10]
 
TGTextEntry * fFilename [10]
 
TGCheckButton * fDoEPS [10]
 
TGCheckButton * fDoPDF [10]
 
TGCheckButton * fDoGIF [10]
 
TGCheckButton * fDoPNG [10]
 
TGCompositeFrame * fButtonFrame
 
TGTextButton * fPrintButton
 
TGTextButton * fCancelButton
 
TGLayoutHints * fL1
 
TGLayoutHints * fL2
 
int fNprintable
 
std::string fPrintTag [10]
 
PrintablefPrintable [10]
 

Detailed Description

Definition at line 22 of file PrintDialog.h.

Constructor & Destructor Documentation

evdb::PrintDialog::PrintDialog ( )

Definition at line 29 of file PrintDialog.cxx.

29  :
30  TGTransientFrame(0,0,800,300,0),
31  fNprintable(0)
32  {
33  fL1 = new TGLayoutHints(kLHintsLeft|kLHintsTop|kLHintsExpandX, 2, 2, 2, 2);
34  fL2 = new TGLayoutHints(kLHintsLeft|kLHintsTop, 2, 2, 2, 2);
35 
36  // Add list of printable object to dialog box. Make a check box for
37  // each one:
38  //
39  // Description | Filename Format
40  // ----------------| -------------------------------------------------
41  // [*] Main window | evd.main.001234.000123456 [ ].eps [ ].ps [*].gif
42  // [*] TPC display | evd.tpc.001234.000123456 [ ].eps [ ].ps [*].gif
43  //
44  int wPrintable = 500; // Width of description field
45  int wFilename = 200; // Width of filename field
46  int wCheckBox = 100; // Width of check boxes
47  int h = 20; // Height of fields
48  int i = 0; // Counter
49  std::map<std::string,Printable*>&
50  printables = Printable::GetPrintables();
51  std::map<std::string,Printable*>::iterator itr(printables.begin());
52  std::map<std::string,Printable*>::iterator itrEnd(printables.end());
53  for (; itr!=itrEnd; ++itr) {
54  fPrintTag[i] = itr->first;
55  fPrintable[i] = itr->second;
56  fPrintFrame[i] = new TGHorizontalFrame(this,20,20);
57 
58  std::string ptag;
61  base = "evd.";
62  base += itr->second->PrintTag();
63 
64  char runevt[128];
65  sprintf(runevt,".%d.%d",
66  evdb::EventHolder::Instance()->GetEvent()->run(),
67  evdb::EventHolder::Instance()->GetEvent()->id().event());
68  base += runevt;
69 
70  // Title of the printable object
71  fPrintableCB[i] = new TGCheckButton(fPrintFrame[i], itr->first.c_str());
72  fPrintableCB[i]->Resize(wPrintable, h);
73  fPrintFrame[i]->AddFrame(fPrintableCB[i], fL1);
75  fPrintableCB[i]->SetState(kButtonDown);
76  }
77 
78  // Base file name to use during print
79  fFilename[i] = new TGTextEntry(fPrintFrame[i], new TGTextBuffer(256));
80  fFilename[i]->SetToolTipText("Base file name for print");
81  fFilename[i]->SetText(base.c_str());
82  fFilename[i]->Resize(wFilename,h);
83  fPrintFrame[i]->AddFrame(fFilename[i], fL2);
84 
85  // PNG check box
86  fDoPNG[i] = new TGCheckButton(fPrintFrame[i], ".png");
87  fDoPNG[i]->Resize(wCheckBox,h);
88  fPrintFrame[i]->AddFrame(fDoPNG[i], fL2);
89  ptag = fPrintTag[i]; ptag += ".png";
90  if (gsFormatSelection[ptag]) fDoPNG[i]->SetState(kButtonDown);
91 
92  // GIF check box
93  fDoGIF[i] = new TGCheckButton(fPrintFrame[i], ".gif");
94  fDoGIF[i]->Resize(wCheckBox,h);
95  fPrintFrame[i]->AddFrame(fDoGIF[i], fL2);
96  ptag = fPrintTag[i]; ptag += ".gif";
97  if (gsFormatSelection[ptag]) fDoGIF[i]->SetState(kButtonDown);
98 
99  // PDF check box
100  fDoPDF[i] = new TGCheckButton(fPrintFrame[i], ".pdf");
101  fDoPDF[i]->Resize(wCheckBox,h);
102  fPrintFrame[i]->AddFrame(fDoPDF[i], fL2);
103  ptag = fPrintTag[i]; ptag += ".pdf";
104  if (gsFormatSelection[ptag]) fDoPDF[i]->SetState(kButtonDown);
105 
106  // EPS check box
107  fDoEPS[i] = new TGCheckButton(fPrintFrame[i], ".eps");
108  fDoEPS[i]->Resize(wCheckBox,h);
109  fPrintFrame[i]->AddFrame(fDoEPS[i], fL2);
110  ptag = fPrintTag[i]; ptag += ".eps";
111  if (gsFormatSelection[ptag]) fDoEPS[i]->SetState(kButtonDown);
112 
113  ++i;
114  }
115  fNprintable = i;
116 
117  // Build the button frame along the bottom
118  fButtonFrame = new TGHorizontalFrame(this,20,20);
119 
120  fPrintButton = new TGTextButton(fButtonFrame,"&Print",150);
121  fPrintButton->Connect("Clicked()",
122  "evdb::PrintDialog",
123  this,
124  "PrintToFile()");
125 
126  fButtonFrame->AddFrame(fPrintButton,
127  new TGLayoutHints(kLHintsLeft,4,4,4,4));
128 
129  fCancelButton = new TGTextButton(fButtonFrame,"&Cancel",150);
130  fCancelButton->Connect("Clicked()", "evdb::PrintDialog", this, "Cancel()");
131  fButtonFrame->AddFrame(fCancelButton,
132  new TGLayoutHints(kLHintsRight,4,4,4,4));
133 
134  // Layout the main frame
135  for (int i=0; i<fNprintable; ++i) this->AddFrame(fPrintFrame[i],fL1);
136  this->AddFrame(fButtonFrame);
137  this->MapSubwindows();
138  this->Resize(500, fNprintable*(h+8)+38);
139 
140  this->SetWindowName("Print Dialog");
141  this->MapWindow();
142 
143  this->Connect("CloseWindow()","evdb::PrintDialog",this,"CloseWindow()");
144  }
intermediate_table::iterator iterator
static std::map< std::string, bool > gsPrintableSelection
Definition: PrintDialog.cxx:24
TGCheckButton * fDoGIF[10]
Definition: PrintDialog.h:39
std::string string
Definition: nybbler.cc:12
TGCheckButton * fDoEPS[10]
Definition: PrintDialog.h:37
TGTextEntry * fFilename[10]
Definition: PrintDialog.h:36
TGLayoutHints * fL2
Definition: PrintDialog.h:47
std::string fPrintTag[10]
Definition: PrintDialog.h:50
string filename
Definition: train.py:213
TGCheckButton * fDoPDF[10]
Definition: PrintDialog.h:38
TGCheckButton * fPrintableCB[10]
Definition: PrintDialog.h:35
static std::map< std::string, evdb::Printable * > & GetPrintables()
Definition: Printable.cxx:61
TGCheckButton * fDoPNG[10]
Definition: PrintDialog.h:40
static EventHolder * Instance()
Definition: EventHolder.cxx:15
TGTextButton * fCancelButton
Definition: PrintDialog.h:44
TGLayoutHints * fL1
Definition: PrintDialog.h:46
TGCompositeFrame * fButtonFrame
Definition: PrintDialog.h:42
TGCompositeFrame * fPrintFrame[10]
Definition: PrintDialog.h:34
static std::map< std::string, bool > gsFormatSelection
Definition: PrintDialog.cxx:25
TGTextButton * fPrintButton
Definition: PrintDialog.h:43
Printable * fPrintable[10]
Definition: PrintDialog.h:51
h
training ###############################
Definition: train_cnn.py:186
unsigned int run
evdb::PrintDialog::~PrintDialog ( )

Definition at line 152 of file PrintDialog.cxx.

153  {
154  for (int i=0; i<fNprintable; ++i) {
155  delete fDoPNG[i];
156  delete fDoGIF[i];
157  delete fDoEPS[i];
158  delete fDoPDF[i];
159  delete fFilename[i];
160  delete fPrintableCB[i];
161  delete fPrintFrame[i];
162  }
163  delete fPrintButton;
164  delete fCancelButton;
165  delete fButtonFrame;
166  delete fL1;
167  delete fL2;
168  }
TGCheckButton * fDoGIF[10]
Definition: PrintDialog.h:39
TGCheckButton * fDoEPS[10]
Definition: PrintDialog.h:37
TGTextEntry * fFilename[10]
Definition: PrintDialog.h:36
TGLayoutHints * fL2
Definition: PrintDialog.h:47
TGCheckButton * fDoPDF[10]
Definition: PrintDialog.h:38
TGCheckButton * fPrintableCB[10]
Definition: PrintDialog.h:35
TGCheckButton * fDoPNG[10]
Definition: PrintDialog.h:40
TGTextButton * fCancelButton
Definition: PrintDialog.h:44
TGLayoutHints * fL1
Definition: PrintDialog.h:46
TGCompositeFrame * fButtonFrame
Definition: PrintDialog.h:42
TGCompositeFrame * fPrintFrame[10]
Definition: PrintDialog.h:34
TGTextButton * fPrintButton
Definition: PrintDialog.h:43

Member Function Documentation

void evdb::PrintDialog::Cancel ( )

Definition at line 172 of file PrintDialog.cxx.

172 { this->SendCloseMessage(); }
evdb::PrintDialog::ClassDef ( PrintDialog  ,
 
)
private
void evdb::PrintDialog::CloseWindow ( )

Definition at line 148 of file PrintDialog.cxx.

148 { delete this; }
void evdb::PrintDialog::PrintToFile ( )

Definition at line 176 of file PrintDialog.cxx.

177  {
178  int nFormats = 4;
179  std::string format[4] = { ".png", ".gif", ".pdf", ".eps" };
180  bool doPrint[4];
181 
182  for (int i=0; i<fNprintable; ++i) {
183  bool printMe = (fPrintableCB[i]->GetState() == kButtonDown);
184 
185  // Remember which printables are selected for use next time
186  gsPrintableSelection[fPrintTag[i]] = printMe;
187 
188  // Handle the print
189  if (printMe) {
190  std::string base = fFilename[i]->GetText();
191 
192  doPrint[0] = (fDoPNG[i]->GetState() == kButtonDown);
193  doPrint[1] = (fDoGIF[i]->GetState() == kButtonDown);
194  doPrint[2] = (fDoPDF[i]->GetState() == kButtonDown);
195  doPrint[3] = (fDoEPS[i]->GetState() == kButtonDown);
196  for (int j=0; j<nFormats; ++j) {
197  // Printable tag (with format) and file name
198  std::string ftag(fPrintTag[i]); ftag += format[j];
199  std::string f(base); f += format[j];
200 
201  // Remember format choices for next time
202  gsFormatSelection[ftag] = doPrint[j];
203 
204  // Actually do the print
205  if (doPrint[j]) {
206  fPrintable[i]->Print(f.c_str());
207  }
208 
209  } // Loop on formats
210  } // If printable is checked
211  } // Loop on printables
212 
213  // Done printing. Cancel the window
214  this->Cancel();
215  }
static std::map< std::string, bool > gsPrintableSelection
Definition: PrintDialog.cxx:24
TGCheckButton * fDoGIF[10]
Definition: PrintDialog.h:39
std::string string
Definition: nybbler.cc:12
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
Definition: qstring.cpp:11496
TGCheckButton * fDoEPS[10]
Definition: PrintDialog.h:37
TGTextEntry * fFilename[10]
Definition: PrintDialog.h:36
std::string fPrintTag[10]
Definition: PrintDialog.h:50
TGCheckButton * fDoPDF[10]
Definition: PrintDialog.h:38
TGCheckButton * fPrintableCB[10]
Definition: PrintDialog.h:35
TGCheckButton * fDoPNG[10]
Definition: PrintDialog.h:40
static std::map< std::string, bool > gsFormatSelection
Definition: PrintDialog.cxx:25
Printable * fPrintable[10]
Definition: PrintDialog.h:51
virtual void Print(const char *filename)=0

Member Data Documentation

TGCompositeFrame* evdb::PrintDialog::fButtonFrame
private

Definition at line 42 of file PrintDialog.h.

TGTextButton* evdb::PrintDialog::fCancelButton
private

Definition at line 44 of file PrintDialog.h.

TGCheckButton* evdb::PrintDialog::fDoEPS[10]
private

Definition at line 37 of file PrintDialog.h.

TGCheckButton* evdb::PrintDialog::fDoGIF[10]
private

Definition at line 39 of file PrintDialog.h.

TGCheckButton* evdb::PrintDialog::fDoPDF[10]
private

Definition at line 38 of file PrintDialog.h.

TGCheckButton* evdb::PrintDialog::fDoPNG[10]
private

Definition at line 40 of file PrintDialog.h.

TGTextEntry* evdb::PrintDialog::fFilename[10]
private

Definition at line 36 of file PrintDialog.h.

TGLayoutHints* evdb::PrintDialog::fL1
private

Definition at line 46 of file PrintDialog.h.

TGLayoutHints* evdb::PrintDialog::fL2
private

Definition at line 47 of file PrintDialog.h.

int evdb::PrintDialog::fNprintable
private

Definition at line 49 of file PrintDialog.h.

Printable* evdb::PrintDialog::fPrintable[10]
private

Definition at line 51 of file PrintDialog.h.

TGCheckButton* evdb::PrintDialog::fPrintableCB[10]
private

Definition at line 35 of file PrintDialog.h.

TGTextButton* evdb::PrintDialog::fPrintButton
private

Definition at line 43 of file PrintDialog.h.

TGCompositeFrame* evdb::PrintDialog::fPrintFrame[10]
private

Definition at line 34 of file PrintDialog.h.

std::string evdb::PrintDialog::fPrintTag[10]
private

Definition at line 50 of file PrintDialog.h.


The documentation for this class was generated from the following files: