Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Canvas.cxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 #include "EventDisplayBase/Canvas.h"
00014 #include "EventDisplayBase/IoModule.h"
00015 
00016 #include "TCanvas.h"
00017 #include "TGFrame.h"
00018 #include "TGLayout.h"
00019 #include "TRootEmbeddedCanvas.h"
00020 
00021 #include <iostream>
00022 #include <string>
00023 
00024 using namespace evdb;
00025 
00026 //......................................................................
00027 
00031 Canvas::Canvas(TGMainFrame* mf) 
00032 {
00033   TGDimension sz;     // Size of the main frame
00034   
00035   sz           = mf->GetSize();
00036   fXsize       = sz.fWidth  - 10; // Leave small margin on left and right 
00037   fYsize       = sz.fHeight - 58; // Leave small margin on top and bottom
00038   fAspectRatio = (float)fYsize/(float)fXsize;
00039   
00040   // This frame is apparently for holding the buttons on the top; it's
00041   // not used for anything else.
00042   fFrame  = new TGCompositeFrame(mf, 60, 60, kHorizontalFrame); 
00043 
00044   // Define a layout for placing the canvas within the frame.
00045   fLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX |
00046                               kLHintsExpandY, 5, 5, 5, 5);
00047   
00048   // Careful about clashes with root's naming of canvases. Make a name
00049   // like "tpcEVDCanvas" using the print tag
00050   std::string name(this->PrintTag());
00051   name += "evdb::Canvas";
00052 
00053   // Create the embedded canvas within the main ROOT graphics frame.
00054   fEmbCanvas = new TRootEmbeddedCanvas(name.c_str(), mf, fXsize, fYsize,
00055                                        kSunkenFrame, 0);
00056   mf->AddFrame(fEmbCanvas, fLayout);
00057   mf->AddFrame(fFrame);
00058   
00059   // Extract the graphical Canvas from the embedded canvas.  The user
00060   // will do most of their drawing in this.
00061   fCanvas = fEmbCanvas->GetCanvas();
00062 }
00063 
00064 //......................................................................
00065 
00066 void Canvas::Connect() 
00067 {
00068   // Make connections for drawing and printing
00069   IoModule::Instance()->Connect("NewEvent()",
00070                                 "evdb::Canvas",this,"Draw()");
00071   Printable::AddToListOfPrintables(this->Description(),this);
00072 }
00073 
00074 //......................................................................
00075 
00076 Canvas::~Canvas() 
00077 {
00078   IoModule::Instance()->Disconnect(0,this,0);
00079   delete fEmbCanvas;
00080   delete fLayout;    
00081   delete fFrame;
00082 }
00083 
00084 //......................................................................
00085 
00086 void Canvas::Print(const char* f) { fCanvas->Print(f); }
00087 
00089 

Generated on Mon Nov 23 04:45:24 2009 for NOvA Offline by  doxygen 1.3.9.1