GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4ConditionInfo.cpp
Go to the documentation of this file.
1 // $Id$
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, &QPushButton::clicked, this, &TGo4ConditionInfo::ConInfoButton_clicked);
28  QObject::connect(ConPrintButton, &QPushButton::clicked, this, &TGo4ConditionInfo::ConPrintButton_clicked);
29  QObject::connect(ConEditButton, &QPushButton::clicked, this, &TGo4ConditionInfo::ConEditButton_clicked);
30  QObject::connect(PrintLog, &QPushButton::clicked, this, &TGo4ConditionInfo::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 ? false : cl->InheritsFrom(TGo4Condition::Class());
39 }
40 
41 void TGo4ConditionInfo::DropItem(const char *itemname, TClass *cl, int kind)
42 {
43  if (!cl) 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, "%s", 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  auto cond = GetLinkedCast<TGo4Condition>("Condition", 2);
109 
110  RefreshWidget(cond);
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) 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())
165  str = "test enabled";
166  else if(cond->FixedResult())
167  str = "always true";
168  else
169  str = "always false";
170  if(cond->IsTrue()) str += " - regular";
171  else str += " - inverse";
172  PropertyBox->item(CONMODE)->setText(str.Data());
173 
174  str.Form("size:%d b",cond->GetMemorySize());
175  PropertyBox->item(CONSIZE)->setText(str.Data());
176 
177  TDatime now;
178  PropertyBox->item(CONTIME)->setText(now.AsSQLString());
179  ensurePolished();
180  update();
181  show();
182  raise();
184 }
virtual void ConPrintButton_clicked()
virtual void ResetWidget()
Definition: QGo4Widget.cpp:52
bool IsAcceptDrag(const char *itemname, TClass *cl, int kind) override
void ServiceCall(const char *name, void *par=nullptr)
Definition: QGo4Widget.cpp:398
void EditItem(const QString &itemname)
Definition: QGo4Widget.cpp:345
void GetValues(Int_t &dim, Double_t &x1, Double_t &y1, Double_t &x2, Double_t &y2) override
static const char * Message(Int_t prio, const char *text,...) GO4_PRINTF2_ARGS
Definition: TGo4Log.cxx:206
virtual Int_t GetMemorySize() const
void DropItem(const char *itemname, TClass *cl, int kind) override
TGo4ConditionInfo(QWidget *parent=nullptr, const char *name=nullptr)
virtual void ConEditButton_clicked()
virtual void RefreshWidget(TGo4Condition *cond)
void ResetWidget() override
virtual void WorkWithCondition(const char *itemname)
virtual void ConInfoButton_clicked()
Bool_t IsEnabled() const
Definition: TGo4Condition.h:82
void linkedObjectUpdated(const char *linkname, TObject *obj) override
void AddLink(const char *itemname, const char *linkname)
Definition: QGo4Widget.cpp:117
Bool_t FixedResult() const
Int_t GetDimension() const
virtual Int_t TrueCounts()
virtual Int_t Counts()
static Bool_t IsAutoEnabled()
Definition: TGo4Log.cxx:378
virtual void PrintLog_clicked()
Bool_t IsTrue() const