GSI Object Oriented Online Offline (Go4)  GO4-6.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4ConditionInfo.cpp
Go to the documentation of this file.
1 // $Id: TGo4ConditionInfo.cpp 3120 2021-03-30 07:42:45Z 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 fuer 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 
19 #include "TGo4Log.h"
20 #include "TGo4WinCond.h"
21 
22 TGo4ConditionInfo::TGo4ConditionInfo(QWidget *parent, const char* name)
23  : QGo4Widget(parent, name)
24 {
25  setupUi(this);
26 
27  QObject::connect(ConInfoButton, SIGNAL(clicked()), this, SLOT(ConInfoButton_clicked()));
28  QObject::connect(ConPrintButton, SIGNAL(clicked()), this, SLOT(ConPrintButton_clicked()));
29  QObject::connect(ConEditButton, SIGNAL(clicked()), this, SLOT(ConEditButton_clicked()));
30  QObject::connect(PrintLog, SIGNAL(clicked()), this, SLOT(PrintLog_clicked()));
31 
32  setWindowTitle("Condition Info:");
33 }
34 
35 
36 bool TGo4ConditionInfo::IsAcceptDrag(const char* itemname, TClass* cl, int kind)
37 {
38  return cl==0 ? false : cl->InheritsFrom(TGo4Condition::Class());
39 }
40 
41 void TGo4ConditionInfo::DropItem(const char* itemname, TClass* cl, int kind)
42 {
43  if (cl==0) return;
44  if (cl->InheritsFrom(TGo4Condition::Class()))
45  WorkWithCondition(itemname);
46 }
47 
48 void TGo4ConditionInfo::linkedObjectUpdated(const char* linkname, TObject* obj)
49 {
50  if (strcmp(linkname,"Condition")==0)
51  RefreshWidget(dynamic_cast<TGo4Condition*>(obj));
52 }
53 
54 
56 {
57  WorkWithCondition(CondnameLbl->text().toLatin1().constData());
58 }
59 
61 {
62  ServiceCall("PrintAnalysisConditions");
63 }
64 
66 {
67  EditItem(CondnameLbl->text());
68 }
69 
71 {
72  QString textbuffer;
73  textbuffer="Condition ";
74  textbuffer+=CondnameLbl->text();
75  textbuffer+=" Status: \n ";
76  textbuffer+="Title: ";
77  textbuffer+=PropertyBox->item(CONTITLE)->text();
78  textbuffer+=" Class: ";
79  textbuffer+=PropertyBox->item(CONCLASS)->text();
80  textbuffer+=" ";
81  textbuffer+=PropertyBox->item(CONDIM)->text();
82  textbuffer+=" ";
83  textbuffer+=PropertyBox->item(CONMODE)->text();
84  textbuffer+="\n ";
85  textbuffer+=PropertyBox->item(CONX)->text();
86  textbuffer+=" ";
87  textbuffer+=PropertyBox->item(CONY)->text();
88  textbuffer+="\n ";
89  textbuffer+=PropertyBox->item(CONCOUNTS)->text();
90  textbuffer+=" ";
91  textbuffer+=PropertyBox->item(CONRESULT)->text();
92  textbuffer+="\n ";
93  textbuffer+=PropertyBox->item(CONSIZE)->text();
94  textbuffer+=" Status received at: ";
95  textbuffer+=PropertyBox->item(CONTIME)->text();
96 
97  TGo4Log::Message(1, textbuffer.toLatin1().constData());
98 }
99 
100 void TGo4ConditionInfo::WorkWithCondition(const char* itemname)
101 {
102  ResetWidget();
103 
104  CondnameLbl->setText(itemname);
105 
106  AddLink(itemname, "Condition");
107 
108  TObject* obj = GetLinked("Condition", 2);
109 
110  RefreshWidget(dynamic_cast<TGo4Condition*>(obj));
111 
112  setFocus();
113 }
114 
116 {
118  PropertyBox->item(CONTITLE)->setText("Title");
119  PropertyBox->item(CONCLASS)->setText("Class:");
120  PropertyBox->item(CONX)->setText("X Testrange");
121  PropertyBox->item(CONY)->setText("Y Testrange");
122  PropertyBox->item(CONDIM)->setText("Dimension");
123  PropertyBox->item(CONCOUNTS)->setText("Counts");
124  PropertyBox->item(CONRESULT)->setText("Result");
125  PropertyBox->item(CONMODE)->setText("Test mode");
126  PropertyBox->item(CONSIZE)->setText("Size");
127  TDatime now;
128  PropertyBox->item(CONTIME)->setText(now.AsSQLString());
129  ensurePolished();
130  update();
131  show();
132  raise();
133 }
134 
136 {
137  if(cond==0) return;
138 
139  TString str;
140  PropertyBox->item(CONTITLE)->setText(cond->GetTitle());
141  PropertyBox->item(CONCLASS)->setText(cond->ClassName());
142  int dimension = 0;
143  if(cond->InheritsFrom(TGo4WinCond::Class())) {
144  TGo4WinCond* wcon = (TGo4WinCond*) cond;
145  double xmin, xmax, ymin, ymax;
146  wcon->GetValues(dimension, xmin, xmax, ymin, ymax);
147  str.Form("X: [%.1f,%.1f]",xmin, xmax);
148  PropertyBox->item(CONX)->setText(str.Data());
149  str.Form("Y: [%.1f,%.1f]",ymin, ymax);
150  PropertyBox->item(CONY)->setText(str.Data());
151  } else {
152  PropertyBox->item(CONX)->setText("X:-");
153  PropertyBox->item(CONY)->setText("Y:-");
154  dimension=cond->GetDimension();
155  }
156 
157  str.Form("Dim:%d", dimension);
158  PropertyBox->item(CONDIM)->setText(str.Data());
159  str.Form("Counts:%d", cond->Counts());
160  PropertyBox->item(CONCOUNTS)->setText(str.Data());
161  str.Form("True:%d",cond->TrueCounts());
162  PropertyBox->item(CONRESULT)->setText(str.Data());
163 
164  if(cond->IsEnabled()) str = "test enabled"; else
165  if(cond->FixedResult()) str = "always true";
166  else str = "always false";
167  if(cond->IsTrue()) str += " - regular";
168  else str += " - inverse";
169  PropertyBox->item(CONMODE)->setText(str.Data());
170 
171  str.Form("size:%d b",cond->GetMemorySize());
172  PropertyBox->item(CONSIZE)->setText(str.Data());
173 
174  TDatime now;
175  PropertyBox->item(CONTIME)->setText(now.AsSQLString());
176  ensurePolished();
177  update();
178  show();
179  raise();
181 }
virtual void ConPrintButton_clicked()
virtual void ResetWidget()
Definition: QGo4Widget.cpp:52
virtual bool IsAcceptDrag(const char *itemname, TClass *cl, int kind)
TObject * GetLinked(const char *linkname, int updatelevel)
Definition: QGo4Widget.cpp:177
Int_t GetDimension()
virtual void linkedObjectUpdated(const char *linkname, TObject *obj)
Bool_t IsEnabled() const
Definition: TGo4Condition.h:82
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:352
Bool_t FixedResult() const
TGo4ConditionInfo(QWidget *parent=0, const char *name=0)
void ServiceCall(const char *name, void *par=0)
Definition: QGo4Widget.cpp:405
static const char * Message(Int_t prio, const char *text,...)
Definition: TGo4Log.cxx:207
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:122
virtual Int_t TrueCounts()
virtual Int_t Counts()
static Bool_t IsAutoEnabled()
Definition: TGo4Log.cxx:382
virtual void PrintLog_clicked()