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