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

ScanFrame Class Reference

#include <ScanFrame.h>

Inheritance diagram for ScanFrame:

ScanFrameCC ScanFrameNC ScanFrameTwoTrack List of all members.

Public Member Functions

 ScanFrame (const TGWindow *p=0, Bool_t buildScanFrame=true)
virtual ~ScanFrame ()
void EntryProc ()
virtual void ResetDisplay (std::string mode="")
void SetRun (Int_t s)
void SetSnarl (Int_t s)
void SetSlice (Int_t s)
void SetEvent (Int_t s)
virtual void Pass (const std::string)
virtual void PassChar (const std::string, char)
virtual void PassInt (const std::string, Long_t)
virtual void PassFloat (const std::string, Double_t)
virtual void PassString (const std::string, const std::string)
virtual void BuildScanSheet ()
virtual void InitScanSheet ()
virtual void ResyncData ()
virtual void WriteScanSheet (ofstream &)

Static Public Member Functions

void EnableXMLFormat (Bool_t enable=true)
ScanFrameCreateScanSheet (const TGWindow *p, const char *name=0)

Protected Member Functions

void BuildScanFrame (const TGWindow *p)
void Init ()
 ClassDef (ScanFrame, 1)

Protected Attributes

TGMainFrame * fMain
TGVerticalFrame * fSframe
 Transient, do not output.
TGTextEntry * Comment
 Transient, do not output.
TGTextEntry * Scanner
 Transient, do not output.
TGLabel * runLabel
 Transient, do not output.
TGLabel * snarlLabel
 Transient, do not output.
TGLabel * sliceLabel
 Transient, do not output.
TGLabel * eventLabel
 Transient, do not output.
Bool_t fEnableXMLFormat
 Transient, do not output.
std::string fComment
 Transient, do not output.
std::string fScanner
std::string fScanName
std::string fScanFormat
Long_t fSnarl
Long_t fRun
Long_t fSlice
Long_t fEvent

Static Protected Attributes

Bool_t fgEnableXMLFormat

Detailed Description

Id
ScanFrame.h,v 1.10 2008/06/26 19:42:39 nwest Exp

ScanFrame is the base class for Mad-based scan forms. It has been developed from Jim Musser's ScanFrame which has been renamed to ScanFrameCC and sub-classed from ScanFrame.

Two interfaces are described here:-

1) The front-end (client i.e. MadScanDisplay) interface. 2) The back-end (implementation e.g. ScanFrameCC) interface.

The front-end (client) interface ********************************

Clients create a ScanFrame or sub-class object using the static factory method:-

ScanFrame* ScanFrame::CreateScanSheet(const TGWindow *p, const char* name = 0 )

This supports multiple scan sheets (see the CreateScanSheet method for the full list) including a very primitive ScanFrame (name="Base") that only records scanner name and comments.

The run, snarl, slice and event state are set using the methods:-

void SetRun(Int_t s) void SetSnarl(Int_t s) void SetSlice(Int_t s) void SetEvent(Int_t s)

The scan is written out using the method:-

void EntryProc();

by default the file format is ASCII where each event consists of a single, space separated, set of values. XML format is also supported and can be enabled by calling the static method:-

void ScanFrame::EnableXMLFormat(Bool_t enable = true)

before creating the sheet.

The scan file name has the format:-

<scan-name>-scan-<scanner-name>.<ext>

where <ext> = "txt" ASCII file "xml" XML file

The scan state refills all widgets from the object state using the method:-

void ResetDisplay(std::string mode = "");

The mode argument allows clients to support qualified resets (see ScanFrameCC).

All additional information is passed to the sub-class object via the generic interface:-

virtual void Pass(const std::string attribute); virtual void PassInt(const std::string attribute,Long_t value); virtual void PassFloat(const std::string attribute,Double_t value); virtual void PassString(const std::string attribute,const std::string value);

The methods are called "PassXxx" rather than "SetXxx" as the sub-class object is free to accept or ignore such data. The model is that the client collects all the information that any type of scan requires and passes it all. Thus the client does not need to know what type of scan is being performed.

The back-end (implementation) interface ***************************************

A client has to reimplemented:-

o Any PassXxx method if it has to collect data of Xxx type.

o virtual void ResetDisplay(std::string mode = "");

This method refills all widgets from the object state. The method should call ScanFrame::ResetDisplay to reset it unless doing a qualified reset that does not require it.

o virtual void BuildScanSheet();

This method fills out the scan specific part of the scan sheet ScanFrame::BuildScanFrame() performs the overall build of the graphical interface and calls this method to embed the scan sheet.

o virtual void InitScanSheet();

This method resets to default the object (non-widget) state. ScanFrame::Init() calls this method. It should set the scan name e.g.:-

fScanName = "CC";

o virtual void ResyncData();

Implementation is optional but allows "lazy synchronisation" whereby updates via graphics to the widgets are not immediately propagated to the non-widget state. Instead all widget state is propagated in this method which is called as a precursor to I/O, thus ensuring that the full state is recorded. This means that it is not necessary to connect slots to each widget and write a function for each to receive the update signal.

o virtual void WriteScanSheet(ofstream& out);

This method writes out the scan specific part of the scan sheet ScanFrame::EntryProc() performs the overall output and calls this method

Definition at line 131 of file ScanFrame.h.


Constructor & Destructor Documentation

ScanFrame::ScanFrame const TGWindow *  p = 0,
Bool_t  buildScanFrame = true
 

Definition at line 46 of file ScanFrame.cxx.

References BuildScanFrame(), and Init().

Referenced by CreateScanSheet().

00047                                                                   :
00048   fEnableXMLFormat(fgEnableXMLFormat)   // Capture current setting of global XML flag.
00049 {
00050 
00051   // Note: The case p == is NOT supported but CINT appears to require that
00052   //       base classes have default constructors.
00053 
00054   if ( ! p ) {
00055     std::cout << "ScanFrame called with TGWindow *p == 0.  This is not supported!" << std::endl;
00056     exit(1);
00057   }
00058 
00059   this->Init();
00060   if ( buildScanFrame ) this->BuildScanFrame(p);
00061 }

ScanFrame::~ScanFrame  )  [virtual]
 

Definition at line 63 of file ScanFrame.cxx.

00063                       {
00064 }


Member Function Documentation

void ScanFrame::BuildScanFrame const TGWindow *  p  )  [protected]
 

Definition at line 66 of file ScanFrame.cxx.

References BuildScanSheet(), Comment, eventLabel, fEvent, fMain, fRun, fSframe, fSlice, fSnarl, runLabel, Scanner, sliceLabel, and snarlLabel.

Referenced by ScanFrame().

00066                                                 {
00067 
00068   // Initialise all the widigits and display the scan frame.
00069 
00070   fMain   = new TGMainFrame(p,600,600);
00071   fSframe = new TGVerticalFrame(fMain,600,600);
00072   fMain->AddFrame(fSframe,new TGLayoutHints(kLHintsCenterX,2,2,2,2));
00073 
00074   // Draw the run, snarl, slice, event and scanner box
00075 
00076   TGHorizontal3DLine* Line1 = new TGHorizontal3DLine(fSframe,400,2);
00077   fSframe->AddFrame(Line1, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
00078 
00079   TGHorizontalFrame * tframe1 = new TGHorizontalFrame(fSframe,400,10);
00080 
00081   TGLabel*  Label1 = new TGLabel(tframe1,"     Run: ");
00082   TGLabel*  Label2 = new TGLabel(tframe1,"     Snarl: ");
00083   TGLabel*  Label3 = new TGLabel(tframe1,"     Slice: ");
00084   TGLabel*  Label4 = new TGLabel(tframe1,"     Event: ");
00085 
00086   runLabel    = new TGLabel(tframe1);
00087   snarlLabel  = new TGLabel(tframe1);
00088   eventLabel  = new TGLabel(tframe1);
00089   sliceLabel  = new TGLabel(tframe1);
00090   
00091   runLabel->SetText(fRun);
00092   snarlLabel->SetText(fSnarl);
00093   eventLabel->SetText(fEvent);
00094   sliceLabel->SetText(fSlice);
00095   
00096   tframe1->AddFrame(Label1,new TGLayoutHints(kLHintsLeft|kLHintsExpandY,2,2,2,2));
00097   tframe1->AddFrame(runLabel,new TGLayoutHints(kLHintsLeft|kLHintsExpandY,2,2,2,2));
00098   tframe1->AddFrame(Label2,new TGLayoutHints(kLHintsLeft|kLHintsExpandY,2,2,2,2));
00099   tframe1->AddFrame(snarlLabel,new TGLayoutHints(kLHintsLeft|kLHintsExpandY,2,2,2,2));
00100   tframe1->AddFrame(Label3,new TGLayoutHints(kLHintsLeft|kLHintsExpandY,2,2,2,2));
00101   tframe1->AddFrame(sliceLabel,new TGLayoutHints(kLHintsLeft|kLHintsExpandY,2,2,2,2));
00102   tframe1->AddFrame(Label4,new TGLayoutHints(kLHintsLeft|kLHintsExpandY,2,2,2,2));
00103   tframe1->AddFrame(eventLabel,new TGLayoutHints(kLHintsLeft|kLHintsExpandY,2,2,2,2));
00104 
00105   fSframe->AddFrame(tframe1,new TGLayoutHints(kLHintsCenterX ,2,2,2,2)); 
00106 
00107   TGHorizontalFrame * tframe2 = new TGHorizontalFrame(fSframe,400,10);
00108 
00109   TGLabel*  Label5 = new TGLabel(tframe2," Scanner:  ");
00110   tframe2->AddFrame(Label5,new TGLayoutHints(kLHintsLeft|kLHintsExpandY,2,2,2,2));
00111   Scanner  = new TGTextEntry(tframe2);
00112   Scanner->SetText("Unknown");
00113   tframe2->AddFrame(Scanner,new TGLayoutHints(kLHintsLeft|kLHintsExpandY,2,2,2,2));
00114 
00115   fSframe->AddFrame(tframe2,new TGLayoutHints(kLHintsCenterX ,2,2,2,2)); 
00116 
00117   TGHorizontal3DLine* Line3 = new TGHorizontal3DLine(fSframe,400,2);
00118   fSframe->AddFrame(Line3, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
00119 
00120   // Fill out the scan-specific data.
00121 
00122   this->BuildScanSheet();
00123 
00124   // Output the comment section.
00125 
00126   TGHorizontal3DLine* Line5 = new TGHorizontal3DLine(fSframe,400,2);
00127   fSframe->AddFrame(Line5, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
00128 
00129   TGHorizontalFrame* tframe = new TGHorizontalFrame(fSframe,400,10);
00130   fSframe->AddFrame(tframe ,new TGLayoutHints(kLHintsLeft|kLHintsExpandX,2,2,2,2)); 
00131 
00132   TGLabel* Label = new TGLabel(tframe,"Comment");
00133   tframe->AddFrame(Label,new TGLayoutHints(kLHintsLeft,2,2,2,2));
00134   Comment  = new TGTextEntry(tframe);
00135   Comment->SetText(" ");
00136   tframe->AddFrame(Comment,new TGLayoutHints(kLHintsExpandX,2,2,2,2));
00137 
00138   TGHorizontal3DLine* Line6 = new TGHorizontal3DLine(fSframe,400,2);
00139   fSframe->AddFrame(Line6, new TGLayoutHints(kLHintsExpandX,1,1,1,1));
00140 
00141   // Complete the canvas and display.
00142  
00143   fMain->SetWindowName("Scan Result Entry");
00144   fMain->MapSubwindows();
00145   fMain->Resize(fMain->GetDefaultSize());
00146   fMain->MapWindow();
00147 }

virtual void ScanFrame::BuildScanSheet  )  [inline, virtual]
 

Reimplemented in ScanFrameCC, ScanFrameNC, and ScanFrameTwoTrack.

Definition at line 157 of file ScanFrame.h.

Referenced by BuildScanFrame().

00157 {}

ScanFrame::ClassDef ScanFrame  ,
[protected]
 

Reimplemented in ScanFrameCC, ScanFrameNC, and ScanFrameTwoTrack.

ScanFrame * ScanFrame::CreateScanSheet const TGWindow *  p,
const char *  name = 0
[static]
 

Definition at line 30 of file ScanFrame.cxx.

References MSG, and ScanFrame().

Referenced by MadScanDisplay::MadScanDisplay().

00031                                                                {
00032   std::string name( nm ? nm : "CC");
00033   MSG("Mad",Msg::kInfo) << "Creating a scan sheet named " << name << std::endl;
00034   
00035   if ( name == "Base"     ) return new ScanFrame(p);
00036   if ( name == "CC"       ) return new ScanFrameCC(p);
00037   if ( name == "NC"       ) return new ScanFrameNC(p);
00038   if ( name == "TwoTrack" ) return new ScanFrameTwoTrack(p);
00039 
00040   MSG("Mad",Msg::kError) << "Cannot create a scan sheet named " << name
00041                          << " creating 'Default' instead."  << std::endl;
00042   return new ScanFrameCC(p);
00043 
00044 }

void ScanFrame::EnableXMLFormat Bool_t  enable = true  )  [static]
 

Definition at line 22 of file ScanFrame.cxx.

References MSG.

00022                                                       { 
00023   // fgEnableXMLFormat = enable; 
00024   MSG("Mad",Msg::kError) << "Support for XML is currently disabled as ROOT SegVs when reading the output"
00025                          << std::endl;
00026 }

void ScanFrame::EntryProc  ) 
 

Definition at line 149 of file ScanFrame.cxx.

References Comment, fComment, fEnableXMLFormat, fEvent, fRun, fScanFormat, fScanName, fScanner, fSlice, fSnarl, gSystem(), Init(), ResetDisplay(), ResyncData(), Scanner, and WriteScanSheet().

Referenced by MadScanDisplay::FindUnSliced(), MadScanDisplay::NextEvt(), MadScanDisplay::NextFidNoTrk(), MadScanDisplay::NextFidTrk(), MadScanDisplay::NextInterestingEvent(), MadScanDisplay::PrevEvt(), and MadScanDisplay::PrevPass().

00149                           {
00150 
00151   // Ensure synchronisation between widget and non-widget state.
00152   this->ResyncData();
00153 
00154   // Append state to scanner file.
00155 
00156   fComment = Comment->GetText();
00157   fScanner = Scanner->GetText();
00158   char fname[256];
00159   const char* ext = fEnableXMLFormat ? "xml" : "txt";
00160   sprintf(fname,"%s-scan-%s.%s",fScanName.c_str(),Scanner->GetText(),ext);
00161 
00162   // Sound beep so scanner knows file updated.
00163   gSystem->Beep();
00164 
00165   // If XML is enabled, use ROOT I/O.
00166 
00167   if ( fEnableXMLFormat ) {
00168     // Save current directory.
00169      TDirectory* cwd = gDirectory;
00170      TFile *f = TFile::Open(fname,"update");
00171      this->Write();
00172      delete f;
00173      // Switch back to old current directory
00174      cwd->cd();
00175      return;
00176   }
00177 
00178   // Otherwise append to ASCII file.
00179 
00180   ofstream fout(fname,std::ios::app);
00181   fout << fScanFormat << " " 
00182        << fScanner << " " 
00183        << fSnarl << " " 
00184        << fRun << " " 
00185        << fSlice << " " 
00186        << fEvent << " " ;
00187 
00188   // Output the scan-specific data.
00189   this->WriteScanSheet(fout);
00190 
00191   // Complete the output
00192 
00193   fout << "\"" << " " << fComment << " " << "\" " << std::endl; 
00194   std::cout << " ENTRY ADDED TO " << fname << std::endl;
00195 
00196   // Reset the form. 
00197   Init();
00198   ResetDisplay();
00199 
00200 }

void ScanFrame::Init  )  [protected]
 

Definition at line 202 of file ScanFrame.cxx.

References fComment, fEvent, fRun, fScanFormat, fScanName, fScanner, fSlice, fSnarl, and InitScanSheet().

Referenced by EntryProc(), and ScanFrame().

00202                     {
00203 
00204   fComment="";
00205   fScanner="";
00206   fScanName="Base";
00207   fScanFormat="Base_v1";
00208   fSnarl=0;
00209   fRun=0;
00210   fSlice=0;
00211   fEvent=0;
00212 
00213   // Initialise the scan-specific data.
00214   this->InitScanSheet();
00215 
00216 }

virtual void ScanFrame::InitScanSheet  )  [inline, virtual]
 

Reimplemented in ScanFrameCC, ScanFrameNC, and ScanFrameTwoTrack.

Definition at line 158 of file ScanFrame.h.

Referenced by Init().

00158 {}

virtual void ScanFrame::Pass const std::string   )  [inline, virtual]
 

Reimplemented in ScanFrameCC, and ScanFrameNC.

Definition at line 149 of file ScanFrame.h.

Referenced by MadScanDisplay::InFidNoTrk(), and MadScanDisplay::InFidTrk().

00149 {};

virtual void ScanFrame::PassChar const std::string  ,
char 
[inline, virtual]
 

Reimplemented in ScanFrameTwoTrack.

Definition at line 150 of file ScanFrame.h.

Referenced by MadScanDisplay::DrawTextBox().

00150 {};

virtual void ScanFrame::PassFloat const std::string  ,
Double_t 
[inline, virtual]
 

Reimplemented in ScanFrameCC, ScanFrameNC, and ScanFrameTwoTrack.

Definition at line 152 of file ScanFrame.h.

Referenced by MadScanDisplay::Display(), MadScanDisplay::DrawTextBox(), MadScanDisplay::ROICalc(), and MadScanDisplay::ShwROICalc().

00152 {};

virtual void ScanFrame::PassInt const std::string  ,
Long_t 
[inline, virtual]
 

Reimplemented in ScanFrameCC, ScanFrameNC, and ScanFrameTwoTrack.

Definition at line 151 of file ScanFrame.h.

Referenced by MadScanDisplay::Display(), and MadScanDisplay::DrawTextBox().

00151 {};

virtual void ScanFrame::PassString const std::string  ,
const std::string 
[inline, virtual]
 

Definition at line 153 of file ScanFrame.h.

00153 {};

void ScanFrame::ResetDisplay std::string  mode = ""  )  [virtual]
 

Reimplemented in ScanFrameCC, ScanFrameNC, and ScanFrameTwoTrack.

Definition at line 218 of file ScanFrame.cxx.

References Comment, eventLabel, fEvent, fRun, fSlice, fSnarl, runLabel, sliceLabel, and snarlLabel.

Referenced by MadScanDisplay::Display(), EntryProc(), ScanFrameTwoTrack::ResetDisplay(), ScanFrameNC::ResetDisplay(), and ScanFrameCC::ResetDisplay().

00218                                                  {
00219 
00220   runLabel->SetText(fRun);
00221   snarlLabel->SetText(fSnarl);
00222   eventLabel->SetText(fEvent);
00223   sliceLabel->SetText(fSlice);
00224   Comment->SetText(" ");
00225 
00226 }

virtual void ScanFrame::ResyncData  )  [inline, virtual]
 

Reimplemented in ScanFrameTwoTrack.

Definition at line 159 of file ScanFrame.h.

Referenced by EntryProc().

00159 {}

void ScanFrame::SetEvent Int_t  s  )  [inline]
 

Definition at line 145 of file ScanFrame.h.

References fEvent.

Referenced by MadScanDisplay::Display(), and MadScanDisplay::FindUnSliced().

00145 {fEvent=s;}

void ScanFrame::SetRun Int_t  s  )  [inline]
 

Definition at line 142 of file ScanFrame.h.

References fRun.

Referenced by MadScanDisplay::Display().

00142 {fRun=s;}

void ScanFrame::SetSlice Int_t  s  )  [inline]
 

Definition at line 144 of file ScanFrame.h.

References fSlice.

Referenced by MadScanDisplay::Display(), and MadScanDisplay::FindUnSliced().

00144 {fSlice=s;}

void ScanFrame::SetSnarl Int_t  s  )  [inline]
 

Definition at line 143 of file ScanFrame.h.

References fSnarl.

Referenced by MadScanDisplay::Display().

00143 {fSnarl=s;}

virtual void ScanFrame::WriteScanSheet ofstream &   )  [inline, virtual]
 

Reimplemented in ScanFrameCC, ScanFrameNC, and ScanFrameTwoTrack.

Definition at line 160 of file ScanFrame.h.

Referenced by EntryProc().

00160 {}


Member Data Documentation

TGTextEntry* ScanFrame::Comment [protected]
 

Transient, do not output.

Definition at line 177 of file ScanFrame.h.

Referenced by BuildScanFrame(), EntryProc(), and ResetDisplay().

TGLabel* ScanFrame::eventLabel [protected]
 

Transient, do not output.

Definition at line 183 of file ScanFrame.h.

Referenced by BuildScanFrame(), and ResetDisplay().

std::string ScanFrame::fComment [protected]
 

Transient, do not output.

Definition at line 187 of file ScanFrame.h.

Referenced by EntryProc(), and Init().

Bool_t ScanFrame::fEnableXMLFormat [protected]
 

Transient, do not output.

Definition at line 185 of file ScanFrame.h.

Referenced by EntryProc().

Long_t ScanFrame::fEvent [protected]
 

Definition at line 195 of file ScanFrame.h.

Referenced by BuildScanFrame(), EntryProc(), Init(), ResetDisplay(), and SetEvent().

Bool_t ScanFrame::fgEnableXMLFormat [static, protected]
 

TGMainFrame* ScanFrame::fMain [protected]
 

Definition at line 174 of file ScanFrame.h.

Referenced by BuildScanFrame().

Long_t ScanFrame::fRun [protected]
 

Definition at line 193 of file ScanFrame.h.

Referenced by BuildScanFrame(), EntryProc(), Init(), ResetDisplay(), and SetRun().

std::string ScanFrame::fScanFormat [protected]
 

Definition at line 190 of file ScanFrame.h.

Referenced by EntryProc(), and Init().

std::string ScanFrame::fScanName [protected]
 

Definition at line 189 of file ScanFrame.h.

Referenced by EntryProc(), and Init().

std::string ScanFrame::fScanner [protected]
 

Definition at line 188 of file ScanFrame.h.

Referenced by EntryProc(), and Init().

TGVerticalFrame* ScanFrame::fSframe [protected]
 

Transient, do not output.

Definition at line 175 of file ScanFrame.h.

Referenced by BuildScanFrame().

Long_t ScanFrame::fSlice [protected]
 

Definition at line 194 of file ScanFrame.h.

Referenced by BuildScanFrame(), EntryProc(), Init(), ResetDisplay(), and SetSlice().

Long_t ScanFrame::fSnarl [protected]
 

Definition at line 192 of file ScanFrame.h.

Referenced by BuildScanFrame(), EntryProc(), Init(), ResetDisplay(), and SetSnarl().

TGLabel* ScanFrame::runLabel [protected]
 

Transient, do not output.

Definition at line 180 of file ScanFrame.h.

Referenced by BuildScanFrame(), and ResetDisplay().

TGTextEntry* ScanFrame::Scanner [protected]
 

Transient, do not output.

Definition at line 178 of file ScanFrame.h.

Referenced by BuildScanFrame(), and EntryProc().

TGLabel* ScanFrame::sliceLabel [protected]
 

Transient, do not output.

Definition at line 182 of file ScanFrame.h.

Referenced by BuildScanFrame(), and ResetDisplay().

TGLabel* ScanFrame::snarlLabel [protected]
 

Transient, do not output.

Definition at line 181 of file ScanFrame.h.

Referenced by BuildScanFrame(), and ResetDisplay().


The documentation for this class was generated from the following files:
Generated on Mon Feb 15 11:10:16 2010 for loon by  doxygen 1.3.9.1