LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
evdb::Canvas Class Referenceabstract

#include "Canvas.h"

Inheritance diagram for evdb::Canvas:
evdb::Printable evd::CalorView evd::Display3DView evd::Ortho3DView evd::TWQMultiTPCProjectionView evd::TWQProjectionView evdb::testCanvas1

Public Member Functions

 Canvas (TGMainFrame *mf)
 
virtual ~Canvas ()
 
virtual void Draw (const char *opt=0)=0
 
virtual const char * PrintTag () const
 
virtual const char * Description () const
 
virtual void Print (const char *f)
 
void Connect ()
 Make signal/slot connections. More...
 

Static Public Member Functions

static void AddToListOfPrintables (const char *name, evdb::Printable *p)
 
static void RemoveFromListOfPrintables (evdb::Printable *p)
 
static std::map< std::string, evdb::Printable * > & GetPrintables ()
 

Protected Attributes

TGCompositeFrame * fFrame
 Graphics frame. More...
 
TGLayoutHints * fLayout
 Layout hints for frame. More...
 
TRootEmbeddedCanvas * fEmbCanvas
 Embedded canvas. More...
 
TCanvas * fCanvas
 The ROOT drawing canvas. More...
 
unsigned short fXsize
 Size of the canvas;. More...
 
unsigned short fYsize
 Size of the canvas;. More...
 
float fAspectRatio
 fYsize/fXsize More...
 

Detailed Description

Definition at line 22 of file Canvas.h.

Constructor & Destructor Documentation

evdb::Canvas::Canvas ( TGMainFrame *  mf)

Perform the basic setup for a drawing canvas

Definition at line 33 of file Canvas.cxx.

References fAspectRatio, fCanvas, fEmbCanvas, fFrame, fLayout, fXsize, fYsize, and PrintTag().

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  }
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
float fAspectRatio
fYsize/fXsize
Definition: Canvas.h:46
unsigned short fXsize
Size of the canvas;.
Definition: Canvas.h:44
unsigned short fYsize
Size of the canvas;.
Definition: Canvas.h:45
virtual const char * PrintTag() const
Definition: Canvas.h:32
TRootEmbeddedCanvas * fEmbCanvas
Embedded canvas.
Definition: Canvas.h:41
evdb::Canvas::~Canvas ( )
virtual

Definition at line 78 of file Canvas.cxx.

References fEmbCanvas, fFrame, and fLayout.

79  {
80  // IoModule::Instance()->Disconnect(0,this,0);
81  delete fEmbCanvas;
82  delete fLayout;
83  delete fFrame;
84  }
TGCompositeFrame * fFrame
Graphics frame.
Definition: Canvas.h:39
TGLayoutHints * fLayout
Layout hints for frame.
Definition: Canvas.h:40
TRootEmbeddedCanvas * fEmbCanvas
Embedded canvas.
Definition: Canvas.h:41

Member Function Documentation

void evdb::Printable::AddToListOfPrintables ( const char *  name,
evdb::Printable p 
)
staticinherited

Definition at line 29 of file Printable.cxx.

Referenced by Connect(), evdb::ObjListCanvas::Connect(), evdb::Printable::Description(), and evdb::testCanvas1::testCanvas1().

31  {
32  std::string s(name);
33 
34  if (gsPrintables[s] == 0) {
35  gsPrintables[s] = p;
36  }
37  else {
38  if (gsPrintables[s] != p) {
39  std::cerr << "Printable: Name " << name << " reused.\n";
40  std::abort();
41  }
42  }
43  }
static std::map< std::string, evdb::Printable * > gsPrintables
Definition: Printable.cxx:14
void evdb::Canvas::Connect ( )

Make signal/slot connections.

Definition at line 68 of file Canvas.cxx.

References evdb::Printable::AddToListOfPrintables(), and Description().

Referenced by evd::CalorView::CalorView(), Description(), evd::Display3DView::Display3DView(), and evdb::DisplayWindow::DisplayWindow().

69  {
70  // Make connections for drawing and printing
71  // IoModule::Instance()->Connect("NewEvent()",
72  // "evdb::Canvas",this,"Draw()");
74  }
virtual const char * Description() const
Definition: Canvas.h:33
static void AddToListOfPrintables(const char *name, evdb::Printable *p)
Definition: Printable.cxx:29
virtual const char* evdb::Canvas::Description ( ) const
inlinevirtual

Reimplemented from evdb::Printable.

Reimplemented in evd::TWQMultiTPCProjectionView, evd::TWQProjectionView, evdb::testCanvas1, evd::CalorView, evd::Ortho3DView, and evd::Display3DView.

Definition at line 33 of file Canvas.h.

References Connect(), f, and Print().

Referenced by Connect().

33 {return "sub-class needs description"; }
virtual void evdb::Canvas::Draw ( const char *  opt = 0)
pure virtual
std::map< std::string, evdb::Printable * > & evdb::Printable::GetPrintables ( )
staticinherited

Definition at line 61 of file Printable.cxx.

References evdb::gsPrintables.

Referenced by evdb::Printable::Description(), evdb::EventDisplay::postProcessEvent(), and evdb::PrintDialog::PrintDialog().

62  {
63  return gsPrintables;
64  }
static std::map< std::string, evdb::Printable * > gsPrintables
Definition: Printable.cxx:14
void evdb::Canvas::Print ( const char *  f)
virtual

Implements evdb::Printable.

Definition at line 88 of file Canvas.cxx.

References fCanvas.

Referenced by Description().

88 { fCanvas->Print(f); }
TCanvas * fCanvas
The ROOT drawing canvas.
Definition: Canvas.h:42
TFile f
Definition: plotHisto.C:6
virtual const char* evdb::Canvas::PrintTag ( ) const
inlinevirtual

Implements evdb::Printable.

Reimplemented in evd::TWQMultiTPCProjectionView, evd::TWQProjectionView, evdb::testCanvas1, evd::CalorView, evd::Ortho3DView, and evd::Display3DView.

Definition at line 32 of file Canvas.h.

Referenced by Canvas().

32 {return "sub-class needs print tag"; }
void evdb::Printable::RemoveFromListOfPrintables ( evdb::Printable p)
staticinherited

Definition at line 47 of file Printable.cxx.

Referenced by evdb::Printable::Description(), evdb::Printable::~Printable(), and evdb::testCanvas1::~testCanvas1().

48  {
51  for (; itr!=itrEnd; ++itr) {
52  if ( itr->second == p) {
53  gsPrintables.erase(itr);
54  return;
55  }
56  }
57  }
intermediate_table::iterator iterator
static std::map< std::string, evdb::Printable * > gsPrintables
Definition: Printable.cxx:14

Member Data Documentation

float evdb::Canvas::fAspectRatio
protected

fYsize/fXsize

Definition at line 46 of file Canvas.h.

Referenced by Canvas().

TRootEmbeddedCanvas* evdb::Canvas::fEmbCanvas
protected
TGCompositeFrame* evdb::Canvas::fFrame
protected
TGLayoutHints* evdb::Canvas::fLayout
protected
unsigned short evdb::Canvas::fXsize
protected
unsigned short evdb::Canvas::fYsize
protected

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