Subversion Repositories f9daq

Rev

Rev 111 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

// By ROOT version 5.17/02 on 2008-03-13 06:46:41

#ifndef ROOT_TGDockableFrame
#include "TGDockableFrame.h"
#endif
#ifndef ROOT_TGMenu
#include "TGMenu.h"
#endif
#ifndef ROOT_TGMdiDecorFrame
#include "TGMdiDecorFrame.h"
#endif
#ifndef ROOT_TG3DLine
#include "TG3DLine.h"
#endif
#ifndef ROOT_TGMdiFrame
#include "TGMdiFrame.h"
#endif
#ifndef ROOT_TGMdiMainFrame
#include "TGMdiMainFrame.h"
#endif
//#ifndef ROOT_TGuiBldHintsButton
//#include "TGuiBldHintsButton.h"
//#endif
#ifndef ROOT_TGMdiMenu
#include "TGMdiMenu.h"
#endif
#ifndef ROOT_TGListBox
#include "TGListBox.h"
#endif
#ifndef ROOT_TGNumberEntry
#include "TGNumberEntry.h"
#endif
#ifndef ROOT_TGScrollBar
#include "TGScrollBar.h"
#endif
//#ifndef ROOT_TGuiBldHintsEditor
//#include "TGuiBldHintsEditor.h"
//#endif
#ifndef ROOT_TRootBrowser
#include "TRootBrowser.h"
#endif
#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif
#ifndef ROOT_TGFileDialog
#include "TGFileDialog.h"
#endif
#ifndef ROOT_TGShutter
#include "TGShutter.h"
#endif
#ifndef ROOT_TGButtonGroup
#include "TGButtonGroup.h"
#endif
#ifndef ROOT_TGCanvas
#include "TGCanvas.h"
#endif
#ifndef ROOT_TGFSContainer
#include "TGFSContainer.h"
#endif
#ifndef ROOT_TGButton
#include "TGButton.h"
#endif
//#ifndef ROOT_TGuiBldEditor
//#include "TGuiBldEditor.h"
//#endif
#ifndef ROOT_TGTextEdit
#include "TGTextEdit.h"
#endif
#ifndef ROOT_TGFSComboBox
#include "TGFSComboBox.h"
#endif
#ifndef ROOT_TGLabel
#include "TGLabel.h"
#endif
#ifndef ROOT_TGView
#include "TGView.h"
#endif
//#ifndef ROOT_TRootGuiBuilder
//#include "TRootGuiBuilder.h"
//#endif
#ifndef ROOT_TGTab
#include "TGTab.h"
#endif
#ifndef ROOT_TGListView
#include "TGListView.h"
#endif
#ifndef ROOT_TGSplitter
#include "TGSplitter.h"
#endif
#ifndef ROOT_TGStatusBar
#include "TGStatusBar.h"
#endif
#ifndef ROOT_TGListTree
#include "TGListTree.h"
#endif
#ifndef ROOT_TGToolTip
#include "TGToolTip.h"
#endif
#ifndef ROOT_TGToolBar
#include "TGToolBar.h"
#endif
#ifndef ROOT_TRootEmbeddedCanvas
#include "TRootEmbeddedCanvas.h"
#endif
#ifndef ROOT_TCanvas
#include "TCanvas.h"
#endif
//#ifndef ROOT_TGuiBldDragManager
//#include "TGuiBldDragManager.h"
//#endif

#include "Riostream.h"
#include "TThread.h"
#include "TApplication.h"
#include "TROOT.h"
#include "TGraph.h"
#include "TCanvas.h"
#include "TPad.h"
#include "TStyle.h"
#include "TH1F.h"
#include "daq.h"

TGTextButton   *gTextButton[10];
TCanvas        *fCanvas;
TGMainFrame    *fMain;
TGTextEntry    *gFilename;
TGNumberEntry  *gThreshold;
TGNumberEntry  *gTimeSet;
TRootEmbeddedCanvas *gCanvas;
TH1F* gHisto;

daq * gDaq;
//----------------------------------------------------

void MyEventHandler(int i){
 char fname[200];
  switch (i) {
  case 0: // init
    gDaq->init();
    break;
  case 1: // start
    gDaq->start((int) gThreshold->GetNumber(),(int) gTimeSet->GetNumber() );
    break;
  case 2: // count
    gDaq->count();
    if (!gHisto) gHisto=new TH1F("h0","h0;Stevilka kanala;Stevilo zadetkov",16,0.5,16.5);
    if (gHisto) {
      for (int i=0;i<16;i++) gHisto->SetBinContent(i+1,gDaq->gData[i]);
      gCanvas->GetCanvas()->cd();
      gHisto->Draw();
      gHisto->Draw("text same");
      gCanvas->GetCanvas()->Modified();
      gCanvas->GetCanvas()->Update();
      printf("Vsota kanalov=%d\n",(int) gHisto->GetSum());
    }
    break;
  case 3: // save
    gDaq->save();
    break;
  case 4: // append
    sprintf ( fname,"%s",gFilename->GetText());
    gDaq->append(fname);
    break;
  case 5: // save
    gCanvas->GetCanvas()->SaveAs("uklonski_poskus.pdf");
    break;
  case 6: // exit
    gApplication->Terminate(0);
    break;
  }
}

//----------------------------------------------------

int gui(){
  
  gDaq= new daq();
  fMain = new TGMainFrame(0,800,800);
  TGHorizontalFrame *fH=new TGHorizontalFrame(fMain,800,400);
  //------------------------------------------------------------
  TGLayoutHints *f0= new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2);
  TGLayoutHints *layout2= new TGLayoutHints(kLHintsLeft | kLHintsTop,20,20,20,20);


  // gumbi

  int nbut=7;
  const char *names[10]={"Inicializacija","Start","Prestej","Shrani","Dodaj v datoteko", "Natisni" , "Konec"};
  for (int i=0;i<nbut;i++){
    
    gTextButton[i]= new TGTextButton(fH, names[i]);
    gTextButton[i]->SetTextJustify(36);
    gTextButton[i]->SetMargins(0,0,0,0);
    gTextButton[i]->SetWrapLength(-1);
    gTextButton[i]->Resize(50,22);
    fH->AddFrame(gTextButton[i], layout2);
    char cmd[50];
    sprintf(cmd,"MyEventHandler(=%d)",i);
    TQObject::Connect(gTextButton[i],"Clicked()",0,0,cmd);
  }
  fMain->AddFrame(fH    , f0);
  //---------------------------------------------------------
  // inputi
  fH=new TGHorizontalFrame(fMain,800,200);
  
  TGLabel *lab1 = new TGLabel( fH ,"Ime datoteke:");
  fH->AddFrame(lab1, f0);
  gFilename =  new TGTextEntry( fH,"datoteka.txt");
  fH->AddFrame(gFilename, f0);
  
  TGLabel *lab2 = new TGLabel( fH ,"Nivo prozenja (mV):");
  fH->AddFrame(lab2, f0);
  gThreshold =  new TGNumberEntry( fH,250);
  fH->AddFrame(gThreshold, f0);
  lab2 = new TGLabel( fH ,"Cas meritve (ms):");
  fH->AddFrame(lab2, f0); 
  gTimeSet =  new TGNumberEntry( fH,1000);
  fH->AddFrame(gTimeSet, f0);

  fMain->AddFrame(fH    , f0); 
  //---------------------------------------------------------
  // canvas
  fH=new TGHorizontalFrame(fMain,800,200);
  gCanvas = new TRootEmbeddedCanvas ("gCanvas",fH,800,400);
  fH->AddFrame(gCanvas, f0);
  fMain->AddFrame(fH   , f0);
  

  fMain->SetWindowName("Praktikum IV Uklonski poskus");
  fMain->MapSubwindows();
  fMain->Resize(fMain->GetDefaultSize());
  fMain->MapWindow();
  gStyle->SetOptStat(11111111);
  return 0;
}