Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
#include <iostream>
using namespace std;

#include "MELeafPanel.hh"
#include "../../interface/MEGeom.h"

#include "MusEcalGUI.hh"
#include <TSystem.h>

ClassImp(MELeafPanel);

MELeafPanel::MELeafPanel( const TGWindow *p, MusEcalGUI* main,
			  UInt_t w, UInt_t h)
:  _gui( main )
{
  _type  = _gui->_type;
  _color = _gui->_color;
  _var   = _gui->_var;
  _zoom  = _gui->_zoom;

  fMain=0;
  fVframe1=0;
  fHframe1=0;
  fHframe2=0;
  fVarBox=0;
  fZoomBox=0;
  fPlotButton=0;
  fOneLevelUpButton=0;

  fDiffPlotButton=0;

  fHint1 = new TGLayoutHints( kLHintsTop | kLHintsCenterX, 5, 5, 5, 5 );
  fHint3 = new TGLayoutHints( kLHintsTop | kLHintsLeft , 3 ,3 ,3 ,3 ); // buttons in groups
  fHint2 = new TGLayoutHints( kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 3, 0);
  fHint4 = new TGLayoutHints( kLHintsTop | kLHintsLeft | kLHintsExpandX,
			      2, 2, 0, 0);
  fHint5 =  new TGLayoutHints( kLHintsCenterX, 0, 0, 0, 0 );

  fMain = new TGTransientFrame(p, main, w, h);
  fMain->Connect( "CloseWindow()", "MELeafPanel", this, "DoClose()" );
  fMain->DontCallClose();
  fMain->SetCleanup(kDeepCleanup);
  
  fMain->ChangeOptions( (fMain->GetOptions() & ~kVerticalFrame) | kHorizontalFrame );
  
  fVframe1 = new TGVerticalFrame( fMain, 0, 0, 0 );
  fHframe1 = new TGHorizontalFrame( fVframe1, 0, 0, 0 );
  fHframe2 = new TGHorizontalFrame( fVframe1, 0, 0, 0 );
  
  fVarBox = new TGListBox( fHframe1, 150, 100 );
  fVarBox->Connect( "Selected(Int_t)", "MELeafPanel", this, "SetVar(UInt_t)" );

  fZoomBox = new TGListBox( fHframe1, 150, 100 );
  fZoomBox->Connect( "Selected(Int_t)", "MELeafPanel", this, "SetZoom(UInt_t)" );
  
  if( _type==ME::iLaser )
    {
      _var =  MusEcal::iAPD;
      for( int jj=0; jj<MusEcal::iSizeLV; jj++ )
	{
	  fVarBox->AddEntry( MusEcal::historyVarName[jj], jj );
	}  
      fVarBox->Resize(150,100);
      fVarBox->Select( _var );
      fVarBox->Layout();

      _zoom = MusEcal::historyVarZoom[_color][ _var ];
      if( _zoom==MusEcal::iZero ) _zoom = MusEcal::iThirtyPercent;
      for( int iZoom=0; iZoom<MusEcal::iZero; iZoom++ )
	{
	  fZoomBox->AddEntry( MusEcal::zoomName[iZoom], iZoom );
	}
      fZoomBox->Resize(150,100);
      fZoomBox->Select( _zoom );
      fZoomBox->Layout();
    }
  else if( _type==ME::iTestPulse )
    {
      int jj_Var =  0;
      for( int jj=0; jj<MusEcal::iSizeTPV; jj++ )
	{
	  fVarBox->AddEntry( MusEcal::historyTPVarName[jj], jj );
	}  
      fVarBox->Resize(150,100);
      fVarBox->Select( jj_Var );
      fVarBox->Layout();

      int jj_Zoom = MusEcal::historyTPVarZoom[ jj_Var ];
      for( int iZoom=0; iZoom<MusEcal::iZero; iZoom++ )
	{
	  fZoomBox->AddEntry( MusEcal::zoomName[iZoom], iZoom );
	}
      fZoomBox->Resize(150,100);
      if( jj_Zoom!=MusEcal::iZero ) fZoomBox->Select( jj_Zoom );
      else fZoomBox->Select(0);
      fZoomBox->Layout();
    }

  fPlotButton = new TGTextButton( fHframe2      , "   Plot      " );
  fPlotButton->Connect("Clicked()","MELeafPanel",this,"DoPlot()");

  //  fDiffPlotButton = new TGTextButton( fHframe2      , "   Diff Plot      " );
  //  fDiffPlotButton->Connect("Clicked()","MELeafPanel",this,"DoDiffPlot()");

  fOneLevelUpButton = new TGTextButton( fHframe2, "  One Level Up  " );
  fOneLevelUpButton->Connect("Clicked()","MELeafPanel",this,"DoOneLevelUp()");

  fHframe1->AddFrame( fVarBox,  fHint3 );
  fHframe1->AddFrame( fZoomBox, fHint3 );
  fHframe1->Resize(310,110);
  fHframe1->MapSubwindows();  
  fVframe1->AddFrame( fHframe1, fHint5 );
  fHframe2->AddFrame( fPlotButton,  fHint3 );
  //  fHframe2->AddFrame( fDiffPlotButton,  fHint3 );
  fHframe2->AddFrame( fOneLevelUpButton, fHint3 );
  fHframe2->Resize(310,50);
  fHframe2->MapSubwindows();  
  fVframe1->AddFrame( fHframe2, fHint5 );
  fVframe1->MapSubwindows();  
  fMain->AddFrame( fVframe1,    fHint5 );

  TString str;
  str += ME::type[_type];
  str += "  Zoom Panel";
  fMain->SetWindowName(str);
  TGDimension size = fMain->GetDefaultSize();
  fMain->Resize(size);

  fMain->MapSubwindows();
  fMain->MapWindow();

}

MELeafPanel::~MELeafPanel()
{
  _gui->_fLeafPanel=0;
  fMain->DeleteWindow();   // deletes fMain
}

void 
MELeafPanel::CloseWindow()
{
  // Called when window is closed via the window manager.

  delete this;
}

void 
MELeafPanel::DoClose()
{
  CloseWindow();
}

void
MELeafPanel::DoPlot()
{
  // cout << "Entering DoPlot for var=" << _var << " and zoom=" << _zoom << endl;
  _gui->_var  = _var;
  _gui->_zoom = _zoom;
  _gui->leafPlot(1);
}

void
MELeafPanel::DoDiffPlot()
{
  // cout << "Plot intervals for type=" << _type << " and var=" << MusEcal::historyVarName[_var] << endl;
  // _gui->_type    = _type;
  //  _gui->setMtqVar(_var);
  //  _gui->_zoom    = _zoom;
  //  cout << "Obsolete -- fixme!!! " << endl;
  //  _gui->intervalPlot();
  //  _gui->distancePlot();
  //  _gui->correctionPlot();
}

void
MELeafPanel::DoOneLevelUp()
{
  _gui->oneLevelUp();
  DoPlot();
}

void
MELeafPanel::SetVar( int ii )
{
  _var = ii;
}

void
MELeafPanel::SetZoom( int iZoom )
{
  _zoom = iZoom;
}