Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CanvasInTab Class Reference

#include <CanvasInTab.hh>

Inheritance diagram for CanvasInTab:
Collaboration diagram for CanvasInTab:

Public Member Functions

 CanvasInTab (const TGWindow *p, UInt_t w, UInt_t h)
 
virtual ~CanvasInTab ()
 
size_t AddCanvas (const char *name="New tab")
 
TCanvas * GetCanvas (int i)
 
size_t GetNCanvas () const
 
void SaveCanvas ()
 

Detailed Description

Definition at line 36 of file CanvasInTab.hh.

Constructor & Destructor Documentation

CanvasInTab::CanvasInTab ( const TGWindow *  p,
UInt_t  w,
UInt_t  h 
)

Definition at line 70 of file CanvasInTab.cc.

71 : TGMainFrame(p,w,h)
72 {
73  fpTab = new TGTab(this, 200, 200);
74 
75  fHintPlots = new TGLayoutHints(kLHintsExpandX|kLHintsExpandY,
76  10,10,10,2);
77 
78  AddFrame(fpTab,
79  new TGLayoutHints(kLHintsExpandX |
80  kLHintsExpandY, 10,10,10,1));
81 
82  fpTab->Resize();
83 
84  //-----
85  TGHorizontalFrame* hframe=new TGHorizontalFrame(this, 200,40);
86 
87  TGTextButton* save = new TGTextButton(hframe,"&Save as ...");
88  save->Connect("Clicked()","CanvasInTab",this,"SaveCanvas()");
89  hframe->AddFrame(save, new TGLayoutHints(kLHintsCenterX,
90  5,5,3,4));
91 
92  TGTextButton *exit = new TGTextButton(hframe,"&Exit ",
93  "gApplication->Terminate()");
94  hframe->AddFrame(exit, new TGLayoutHints(kLHintsCenterX,
95  5,5,3,4));
96 
97  AddFrame(hframe,new TGLayoutHints(kLHintsCenterX,2,2,2,2));
98 
99  //-----
100  // Sets window name and shows the main frame
101 
102  SetWindowName("PlotG");
103  MapSubwindows();
104  Resize(GetDefaultSize());
105  MapWindow();
106 }
const char * p
Definition: xmltok.h:285
CanvasInTab::~CanvasInTab ( )
virtual

Definition at line 108 of file CanvasInTab.cc.

109 {
110  Cleanup();
111 // if(fpTab)
112 // {
114 // delete fpTab;
115 // }
116 
117 // if(fHintPlots)
118 // delete fHintPlots;
119 }

Member Function Documentation

size_t CanvasInTab::AddCanvas ( const char *  name = "New tab")

Definition at line 121 of file CanvasInTab.cc.

122 {
123  size_t output = fEcanvas.size();
124  auto compositeFrame = fpTab->AddTab(name);
125  TRootEmbeddedCanvas* embeddedCanvas =
126  new TRootEmbeddedCanvas(name,
127  compositeFrame,
128  500, 300);
129  embeddedCanvas->SetAutoFit();
130  fEcanvas.push_back(embeddedCanvas);
131  compositeFrame->AddFrame(embeddedCanvas, fHintPlots);
132  embeddedCanvas->SetContainer(compositeFrame);
133  fpTab->Resize();
134  fpTab->MapSubwindows();
135 // fpTab->MapWindow();
136  Resize();
137  return output;
138 }
const XML_Char * name
Definition: expat.h:151

Here is the caller graph for this function:

TCanvas * CanvasInTab::GetCanvas ( int  i)

Definition at line 140 of file CanvasInTab.cc.

141 {
142  return fEcanvas[i]->GetCanvas();
143 }

Here is the caller graph for this function:

size_t CanvasInTab::GetNCanvas ( ) const
inline

Definition at line 49 of file CanvasInTab.hh.

50  {
51  return fEcanvas.size();
52  }

Here is the caller graph for this function:

void CanvasInTab::SaveCanvas ( )

Definition at line 145 of file CanvasInTab.cc.

146 {
147  if(fpTab->GetNumberOfTabs() == 0) return;
148 
149  const char* name = SaveFileDialog();
150 
151  if(name == 0 || strlen(name) == 0) return;
152 
153  int current = fpTab->GetCurrent();
154  TCanvas* canvas = fEcanvas[current]->GetCanvas();
155  canvas->SaveAs(name);
156 }
const XML_Char * name
Definition: expat.h:151
const char * SaveFileDialog()
Definition: CanvasInTab.cc:43

Here is the call graph for this function:


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