メインページ   モジュール   名前空間一覧   クラス階層   アルファベット順一覧   構成   ファイル一覧   構成メンバ   ファイルメンバ   関連ページ    

TRecordDisplay.cc

解説を見る。
00001 // ============================================================================
00002 //  $Id: TRecordDisplay.cc,v 1.3 2004/06/24 15:15:24 goiwai Exp $
00003 //  $Name: CLDAQ-1-14-03 $
00004 //  $Log: TRecordDisplay.cc,v $
00005 //  Revision 1.3  2004/06/24 15:15:24  goiwai
00006 //  たくさんの変更
00007 //  Tcout,Tcerr,Tlogをバッファ経由にした。
00008 //  何個かexternした。Tlog,Tcout,Tcerr,Tinfo...Tcritなど出力関係。
00009 //
00010 //  Revision 1.2  2004/03/07 10:30:27  goiwai
00011 //  ROOTに組みこむためのおまじないマクロを埋めこみました。
00012 //  全てにおいて完全に動作するわけではありません。
00013 //
00014 //  Revision 1.1  2004/03/01 02:36:25  goiwai
00015 //  RecordDisplay用のクラス群を置きました.
00016 //  お蔵入りになってたものに手直しを加えたものですが,
00017 //  まだ不充分な点も在ります.徐々に修正していきたいと思います.
00018 //  DataRecordオブジェクトを表示するためのツール群なのでRecordDisplayと呼
00019 //  んでいます,多分にオフライン要素が強いです.
00020 //  オンラインよりにしたものを後でEventDisplay(Eventを表示)としてコミット
00021 //  します.
00022 //
00023 // ============================================================================
00024 #ifdef __CLDAQ_ROOT_USE
00025 #include <TGFrame.h>
00026 #include <TH1.h>
00027 #include <TError.h>
00028 #include <TDirectory.h>
00029 #include <TBrowser.h>
00030 #include "TRecordDisplay.hh"
00031 #include "TRecordDisplayTab.hh"
00032 #include "TRecordDisplayMenuBar.hh"
00033 #include "TRecordDisplayCanvas.hh"
00034 #include "TInputObjectStream.hh"
00035 #include "TInputObjectFile.hh"
00036 #include "TRecordDisplayPreference.hh"
00037 #include "TRecordAssociationTable.hh"
00038 #include "TRecordAssociationList.hh"
00039 #include "TDataRecord.hh"
00040 #include "TDataSection.hh"
00041 #include "TDataSegment.hh"
00042 #include "TDataElement.hh"
00043 #include "Trootinit.h"
00044 
00045 TApplication* TRecordDisplay::theApplication = rootinit( "Default", "CLDAQ RECORD DISPLAY" );
00046 
00047 enum { RECORD, SECTION, SEGMENT, ELEMENT, NTAGS };
00048 static const Tint _width = 680;
00049 static const Tint _height = 580;
00050 static const Tint _digits = 3;
00051 static TFile* _file = 0;
00052 static const Tstring _hist = "hist";
00053 static const Tstring _cv = "cv";
00054 static const Tstring _wname = "CLDAQ Record Display";
00055 
00056 TRecordDisplay::TRecordDisplay()
00057   : TRecordDisplayComponent( this ), 
00058     TGMainFrame( gClient->GetRoot(), _width, _height ),
00059     thePreference( 0 ),
00060     theAssociationTable( 0 ),
00061     theNumberOfRecords( 0 ),
00062     theAutoBuild( Ttrue ),
00063     theTab( 0 ),
00064     theMenu( 0 )
00065 {
00066   SetWindowName( _wname.c_str() );
00067 
00068   thePreference = new TRecordDisplayPreference();
00069   theAssociationTable = new TRecordAssociationTable();
00070 
00071   Associate();
00072 
00073   BuildMenuBar();
00074   BuildTabFrame();
00075 
00076   Update();
00077 }
00078 
00079 TRecordDisplay::TRecordDisplay( const Tstring& filename, TRecordAssociationTable* as )
00080   : TRecordDisplayComponent( this ), 
00081     TGMainFrame( gClient->GetRoot(), _width, _height ),
00082     thePreference( 0 ),
00083     theAssociationTable( as ),
00084     theNumberOfRecords( 0 ),
00085     theAutoBuild( Tfalse ),
00086     theTab( 0 ),
00087     theMenu( 0 )
00088 {
00089   if ( !isexist( filename ) ) {
00090     Tcout << filename << ": No such a file." << Tendl;
00091     exit( EXIT_SUCCESS );
00092   }
00093 
00094   Tstring wname = _wname + " [" + filename + "]";
00095   SetWindowName( wname.c_str() );
00096 
00097   thePreference = 
00098     new TRecordDisplayPreference( new TInputObjectFile( filename ) );
00099   
00100   if ( !theAssociationTable ) {
00101     theAssociationTable = new TRecordAssociationTable();
00102     theAutoBuild = Ttrue;
00103   } else if ( theAssociationTable -> Empty() ) {
00104     theAutoBuild = Ttrue;
00105   }
00106 
00107   Associate();
00108 
00109   BuildMenuBar();
00110   BuildTabFrame();
00111 
00112   Update();
00113 }
00114 
00115 TRecordDisplay::TRecordDisplay( TRecordDisplayPreference* pre, const Tstring& filename, TRecordAssociationTable* as )
00116   : TRecordDisplayComponent( this ), 
00117     TGMainFrame( gClient->GetRoot(), _width, _height ),
00118     thePreference( pre ),
00119     theAssociationTable( as ),
00120     theNumberOfRecords( 0 ),
00121     theAutoBuild( Tfalse ),
00122     theTab( 0 ),
00123     theMenu( 0 )
00124 {
00125   if ( !isexist( filename ) ) {
00126     Tcout << filename << ": No such a file." << Tendl;
00127     exit( EXIT_SUCCESS );
00128   }
00129   thePreference -> SetStream( new TInputObjectFile( filename ) );
00130 
00131   Tstring wname = _wname + " [" + filename + "]";
00132   SetWindowName( wname.c_str() );
00133 
00134   if ( !theAssociationTable ) {
00135     theAssociationTable = new TRecordAssociationTable();
00136     theAutoBuild = Ttrue;
00137   } else if ( theAssociationTable -> Empty() ) {
00138     theAutoBuild = Ttrue;
00139   }
00140 
00141   Associate();
00142 
00143   BuildMenuBar();
00144   BuildTabFrame();
00145 
00146   Update();
00147 }
00148 
00149 TRecordDisplay::TRecordDisplay( TRecordDisplayPreference* pre, TRecordAssociationTable* as )
00150   : TRecordDisplayComponent( this ), 
00151     TGMainFrame( gClient->GetRoot(), _width, _height ),
00152     thePreference( pre ),
00153     theAssociationTable( as ),
00154     theNumberOfRecords( 0 ),
00155     theAutoBuild( Tfalse ),
00156     theTab( 0 ),
00157     theMenu( 0 )
00158 {
00159   SetWindowName( _wname.c_str() );
00160 
00161   if ( !theAssociationTable ) {
00162     theAssociationTable = new TRecordAssociationTable();
00163     theAutoBuild = Ttrue;
00164   } else if ( theAssociationTable -> Empty() ) {
00165     theAutoBuild = Ttrue;
00166   }
00167 
00168   Associate();
00169 
00170   BuildMenuBar();
00171   BuildTabFrame();
00172 
00173   Update();
00174 }
00175 
00176 TRecordDisplay::~TRecordDisplay()
00177 {
00178   delete thePreference;
00179   delete theAssociationTable;
00180   delete theMenu;
00181   delete theTab;
00182 }
00183 
00184 Tvoid TRecordDisplay::Associate()
00185 {
00186   if ( theAutoBuild ) {
00187     return;
00188   }
00189 
00190   // ヒストグラムだけ作る
00191   TRecordAssociationList& alist = theAssociationTable -> GetAssociationList();
00192   for ( Tsize_t i = 0; i < alist.size(); i ++ ) {
00193     Tint nbin = alist[i].GetNumberOfBins();
00194     Tdouble xmin = alist[i].GetMinimumX();
00195     Tdouble xmax = alist[i].GetMaximumX();
00196     Tstring hname = GetHistogramName( i );
00197     Tstring htitle = alist[i].GetElementID();
00198     TH1D* histo =
00199       new TH1D( hname.c_str(), htitle.c_str(), nbin, xmin, xmax );
00200     alist[i].SetHistogram( histo );
00201   }
00202 
00203   return;
00204 }
00205 
00206 Tvoid TRecordDisplay::BuildMenuBar()
00207 {
00208   theMenu = new TRecordDisplayMenuBar( this );
00209   return;
00210 }
00211 
00212 Tvoid TRecordDisplay::BuildTabFrame()
00213 {
00214   theTab = new TRecordDisplayTab( this );
00215 
00216   if ( theAutoBuild ) {
00217     return;
00218   }
00219 
00220   static const Tint taglen = NTAGS;
00221   TRecordAssociationList& alist = 
00222     theAssociationTable -> GetAssociationList();
00223   for ( Tsize_t i = 0; i < alist.size(); i ++ ) {
00224     Tstring tags[ taglen ] = {
00225       alist[i].GetRecordID(),
00226       alist[i].GetSectionID(),
00227       alist[i].GetSegmentID(),
00228       alist[i].GetElementID()
00229     };
00230     TGCompositeFrame* aframe = GetFrame( tags );
00231     Tstring cvname = GetCanvasName( i );
00232     TRecordDisplayCanvas* cv =
00233       new TRecordDisplayCanvas( this, aframe, cvname, _width, _height );
00234     alist[i].SetCanvas( cv );
00235     cv -> GetCanvas() -> cd();
00236     alist[i].GetHistogram() -> Draw();
00237   }
00238 
00239   return;
00240 }
00241 
00242 Tvoid TRecordDisplay::Build()
00243 {
00244   TInputObjectStream* stream = thePreference -> GetStream();
00245   TDataRecord recbuf;
00246   TDataElement elebuf;
00247   Tstring endid = thePreference -> GetEndOfRecordID();
00248   Tint update = thePreference -> GetUpdateCycle();
00249   const TRecordAssociationList& alist = 
00250     theAssociationTable -> GetAssociationList();
00251 
00252   static const Tint taglen = NTAGS;
00253   while ( stream -> Read( recbuf ) ) {
00254     theNumberOfRecords ++;
00255 
00256     if ( ! endid.empty() && recbuf.GetID() == endid ) {
00257       break;
00258     }
00259 
00260 
00261     for ( Tsize_t i = 0; i < alist.size(); i ++ ) {
00262       Tstring tags[ taglen ] = {
00263         alist[i].GetRecordID(),
00264         alist[i].GetSectionID(),
00265         alist[i].GetSegmentID(),
00266         alist[i].GetElementID()
00267       };
00268 
00269       if ( recbuf == tags[RECORD] && recbuf.FindDataElement(tags[SECTION],tags[SEGMENT],tags[ELEMENT],elebuf) ) {
00270         Tint ndata = elebuf.GetNumberOfPrimitives();
00271 
00272         if ( ndata == 1 ) {
00273           Tdouble databuf;
00274           elebuf.StorePrimitive( databuf );
00275           alist[i].GetHistogram() -> Fill( databuf );
00276         } else {
00277           Tdouble* databuf = new Tdouble[ndata];
00278           elebuf.StorePrimitives( databuf );
00279           for ( Tint j = 0; j < ndata; j ++ ) {
00280             alist[i].GetHistogram() -> Fill( databuf[j] );
00281           }
00282           delete [] databuf;
00283         }
00284       }
00285     }
00286 
00287     if ( update > 0 && theNumberOfRecords % update == 0 ) {
00288       Update();
00289     }
00290 
00291     gSystem -> ProcessEvents();
00292   }
00293 
00294   return;
00295 }
00296 
00297 Tvoid TRecordDisplay::AutoBuild()
00298 {
00299   TInputObjectStream* stream = thePreference -> GetStream();
00300   TDataRecord recbuf;
00301   Tstring endid = thePreference -> GetEndOfRecordID();
00302   Tint update = thePreference -> GetUpdateCycle();
00303 
00304   static const Tint taglen = NTAGS;
00305   Tstring tag[taglen];
00306   while ( stream -> Read( recbuf ) ) {
00307     theNumberOfRecords ++;
00308 
00309     tag[RECORD] = recbuf.GetID();
00310     if ( ! endid.empty() && tag[RECORD] == endid ) {
00311       break;
00312     }
00313     for ( Tint secid = 0; secid < recbuf.Size(); secid ++ ) {
00314       tag[SECTION] = recbuf[secid].GetID();
00315       for ( Tint segid = 0; segid < recbuf[secid].Size(); segid ++ ) {
00316         tag[SEGMENT] = recbuf[secid][segid].GetID();
00317         for ( Tint eleid = 0; eleid < recbuf[secid][segid].Size(); eleid ++ ) {
00318           tag[ELEMENT] = recbuf[secid][segid][eleid].GetID();
00319           if ( recbuf[secid][segid][eleid].GetElementType() == tTypeString ) {
00320             Tint ndata = recbuf[secid][segid][eleid].GetNumberOfPrimitives();
00321             TDataElement& e = recbuf[secid][segid][eleid];
00322             Tstring databuf;
00323             e.StorePrimitive( databuf );
00324             Tcout << "#" << itostr(theNumberOfRecords) << ":"
00325                   << "[" << tag[RECORD] << "]"
00326                   << "[" << tag[SECTION] << "]"
00327                   << "[" << tag[SEGMENT] << "]"
00328                   << "[" << tag[ELEMENT] << "]"
00329                   << " >>> \"" << databuf << "\"";
00330             if ( ndata == 1 ) {
00331               Tcout << Tendl;
00332             } else {
00333               Tcout << ", ...(omitted " << ndata-1 << " messages)" << Tendl;
00334             }
00335             continue;
00336           }
00337 
00338           if ( ! theAssociationTable -> HasAssociation( tag ) ) {
00339             Tint nbin = thePreference -> GetDefaultNumberOfBins();
00340             Tdouble xmin = thePreference -> GetDefaultMinimumX();
00341             Tdouble xmax = thePreference -> GetDefaultMaximumX();
00342             Tint nas = theAssociationTable -> Size();
00343             Tstring hname = GetHistogramName( nas );
00344             Tstring htitle = tag[ELEMENT];
00345 
00346 
00347             TGCompositeFrame* aframe = GetFrame( tag );
00348 
00349             Tstring cvname = GetCanvasName( nas );
00350             TRecordDisplayCanvas* cv =
00351               new TRecordDisplayCanvas( this, aframe, cvname, _width, _height );
00352 
00353             TH1D* histo =
00354               new TH1D( hname.c_str(), htitle.c_str(), nbin, xmin, xmax );
00355             histo->Draw();
00356 
00357             theAssociationTable
00358               -> AddAssociation( TRecordAssociation( tag[RECORD],
00359                                                      tag[SECTION],
00360                                                      tag[SEGMENT],
00361                                                      tag[ELEMENT],
00362                                                      nbin, xmin, xmax,
00363                                                      cv,
00364                                                      histo
00365                                                      ) );
00366           } else {
00367 
00368             // すでに関連づけられているけど,CanvasとかHISTOなきゃ作ってやる
00369             TRecordDisplayCanvas* cv = theAssociationTable -> GetCanvas( tag );
00370             if ( cv == 0 ) {
00371               Tint nas = theAssociationTable -> Size();
00372               Tstring cvname = GetCanvasName( nas );
00373               TGCompositeFrame* aframe = GetFrame( tag );              
00374               cv = new TRecordDisplayCanvas(this,aframe,cvname,_width,_height);
00375               theAssociationTable -> SetCanvas( tag, cv );
00376             }
00377 
00378             TH1D* histo = theAssociationTable -> GetHistogram( tag );
00379             if ( histo == 0 ) {
00380               // このときはAssociationからひろってくる
00381               Tint nbin = theAssociationTable -> GetNumberOfBins( tag );
00382               Tdouble xmin = theAssociationTable -> GetMinimumX( tag );
00383               Tdouble xmax = theAssociationTable -> GetMaximumX( tag );
00384               Tint nas = theAssociationTable -> Size();
00385               Tstring hname = GetHistogramName( nas );
00386               Tstring htitle = tag[ELEMENT];
00387               TH1D* histo =
00388                 new TH1D( hname.c_str(), htitle.c_str(), nbin, xmin, xmax );
00389               cv -> GetCanvas() -> cd();
00390               histo->Draw();
00391               theAssociationTable -> SetHistogram( tag, histo );
00392             }
00393 
00394           }
00395 
00396           TH1D* histo = theAssociationTable -> GetHistogram( tag );
00397           if ( ! histo ) {
00398             Tcout << "#" << itostr(theNumberOfRecords) << ":"
00399                   << "[" << tag[RECORD] << "]"
00400                   << "[" << tag[SECTION] << "]"
00401                   << "[" << tag[SEGMENT] << "]"
00402                   << "[" << tag[ELEMENT] << "]"
00403                   << " no histogram." << Tendl;
00404             continue;
00405           }
00406 
00407           Tint ndata = recbuf[secid][segid][eleid].GetNumberOfPrimitives();
00408           if ( ndata == 1 ) {
00409             Tdouble databuf;
00410             recbuf[secid][segid][eleid].StorePrimitive( databuf );
00411             histo -> Fill( databuf );
00412           } else {
00413             Tdouble* databuf = new Tdouble[ndata];
00414             recbuf[secid][segid][eleid].StorePrimitives( databuf );
00415             for ( Tint i = 0; i < ndata; i ++ ) {
00416               histo -> Fill( databuf[i] );
00417             }
00418             delete [] databuf;
00419           }
00420 
00421 
00422           if ( update > 0 && theNumberOfRecords % update == 0 ) {
00423             Update();
00424           }
00425 
00426           gSystem -> ProcessEvents();
00427         }
00428       }
00429     }
00430   }
00431 
00432   return;
00433 }
00434 
00435 TGCompositeFrame* TRecordDisplay::GetFrame( Tstring* tags )
00436 {
00437   static const Tint taglen = NTAGS;
00438   TGCompositeFrame* aframe = 0;
00439   TRecordDisplayTab* atab = theTab;
00440   for ( Tint i = 0; i < taglen; i ++ ) {
00441     aframe = atab -> GetFrame( tags[i] );
00442     if ( i != 3 ) {
00443       atab = atab->GetTab( aframe );
00444     }
00445   }
00446   return aframe;
00447 }
00448 
00449 TDirectory* TRecordDisplay::GetDirectory( Tstring* tags )
00450 {
00451   static const Tint taglen = NTAGS;
00452   static const Tint tmpLV = 3000;
00453 
00454   // エラーがうざいので
00455   Tint tmp = gErrorIgnoreLevel;
00456   gErrorIgnoreLevel = tmpLV;
00457 
00458   _file -> cd();
00459   TDirectory* d = gDirectory;
00460 
00461   Tstring path;
00462   for ( int i =0; i < taglen; i ++ ) {
00463     if ( ! path.empty() ) {
00464       path += "/";
00465     }
00466     path += tags[i];
00467     if ( _file -> cd( path.c_str() ) ) {
00468       d = gDirectory;
00469     } else {
00470       d = d -> mkdir( tags[i].c_str() );
00471     }
00472   }
00473 
00474   gErrorIgnoreLevel = tmp;
00475 
00476   return d;
00477 }
00478 
00479 
00480 Tstring TRecordDisplay::GetHistogramName( Tint id ) const
00481 {
00482   Tstring retval = _hist + itostr(id,_digits);
00483   return retval;
00484 }
00485 
00486 Tstring TRecordDisplay::GetCanvasName( Tint id ) const
00487 {
00488   Tstring retval = _cv + itostr(id,_digits);
00489   return retval;
00490 }
00491 
00492 Tvoid TRecordDisplay::Open()
00493 {
00494   Tcout << "TODO: Open(): under construction." << Tendl;
00495   return;
00496 }
00497 
00498 Tvoid TRecordDisplay::Browse()
00499 {
00500   new TBrowser( "Browser", "CLDAQ Record Display", _width, _height );
00501   return;
00502 }
00503 
00504 Tvoid TRecordDisplay::Save()
00505 {
00506   static const Tint taglen = NTAGS;
00507   if ( thePreference -> SaveRootAtLast() ) {
00508     Tstring rootfile = thePreference -> RootFile();
00509     _file = new TFile( rootfile.c_str(), "recreate" );
00510     const TRecordAssociationList& list = 
00511       theAssociationTable -> GetAssociationList();
00512     for ( Tsize_t i = 0; i < list.size(); i ++ ) {
00513       Tstring tags[ taglen ] = {
00514         list[i].GetRecordID(),
00515         list[i].GetSectionID(),
00516         list[i].GetSegmentID(),
00517         list[i].GetElementID()
00518       };
00519       GetDirectory( tags ) -> cd();
00520       TH1D* histo = list[i].GetHistogram();
00521       if ( histo ) {
00522         histo -> Write();
00523       }
00524     }
00525     _file -> Close();
00526     delete _file;
00527     _file = 0;
00528   }
00529 
00530   if ( thePreference -> SavePsAtLast() ) {
00531     const TRecordAssociationList& list = 
00532       theAssociationTable -> GetAssociationList();
00533     for ( Tsize_t i = 0; i < list.size(); i ++ ) {
00534       TCanvas* cv = list[i].GetCanvas()->GetCanvas();
00535       if ( cv ) {
00536         cv -> Print();
00537       }
00538     }
00539   }
00540 
00541   if ( thePreference -> SaveGifAtLast() ) {
00542     const TRecordAssociationList& list = 
00543       theAssociationTable -> GetAssociationList();
00544     for ( Tsize_t i = 0; i < list.size(); i ++ ) {
00545       TCanvas* cv = list[i].GetCanvas()->GetCanvas();
00546       if ( cv ) {
00547         Tstring gif = cv -> GetName();
00548         gif += ".gif";
00549         cv -> Print( gif.c_str() );
00550       }
00551     }
00552   }
00553 
00554   return;
00555 }
00556 
00557 Tvoid TRecordDisplay::SaveAs()
00558 {
00559   Tcout << "TODO: SaveAs(): under construction." << Tendl;
00560   return;
00561 }
00562 
00563 Tvoid TRecordDisplay::Print()
00564 {
00565   const TRecordAssociationList& list = 
00566     theAssociationTable -> GetAssociationList();
00567   for ( Tsize_t i = 0; i < list.size(); i ++ ) {
00568     TCanvas* cv = list[i].GetCanvas()->GetCanvas();
00569     if ( cv ) {
00570       cv -> Print();
00571     }
00572   }
00573 
00574   for ( Tsize_t i = 0; i < list.size(); i ++ ) {
00575     TCanvas* cv = list[i].GetCanvas()->GetCanvas();
00576     if ( cv ) {
00577       Tstring gif = cv -> GetName();
00578       gif += ".gif";
00579       cv -> Print( gif.c_str() );
00580     }
00581   }
00582 
00583   return;
00584 }
00585 
00586 Tvoid TRecordDisplay::PrintAs()
00587 {
00588   Tcout << "TODO: PrintAs(): under construction." << Tendl;
00589   return;
00590 }
00591 
00592 Tvoid TRecordDisplay::Quit()
00593 {
00594   theApplication -> Terminate( 0 );
00595 }
00596 
00597 Tvoid TRecordDisplay::Start()
00598 {
00599   if ( IsAutoBuild() ) {
00600     Tbool modified = Tfalse;
00601     if ( thePreference -> GetUpdateCycle() == 1 ) {
00602       // auto build で update cycle がデフォルトなら
00603       // オフラインな利用が多いと思う
00604       thePreference -> SetUpdateCycle( 0 );
00605       modified = Ttrue;
00606     }
00607     AutoBuild();
00608     if ( modified ) {
00609       // こっそり元にもどしておこう
00610       thePreference -> SetUpdateCycle( 1 );
00611     }
00612   } else {
00613     Build();
00614   }
00615 
00616   Update();
00617   Save();
00618 
00619   if ( thePreference -> TerminateAtLast() ) {
00620     Quit();
00621   }
00622 
00623   theApplication -> Run();
00624 
00625   return;
00626 }
00627 
00628 Tvoid TRecordDisplay::Start( const Tstring& filename )
00629 {
00630   if ( !isexist( filename ) ) {
00631     Tcout << filename << ": No such a file." << Tendl;
00632     return;
00633   }
00634 
00635   Tstring wname = _wname + " [" + filename + "]";
00636   SetWindowName( wname.c_str() );
00637 
00638   thePreference -> SetStream( new TInputObjectFile( filename ) );
00639   Start();
00640   return;
00641 }
00642 
00643 Tvoid TRecordDisplay::Pause()
00644 {
00645   Tcout << "TODO: Pause(): under construction." << Tendl;
00646   return;
00647 }
00648 
00649 Tvoid TRecordDisplay::Update()
00650 {
00651   MapSubwindows();
00652   Layout();
00653   MapWindow();
00654 
00655   const TRecordAssociationList& list = 
00656     theAssociationTable -> GetAssociationList();
00657   for ( Tsize_t i = 0; i < list.size(); i ++ ) {
00658     TCanvas* cv = list[i].GetCanvas() -> GetCanvas();
00659     if ( cv ) {
00660       cv -> Modified();
00661       cv -> Update();
00662     }
00663   }
00664 
00665   return;
00666 }
00667 
00668 Tvoid TRecordDisplay::Stop()
00669 {
00670   Tcout << "TODO: Stop(): under construction." << Tendl;
00671   return;
00672 }
00673 
00674 Tvoid TRecordDisplay::Edit()
00675 {
00676   Tcout << "TODO: Edit(): under construction." << Tendl;
00677   return;
00678 }
00679 
00680 Tvoid TRecordDisplay::Undo()
00681 {
00682   Tcout << "TODO: Undo(): under construction." << Tendl;
00683   return;
00684 }
00685 
00686 Tvoid TRecordDisplay::Clear()
00687 {
00688   // キャンバスだけ真っ白にする オブジェクトはのこる
00689   // ヒストグラムの内容もクリアする オブジェクトと軸情報はのこる
00690   const TRecordAssociationList& list = 
00691     theAssociationTable -> GetAssociationList();
00692   for ( Tsize_t i = 0; i < list.size(); i ++ ) {
00693     TCanvas* cv = list[i].GetCanvas()->GetCanvas();
00694     TH1D* histo = list[i].GetHistogram();
00695     if ( cv ) {
00696       cv -> Clear();
00697     }
00698     if ( histo ) {
00699       histo -> Reset();
00700     }
00701   }
00702 
00703   return;
00704 }
00705 
00706 Tvoid TRecordDisplay::Initialize()
00707 {
00708   // メニューバーのこして全て消す
00709   // キャンバスとかも全部消す方向で
00710   // TODO: まだうまく動かない
00711   TRecordAssociationList& alist = 
00712     theAssociationTable -> GetAssociationList();
00713   for ( Tsize_t i = 0; i < alist.size(); i ++ ) {
00714     TCanvas* cv = alist[i].GetCanvas()->GetCanvas();
00715     TH1D* histo = alist[i].GetHistogram();
00716     if ( cv ) {
00717       delete cv;
00718       alist[i].SetCanvas( 0 );
00719     }
00720     if ( histo ) {
00721       delete histo;
00722       alist[i].SetHistogram( 0 );
00723     }
00724   }
00725 
00726   Update();
00727   return;
00728 }
00729 
00730 Tvoid TRecordDisplay::Preferences()
00731 {
00732   Tcout << "TODO: Preferences(): under construction." << Tendl;
00733   return;
00734 }
00735 
00736 Tbool TRecordDisplay::ProcessMessage( Tlong msg, Tlong id, Tlong arg )
00737 {
00738   if ( GET_SUBMSG( msg ) == kCM_MENU ) {
00739     switch ( id ) {
00740       case MENU_FILE_OPEN:
00741         Open();
00742         break;
00743       case MENU_FILE_BROWSE:
00744         Browse();
00745         break;
00746       case MENU_FILE_SAVE:
00747         Save();
00748         break;
00749       case MENU_FILE_SAVEAS:
00750         SaveAs();
00751         break;
00752       case MENU_FILE_PRINT:
00753         Print();
00754         break;
00755       case MENU_FILE_PRINTAS:
00756         PrintAs();
00757         break;
00758       case MENU_FILE_QUIT:
00759         Quit();
00760         break;
00761 
00762       case MENU_CTRL_START:
00763         Start();
00764         break;
00765       case MENU_CTRL_PAUSE:
00766         Pause();
00767         break;
00768       case MENU_CTRL_UPDATE:
00769         Update();
00770         break;
00771       case MENU_CTRL_STOP:
00772         Stop();
00773         break;
00774 
00775       case MENU_EDIT_EDIT:
00776         Edit();
00777         break;
00778       case MENU_EDIT_UNDO:
00779         Undo();
00780         break;
00781       case MENU_EDIT_CLEAR:
00782         Clear();
00783         break;
00784       case MENU_EDIT_INITIALIZE:
00785         Initialize();
00786         break;
00787       case MENU_EDIT_PREFERENCES:
00788         Preferences();
00789         break;
00790 
00791       case MENU_VIEW_FULL_SCREEN:
00792       case MENU_VIEW_ICONIFY:
00793       case MENU_VIEW_COLOR_LIST:
00794       case MENU_VIEW_FONT_LIST:
00795       case MENU_VIEW_MARKER_LIST:
00796       case MENU_VIEW_X3D:
00797       case MENU_VIEW_OPEN_GL:
00798         Tcout << "TODO: View Directory: under construction..." << Tendl;
00799         break;
00800     }
00801   }
00802   return Ttrue;
00803 }
00804 
00805 #endif
00806 
00807 #ifdef __CLDAQ_ROOT_DLL
00808     ClassImp(TRecordDisplay)
00809 #endif


CLDAQ - a Class Library for DataAcQuisition (Version 1.14.3)
Go IWAI -- goiwai at users.sourceforge.jp