Subversion Repositories f9daq

Rev

Rev 111 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
111 f9daq 1
// By ROOT version 5.17/02 on 2008-03-13 06:46:41
2
 
3
#ifndef ROOT_TGDockableFrame
4
#include "TGDockableFrame.h"
5
#endif
6
#ifndef ROOT_TGMenu
7
#include "TGMenu.h"
8
#endif
9
#ifndef ROOT_TGMdiDecorFrame
10
#include "TGMdiDecorFrame.h"
11
#endif
12
#ifndef ROOT_TG3DLine
13
#include "TG3DLine.h"
14
#endif
15
#ifndef ROOT_TGMdiFrame
16
#include "TGMdiFrame.h"
17
#endif
18
#ifndef ROOT_TGMdiMainFrame
19
#include "TGMdiMainFrame.h"
20
#endif
21
//#ifndef ROOT_TGuiBldHintsButton
22
//#include "TGuiBldHintsButton.h"
23
//#endif
24
#ifndef ROOT_TGMdiMenu
25
#include "TGMdiMenu.h"
26
#endif
27
#ifndef ROOT_TGListBox
28
#include "TGListBox.h"
29
#endif
30
#ifndef ROOT_TGNumberEntry
31
#include "TGNumberEntry.h"
32
#endif
33
#ifndef ROOT_TGScrollBar
34
#include "TGScrollBar.h"
35
#endif
36
//#ifndef ROOT_TGuiBldHintsEditor
37
//#include "TGuiBldHintsEditor.h"
38
//#endif
39
#ifndef ROOT_TRootBrowser
40
#include "TRootBrowser.h"
41
#endif
42
#ifndef ROOT_TGFrame
43
#include "TGFrame.h"
44
#endif
45
#ifndef ROOT_TGFileDialog
46
#include "TGFileDialog.h"
47
#endif
48
#ifndef ROOT_TGShutter
49
#include "TGShutter.h"
50
#endif
51
#ifndef ROOT_TGButtonGroup
52
#include "TGButtonGroup.h"
53
#endif
54
#ifndef ROOT_TGCanvas
55
#include "TGCanvas.h"
56
#endif
57
#ifndef ROOT_TGFSContainer
58
#include "TGFSContainer.h"
59
#endif
60
#ifndef ROOT_TGButton
61
#include "TGButton.h"
62
#endif
63
//#ifndef ROOT_TGuiBldEditor
64
//#include "TGuiBldEditor.h"
65
//#endif
66
#ifndef ROOT_TGTextEdit
67
#include "TGTextEdit.h"
68
#endif
69
#ifndef ROOT_TGFSComboBox
70
#include "TGFSComboBox.h"
71
#endif
72
#ifndef ROOT_TGLabel
73
#include "TGLabel.h"
74
#endif
75
#ifndef ROOT_TGView
76
#include "TGView.h"
77
#endif
78
//#ifndef ROOT_TRootGuiBuilder
79
//#include "TRootGuiBuilder.h"
80
//#endif
81
#ifndef ROOT_TGTab
82
#include "TGTab.h"
83
#endif
84
#ifndef ROOT_TGListView
85
#include "TGListView.h"
86
#endif
87
#ifndef ROOT_TGSplitter
88
#include "TGSplitter.h"
89
#endif
90
#ifndef ROOT_TGStatusBar
91
#include "TGStatusBar.h"
92
#endif
93
#ifndef ROOT_TGListTree
94
#include "TGListTree.h"
95
#endif
96
#ifndef ROOT_TGToolTip
97
#include "TGToolTip.h"
98
#endif
99
#ifndef ROOT_TGToolBar
100
#include "TGToolBar.h"
101
#endif
102
#ifndef ROOT_TRootEmbeddedCanvas
103
#include "TRootEmbeddedCanvas.h"
104
#endif
105
#ifndef ROOT_TCanvas
106
#include "TCanvas.h"
107
#endif
108
//#ifndef ROOT_TGuiBldDragManager
109
//#include "TGuiBldDragManager.h"
110
//#endif
111
 
112
#include "Riostream.h"
113
#include "TThread.h"
114
#include "TApplication.h"
115
#include "TROOT.h"
116
#include "TGraph.h"
118 rok 117
#include "TCanvas.h"
118
#include "TPad.h"
111 f9daq 119
#include "TStyle.h"
120
#include "TH1F.h"
121
#include "daq.h"
122
 
123
TGTextButton   *gTextButton[10];
124
TCanvas        *fCanvas;
125
TGMainFrame    *fMain;
126
TGTextEntry    *gFilename;
127
TGNumberEntry  *gThreshold;
128
TGNumberEntry  *gTimeSet;
129
TRootEmbeddedCanvas *gCanvas;
130
TH1F* gHisto;
131
 
132
daq * gDaq;
133
//----------------------------------------------------
134
 
135
void MyEventHandler(int i){
136
 char fname[200];
137
  switch (i) {
138
  case 0: // init
139
    gDaq->init();
140
    break;
141
  case 1: // start
142
    gDaq->start((int) gThreshold->GetNumber(),(int) gTimeSet->GetNumber() );
143
    break;
144
  case 2: // count
145
    gDaq->count();
146
    if (!gHisto) gHisto=new TH1F("h0","h0;Stevilka kanala;Stevilo zadetkov",16,0.5,16.5);
147
    if (gHisto) {
148
      for (int i=0;i<16;i++) gHisto->SetBinContent(i+1,gDaq->gData[i]);
149
      gCanvas->GetCanvas()->cd();
150
      gHisto->Draw();
151
      gHisto->Draw("text same");
152
      gCanvas->GetCanvas()->Modified();
153
      gCanvas->GetCanvas()->Update();
154
      printf("Vsota kanalov=%d\n",(int) gHisto->GetSum());
155
    }
156
    break;
157
  case 3: // save
158
    gDaq->save();
159
    break;
160
  case 4: // append
161
    sprintf ( fname,"%s",gFilename->GetText());
162
    gDaq->append(fname);
163
    break;
164
  case 5: // save
165
    gCanvas->GetCanvas()->SaveAs("uklonski_poskus.pdf");
166
    break;
167
  case 6: // exit
168
    gApplication->Terminate(0);
169
    break;
170
  }
171
}
172
 
173
//----------------------------------------------------
174
 
175
int gui(){
176
 
177
  gDaq= new daq();
178
  fMain = new TGMainFrame(0,800,800);
179
  TGHorizontalFrame *fH=new TGHorizontalFrame(fMain,800,400);
180
  //------------------------------------------------------------
181
  TGLayoutHints *f0= new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2);
182
  TGLayoutHints *layout2= new TGLayoutHints(kLHintsLeft | kLHintsTop,20,20,20,20);
183
 
184
 
185
  // gumbi
186
 
187
  int nbut=7;
188
  const char *names[10]={"Inicializacija","Start","Prestej","Shrani","Dodaj v datoteko", "Natisni" , "Konec"};
189
  for (int i=0;i<nbut;i++){
190
 
191
    gTextButton[i]= new TGTextButton(fH, names[i]);
192
    gTextButton[i]->SetTextJustify(36);
193
    gTextButton[i]->SetMargins(0,0,0,0);
194
    gTextButton[i]->SetWrapLength(-1);
195
    gTextButton[i]->Resize(50,22);
196
    fH->AddFrame(gTextButton[i], layout2);
197
    char cmd[50];
198
    sprintf(cmd,"MyEventHandler(=%d)",i);
199
    TQObject::Connect(gTextButton[i],"Clicked()",0,0,cmd);
200
  }
201
  fMain->AddFrame(fH    , f0);
202
  //---------------------------------------------------------
203
  // inputi
204
  fH=new TGHorizontalFrame(fMain,800,200);
205
 
206
  TGLabel *lab1 = new TGLabel( fH ,"Ime datoteke:");
207
  fH->AddFrame(lab1, f0);
208
  gFilename =  new TGTextEntry( fH,"datoteka.txt");
209
  fH->AddFrame(gFilename, f0);
210
 
211
  TGLabel *lab2 = new TGLabel( fH ,"Nivo prozenja (mV):");
212
  fH->AddFrame(lab2, f0);
213
  gThreshold =  new TGNumberEntry( fH,250);
214
  fH->AddFrame(gThreshold, f0);
215
  lab2 = new TGLabel( fH ,"Cas meritve (ms):");
216
  fH->AddFrame(lab2, f0);
217
  gTimeSet =  new TGNumberEntry( fH,1000);
218
  fH->AddFrame(gTimeSet, f0);
219
 
220
  fMain->AddFrame(fH    , f0);
221
  //---------------------------------------------------------
222
  // canvas
223
  fH=new TGHorizontalFrame(fMain,800,200);
224
  gCanvas = new TRootEmbeddedCanvas ("gCanvas",fH,800,400);
225
  fH->AddFrame(gCanvas, f0);
226
  fMain->AddFrame(fH   , f0);
227
 
228
 
229
  fMain->SetWindowName("Praktikum IV Uklonski poskus");
230
  fMain->MapSubwindows();
231
  fMain->Resize(fMain->GetDefaultSize());
232
  fMain->MapWindow();
233
  gStyle->SetOptStat(11111111);
234
  return 0;
235
}