GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ConditionInfo.cpp
Go to the documentation of this file.
1 // $Id: TGo4ConditionInfo.cpp 1134 2014-01-22 14:53:40Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4ConditionInfo.h"
15 
16 #include "TClass.h"
17 #include "TDatime.h"
18 #include "TH1.h"
19 #include "TGo4Log.h"
20 #include "TGo4Condition.h"
21 #include "TGo4WinCond.h"
22 
23 
24 
25 TGo4ConditionInfo::TGo4ConditionInfo(QWidget *parent, const char* name)
26  : QGo4Widget(parent, name)
27 {
28  setupUi(this);
29  setWindowTitle("Condition Info:");
30 }
31 
32 
33 bool TGo4ConditionInfo::IsAcceptDrag(const char* itemname, TClass* cl, int kind)
34 {
35  return cl==0 ? false : cl->InheritsFrom(TGo4Condition::Class());
36 }
37 
38 void TGo4ConditionInfo::DropItem(const char* itemname, TClass* cl, int kind)
39 {
40  if (cl==0) return;
41  if (cl->InheritsFrom(TGo4Condition::Class()))
42  WorkWithCondition(itemname);
43 }
44 
45 void TGo4ConditionInfo::linkedObjectUpdated(const char* linkname, TObject* obj)
46 {
47  if (strcmp(linkname,"Condition")==0)
48  RefreshWidget(dynamic_cast<TGo4Condition*>(obj));
49 }
50 
51 
53 {
54  WorkWithCondition(CondnameLbl->text().toLatin1().constData());
55 }
56 
58 {
59  ServiceCall("PrintAnalysisConditions");
60 }
61 
63 {
64  EditItem(CondnameLbl->text());
65 }
66 
68 {
69  QString textbuffer;
70  textbuffer="Condition ";
71  textbuffer+=CondnameLbl->text();
72  textbuffer+=" Status: \n ";
73  textbuffer+="Title: ";
74  textbuffer+=PropertyBox->item(CONTITLE)->text();
75  textbuffer+=" Class: ";
76  textbuffer+=PropertyBox->item(CONCLASS)->text();
77  textbuffer+=" ";
78  textbuffer+=PropertyBox->item(CONDIM)->text();
79  textbuffer+=" ";
80  textbuffer+=PropertyBox->item(CONMODE)->text();
81  textbuffer+="\n ";
82  textbuffer+=PropertyBox->item(CONX)->text();
83  textbuffer+=" ";
84  textbuffer+=PropertyBox->item(CONY)->text();
85  textbuffer+="\n ";
86  textbuffer+=PropertyBox->item(CONCOUNTS)->text();
87  textbuffer+=" ";
88  textbuffer+=PropertyBox->item(CONRESULT)->text();
89  textbuffer+="\n ";
90  textbuffer+=PropertyBox->item(CONSIZE)->text();
91  textbuffer+=" Status received at: ";
92  textbuffer+=PropertyBox->item(CONTIME)->text();
93 
94  TGo4Log::Message(1, textbuffer.toLatin1().constData());
95 }
96 
97 void TGo4ConditionInfo::WorkWithCondition(const char* itemname)
98 {
99  ResetWidget();
100 
101  CondnameLbl->setText(itemname);
102 
103  AddLink(itemname, "Condition");
104 
105  TObject* obj = GetLinked("Condition", 2);
106 
107  RefreshWidget(dynamic_cast<TGo4Condition*>(obj));
108 
109  setFocus();
110 }
111 
113 {
115  PropertyBox->item(CONTITLE)->setText("Title");
116  PropertyBox->item(CONCLASS)->setText("Class:");
117  PropertyBox->item(CONX)->setText("X Testrange");
118  PropertyBox->item(CONY)->setText("Y Testrange");
119  PropertyBox->item(CONDIM)->setText("Dimension");
120  PropertyBox->item(CONCOUNTS)->setText("Counts");
121  PropertyBox->item(CONRESULT)->setText("Result");
122  PropertyBox->item(CONMODE)->setText("Test mode");
123  PropertyBox->item(CONSIZE)->setText("Size");
124  TDatime now;
125  PropertyBox->item(CONTIME)->setText(now.AsSQLString());
126  ensurePolished();
127  update();
128  show();
129  raise();
130 }
131 
133 {
134  if(cond==0) return;
135 
136  TString str;
137  PropertyBox->item(CONTITLE)->setText(cond->GetTitle());
138  PropertyBox->item(CONCLASS)->setText(cond->ClassName());
139  int dimension = 0;
140  if(cond->InheritsFrom(TGo4WinCond::Class())) {
141  TGo4WinCond* wcon = (TGo4WinCond*) cond;
142  double xmin, xmax, ymin, ymax;
143  wcon->GetValues(dimension, xmin, xmax, ymin, ymax);
144  str.Form("X: [%.1f,%.1f]",xmin, xmax);
145  PropertyBox->item(CONX)->setText(str.Data());
146  str.Form("Y: [%.1f,%.1f]",ymin, ymax);
147  PropertyBox->item(CONY)->setText(str.Data());
148  } else {
149  PropertyBox->item(CONX)->setText("X:-");
150  PropertyBox->item(CONY)->setText("Y:-");
151  dimension = 2;
152  }
153 
154  str.Form("Dim:%d", dimension);
155  PropertyBox->item(CONDIM)->setText(str.Data());
156  str.Form("Counts:%d", cond->Counts());
157  PropertyBox->item(CONCOUNTS)->setText(str.Data());
158  str.Form("True:%d",cond->TrueCounts());
159  PropertyBox->item(CONRESULT)->setText(str.Data());
160 
161  if(cond->IsEnabled()) str = "test enabled"; else
162  if(cond->FixedResult()) str = "always true";
163  else str = "always false";
164  if(cond->IsTrue()) str += " - regular";
165  else str += " - inverse";
166  PropertyBox->item(CONMODE)->setText(str.Data());
167 
168  str.Form("size:%d b",cond->GetMemorySize());
169  PropertyBox->item(CONSIZE)->setText(str.Data());
170 
171  TDatime now;
172  PropertyBox->item(CONTIME)->setText(now.AsSQLString());
173  ensurePolished();
174  update();
175  show();
176  raise();
178 }
virtual void ConPrintButton_clicked()
virtual void ResetWidget()
Definition: QGo4Widget.cpp:51
virtual bool IsAcceptDrag(const char *itemname, TClass *cl, int kind)
TObject * GetLinked(const char *linkname, int updatelevel)
Definition: QGo4Widget.cpp:176
virtual void linkedObjectUpdated(const char *linkname, TObject *obj)
Bool_t IsEnabled() const
Definition: TGo4Condition.h:94
virtual void GetValues(Int_t &dim, Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2)
void EditItem(const QString &itemname)
Definition: QGo4Widget.cpp:351
Bool_t FixedResult() const
TGo4ConditionInfo(QWidget *parent=0, const char *name=0)
void ServiceCall(const char *name, void *par=0)
Definition: QGo4Widget.cpp:402
static const char * Message(Int_t prio, const char *text,...)
Definition: TGo4Log.cxx:209
Bool_t IsTrue() const
virtual void ConEditButton_clicked()
virtual void RefreshWidget(TGo4Condition *cond)
virtual void DropItem(const char *itemname, TClass *cl, int kind)
virtual void WorkWithCondition(const char *itemname)
virtual void ResetWidget()
virtual void ConInfoButton_clicked()
virtual Int_t GetMemorySize()
void AddLink(const char *itemname, const char *linkname)
Definition: QGo4Widget.cpp:121
virtual Int_t TrueCounts()
virtual Int_t Counts()
static Bool_t IsAutoEnabled()
Definition: TGo4Log.cxx:386
virtual void PrintLog_clicked()