/* * OverviewMainFrame.cpp * * Created on: Apr 20, 2015 * Author: Hovanes Egiyan */ #include "OverviewMainFrame.hh" ClassImp(OverviewMainFrame) // Main constructor OverviewMainFrame::OverviewMainFrame(const TGWindow *pWindow, const char* name, UInt_t width, UInt_t height, map plotMap, int nPlots ) : LogableMainFrame( pWindow,width,height ), omfNumberOfPlots(nPlots), omfPlotMap(plotMap) { this->MakeMenuBar(); // Create the frames for overviews this->MakePlotFrames(); cout << "Requested OverviewMainFrame called " << name << endl; // Sets window name and shows the main frame SetWindowName( name ); SetName(name); cout << "Set name for the OverviewMainFrame to " << this->GetName() << endl; cout << "Set window name for the OverviewMainFrame to " << this->GetWindowName() << endl; cout << "Request was for name " << name << endl; MapSubwindows(); this->SetMinHeight( height ); Resize(GetDefaultSize()); // Resize( width, height ); MapWindow(); return; } OverviewMainFrame::~OverviewMainFrame() { cout << "OverviewMainFrame::~OverviewMainFrame() is called" << endl; // // Delete daughter overview frames // for( unsigned iFrameX = 0; iFrameX < omfFrameVector.size(); iFrameX++ ) { // for( unsigned iFrameY = 0; iFrameY < omfFrameVector[iFrameX].size(); iFrameY++ ) { // if( omfFrameVector[iFrameX][iFrameY] != 0 ) delete omfFrameVector[iFrameX][iFrameY]; // } // } this->Cleanup(); // // Remove itself from the map of pointers // cout << "Size of the map before erasing is " << omfMainFrameMap.size() << endl; // if( omfMainFrameMap.count( this->GetWindowName() ) > 0 ) { // cout << "Erasing frame with name " << this->GetWindowName() << endl; // omfMainFrameMap.erase(this->GetWindowName()); // } // cout << "Size of the map after erasing is " << omfMainFrameMap.size() << endl; return; } // Calculate the number of frames in x and y direction such that // the frame is close to being square in units of plots in each direction. void OverviewMainFrame::MakePlotFrames() { TGHorizontalFrame* plotFrame = new TGHorizontalFrame(this, fWidth, fHeight ); omfNumberOfPlotsX = 1; omfNumberOfPlotsY = omfNumberOfPlots; double sqrtNplots = sqrt( omfNumberOfPlots ); for( int iDiff = 0; iDiff < sqrtNplots; iDiff++ ) { int testX = floor(sqrtNplots - iDiff); int remainderY = omfNumberOfPlots % testX; if( remainderY == 0 ) { omfNumberOfPlotsX = testX; omfNumberOfPlotsY = omfNumberOfPlots / omfNumberOfPlotsX; break; } } cout << "Will draw " << omfNumberOfPlotsX << " columns and " << omfNumberOfPlotsY << " rows " << endl; for( int iFrameX = 0; iFrameX < omfNumberOfPlotsX; iFrameX++ ) { TGVerticalFrame* xFrame = new TGVerticalFrame(plotFrame, fWidth/omfNumberOfPlotsX, fHeight ); // xFrame->SetBackgroundColor(0x00FF00); vector frameColumn; for( int iFrameY = 0; iFrameY < omfNumberOfPlotsY; iFrameY++ ) { unsigned iDet = iFrameX * omfNumberOfPlotsY + iFrameY + 1; OverviewFrame* yFrame = new OverviewFrame( omfPlotMap[iDet], xFrame, fWidth/omfNumberOfPlotsX, fHeight/omfNumberOfPlotsY ); yFrame->SetBackgroundColor(0x334455); xFrame->AddFrame(yFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5)); frameColumn.push_back( yFrame ); } plotFrame->AddFrame(xFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5)); omfFrameVector.push_back( frameColumn ); } // Draw plots in the frames for( unsigned iFrameX = 0; iFrameX < omfFrameVector.size(); iFrameX++ ) { for( unsigned iFrameY = 0; iFrameY < omfFrameVector[iFrameX].size(); iFrameY++ ) { omfFrameVector[iFrameX][iFrameY]->DrawPlot(); } } plotFrame->Resize( fWidth, fHeight ); this->AddFrame(plotFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY | kLHintsBottom, 5, 5, 5, 5)); }