LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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.

References fButtonFrame, fCancelButton, fDoEPS, fDoGIF, fDoPDF, fDoPNG, fFilename, fL1, fL2, fNprintable, fPrintable, fPrintableCB, fPrintButton, fPrintFrame, fPrintTag, evdb::Printable::GetPrintables(), and evdb::EventHolder::Instance().

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;
59  std::string base;
60  std::string filename;
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
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
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
Event finding and building.
evdb::PrintDialog::~PrintDialog ( )

Definition at line 152 of file PrintDialog.cxx.

References fButtonFrame, fCancelButton, fDoEPS, fDoGIF, fDoPDF, fDoPNG, fFilename, fL1, fL2, fNprintable, fPrintableCB, fPrintButton, and fPrintFrame.

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.

Referenced by PrintToFile().

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.

References Cancel(), f, fDoEPS, fDoGIF, fDoPDF, fDoPNG, fFilename, fNprintable, fPrintable, fPrintableCB, fPrintTag, and evdb::Printable::Print().

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
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
TFile f
Definition: plotHisto.C:6
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.

Referenced by PrintDialog(), and ~PrintDialog().

TGTextButton* evdb::PrintDialog::fCancelButton
private

Definition at line 44 of file PrintDialog.h.

Referenced by PrintDialog(), and ~PrintDialog().

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

Definition at line 37 of file PrintDialog.h.

Referenced by PrintDialog(), PrintToFile(), and ~PrintDialog().

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

Definition at line 39 of file PrintDialog.h.

Referenced by PrintDialog(), PrintToFile(), and ~PrintDialog().

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

Definition at line 38 of file PrintDialog.h.

Referenced by PrintDialog(), PrintToFile(), and ~PrintDialog().

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

Definition at line 40 of file PrintDialog.h.

Referenced by PrintDialog(), PrintToFile(), and ~PrintDialog().

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

Definition at line 36 of file PrintDialog.h.

Referenced by PrintDialog(), PrintToFile(), and ~PrintDialog().

TGLayoutHints* evdb::PrintDialog::fL1
private

Definition at line 46 of file PrintDialog.h.

Referenced by PrintDialog(), and ~PrintDialog().

TGLayoutHints* evdb::PrintDialog::fL2
private

Definition at line 47 of file PrintDialog.h.

Referenced by PrintDialog(), and ~PrintDialog().

int evdb::PrintDialog::fNprintable
private

Definition at line 49 of file PrintDialog.h.

Referenced by PrintDialog(), PrintToFile(), and ~PrintDialog().

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

Definition at line 51 of file PrintDialog.h.

Referenced by PrintDialog(), and PrintToFile().

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

Definition at line 35 of file PrintDialog.h.

Referenced by PrintDialog(), PrintToFile(), and ~PrintDialog().

TGTextButton* evdb::PrintDialog::fPrintButton
private

Definition at line 43 of file PrintDialog.h.

Referenced by PrintDialog(), and ~PrintDialog().

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

Definition at line 34 of file PrintDialog.h.

Referenced by PrintDialog(), and ~PrintDialog().

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

Definition at line 50 of file PrintDialog.h.

Referenced by PrintDialog(), and PrintToFile().


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