PT-Cooling-Log 1.0
PTCoolingLogViewer
src/PtMwView.cc
00001 #include "PtMwView.hh"
00002 #include "LogViewer.hh"
00003 
00004 #include <TGraph.h>
00005 #include <TGaxis.h>
00006 #include <TH1.h>
00007 
00008 PtMwView::PtMwView() : 
00009   PtView( LogViewer::tgMw ), 
00010   power_( NULL ), axis_( NULL ), yl_( 0.0 ), yh_( 0.0 )
00011 {
00012   this->title() = "Microwave";
00013   this->add( LogViewer::sqlEpoch,    "epoch",  kBlack );
00014   this->add( LogViewer::sqlTimeZone, "TZ",     kBlack );
00015   this->add( "frq", "Freq.", kBlue );
00016   this->add( "pwr", "Power", kRed );
00017   power_ = new TGraph;
00018   axis_  = new TGaxis;
00019 }
00020 
00021 PtMwView::~PtMwView(){
00022 }
00023 
00024 void PtMwView::setRange(){
00025 
00026   ymin_ = 68.0;
00027   ymax_ = 74.0;
00028   TGraph& p = (*this)[ 3 ].graph();
00029   double x, y;
00030   for( int i = 0; i < p.GetN(); i++ ){
00031     p.GetPoint( i, x, y );
00032     yl_ = ( i == 0 || yl_ > y ? y : yl_ );
00033     yh_ = ( i == 0 || yh_ < y ? y : yh_ );
00034   }
00035 
00036   if( yl_ == yh_ ) { yl_ = 0.0; yh_ = 1.0;}
00037 
00038 }
00039 
00040 void PtMwView::drawGraph(){
00041   
00042   TGraph& f = (*this)[ 2 ].graph();
00043   TGraph& p = (*this)[ 3 ].graph();
00044   
00045   power_->Set( p.GetN() );
00046   power_->SetLineWidth( p.GetLineWidth() );
00047   power_->SetLineColor( p.GetLineColor() );
00048   power_->SetLineStyle( p.GetLineStyle() );
00049   
00050   double h = ymax_ - ymin_;
00051   double x, y;
00052   double r = 0.8 * h / ( yh_ - yl_ );
00053   for( int i = 0; i < p.GetN(); i++ ){
00054     p.GetPoint( i, x, y );
00055     power_->SetPoint( i, x, r * ( y - yl_ ) + ymin_ + 0.1 * h );
00056   }
00057   
00058   f.Draw( "L" );
00059   power_->Draw( "L" );
00060 
00061   axis_->SetLineColor( p.GetLineColor() );
00062   axis_->SetTitle( "Power" );
00063   axis_->SetTitleSize( 0.8 * frame_->GetYaxis()->GetTitleSize() );
00064   axis_->SetTitleOffset( 0.5 * frame_->GetYaxis()->GetTitleOffset() );
00065   axis_->SetLabelSize( 0.8 * frame_->GetYaxis()->GetLabelSize() );
00066   
00067   x = xmax_ - 0.11 * ( xmax_ - xmin_ );
00068   
00069   axis_->DrawAxis( x, ymin_ + 0.1 * h,
00070                    x, ymax_ - 0.1 * h,
00071                    yl_, yh_,
00072                    510, "+L");
00073 }
 全て クラス ファイル 関数 変数