Canvas.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file Canvas.cxx
3 /// \brief A base class for defining a detector display
4 ///
5 /// \version $Id: Canvas.cxx,v 1.6 2011-01-25 20:51:18 p-nusoftart Exp $
6 /// \author messier@indiana.edu
7 ////////////////////////////////////////////////////////////////////////
8 /// Revised 16-Apr-2009 seligman@nevis.columbia.edu
9 /// Allow dynamic re-sizing of the canvas if the user drags the window's
10 /// size box.
11 ////////////////////////////////////////////////////////////////////////
12 
13 // NuTools includes
16 
17 // ROOT includes
18 #include "TCanvas.h"
19 #include "TGFrame.h"
20 #include "TGLayout.h"
21 #include "TRootEmbeddedCanvas.h"
22 
23 #include <iostream>
24 #include <string>
25 
26 namespace evdb{
27 
28  //......................................................................
29 
30  ///
31  /// Perform the basic setup for a drawing canvas
32  ///
33  Canvas::Canvas(TGMainFrame* mf)
34  {
35  TGDimension sz; // Size of the main frame
36 
37  sz = mf->GetSize();
38  fXsize = sz.fWidth - 10; // Leave small margin on left and right
39  fYsize = sz.fHeight - 58; // Leave small margin on top and bottom
40  fAspectRatio = (float)fYsize/(float)fXsize;
41 
42  // This frame is apparently for holding the buttons on the top; it's
43  // not used for anything else.
44  fFrame = new TGCompositeFrame(mf, 60, 60, kHorizontalFrame);
45 
46  // Define a layout for placing the canvas within the frame.
47  fLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX |
48  kLHintsExpandY, 5, 5, 5, 5);
49 
50  // Careful about clashes with root's naming of canvases. Make a name
51  // like "tpcEVDCanvas" using the print tag
52  std::string name(this->PrintTag());
53  name += "evdb::Canvas";
54 
55  // Create the embedded canvas within the main ROOT graphics frame.
56  fEmbCanvas = new TRootEmbeddedCanvas(name.c_str(), mf, fXsize, fYsize,
57  kSunkenFrame, 0);
58  mf->AddFrame(fEmbCanvas, fLayout);
59  mf->AddFrame(fFrame);
60 
61  // Extract the graphical Canvas from the embedded canvas. The user
62  // will do most of their drawing in this.
63  fCanvas = fEmbCanvas->GetCanvas();
64  }
65 
66  //......................................................................
67 
69  {
70  // Make connections for drawing and printing
71  // IoModule::Instance()->Connect("NewEvent()",
72  // "evdb::Canvas",this,"Draw()");
74  }
75 
76  //......................................................................
77 
79  {
80  // IoModule::Instance()->Disconnect(0,this,0);
81  delete fEmbCanvas;
82  delete fLayout;
83  delete fFrame;
84  }
85 
86  //......................................................................
87 
88  void Canvas::Print(const char* f) { fCanvas->Print(f); }
89 
90 }// namespace
91 ////////////////////////////////////////////////////////////////////////
92 
const XML_Char * name
Definition: expat.h:151
void Connect()
Make signal/slot connections.
Definition: Canvas.cxx:68
TGCompositeFrame * fFrame
Graphics frame.
Definition: Canvas.h:39
TCanvas * fCanvas
The ROOT drawing canvas.
Definition: Canvas.h:42
TGLayoutHints * fLayout
Layout hints for frame.
Definition: Canvas.h:40
Manage all things related to colors for the event display.
Definition: Display3DPad.h:11
float fAspectRatio
fYsize/fXsize
Definition: Canvas.h:46
Base class for define a detector display.
Base class for printable objects.
virtual const char * Description() const
Definition: Canvas.h:33
unsigned short fXsize
Size of the canvas;.
Definition: Canvas.h:44
unsigned short fYsize
Size of the canvas;.
Definition: Canvas.h:45
Canvas(TGMainFrame *mf)
Definition: Canvas.cxx:33
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
virtual const char * PrintTag() const
Definition: Canvas.h:32
virtual void Print(const char *f)
Definition: Canvas.cxx:88
static void AddToListOfPrintables(const char *name, evdb::Printable *p)
Definition: Printable.cxx:29
TRootEmbeddedCanvas * fEmbCanvas
Embedded canvas.
Definition: Canvas.h:41
virtual ~Canvas()
Definition: Canvas.cxx:78