GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4EventInfo.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 "TGo4EventInfo.h"
15 #include "TTree.h"
16 #include "TGo4ServerProxy.h"
17 #include "TGo4Slot.h"
18 #include "TGo4BrowserProxy.h"
19 
20 const char *defMbsEventName = "MbsEvent101";
21 
22 TGo4EventInfo::TGo4EventInfo(QWidget *parent, const char *name)
23  : QGo4Widget(parent, name)
24 {
25  setupUi(this);
26  QObject::connect(RefreshButton, &QPushButton::clicked, this, &TGo4EventInfo::RefreshClicked);
27  QObject::connect(PrintEventButton, &QPushButton::clicked, this, &TGo4EventInfo::PrintEventClicked);
28  QObject::connect(MbsButton, &QPushButton::clicked, this, &TGo4EventInfo::MbsButton_clicked);
29  setWindowTitle("Event info");
30  ResetWidget();
31 }
32 
33 bool TGo4EventInfo::IsAcceptDrag(const char *itemname, TClass *cl, int kind)
34 {
35  return kind == TGo4Access::kndEventElement;
36 }
37 
38 void TGo4EventInfo::DropItem(const char *itemname, TClass *cl, int kind)
39 {
40  if (kind == TGo4Access::kndEventElement)
41  WorkWithEvent(itemname);
42 }
43 
44 void TGo4EventInfo::WorkWithEvent(const char *itemname)
45 {
46  EventLbl->setText(itemname);
47 
48  bool ismbs = QString(itemname).contains(defMbsEventName);
49 
50  MbsPrintBox->setEnabled(ismbs);
51  TString mbsitem = Browser()->FindItemInAnalysis(defMbsEventName);
52  MbsButton->setEnabled(!ismbs && (mbsitem.Length() > 0));
53  setFocus();
54 }
55 
57 {
59  EventLbl->setText("");
60  MbsButton->setEnabled(true);
61 // if (Browser()) {
62 // TString mbsitem = Browser()->FindItemInAnalysis(defMbsEventName);
63 // MbsButton->setEnabled(mbsitem.Length()>0);
64 // } else
65 // MbsButton->setEnabled(false);
66  MbsPrintBox->setEnabled(false);
67 }
68 
69 void TGo4EventInfo::linkedObjectUpdated(const char *linkname, TObject *obj)
70 {
71  TTree *tr = dynamic_cast<TTree *>(obj);
72  if (tr) {
73  tr->Show(0);
74  return;
75  }
76 
77  if (obj) {
78  obj->Print();
79  return;
80  }
81 }
82 
84 {
85 }
86 
87 
89 {
91 
92  if (EventLbl->text().isEmpty()) return;
93  QString evname = EventLbl->text();
94  bool isremote = RemoteButton->isChecked();
95  bool istree = TreeButton->isChecked();
96 
97  TGo4Slot *tgtslot = isremote ? nullptr : AddSlot("Event");
98 
99  TGo4BrowserProxy *br = Browser();
100  if (!br) return;
101 
102  TString objname;
103  TGo4ServerProxy *an = br->DefineAnalysisObject(evname.toLatin1().constData(), objname);
104  if (an) an->RequestEventStatus(objname.Data(), istree, tgtslot);
105 }
106 
108 {
109  if (EventLbl->text().isEmpty()) return;
110 
111  TString folder, name;
112  TGo4Slot::ProduceFolderAndName(EventLbl->text().toLatin1().constData(), folder, name);
113 
114  TGo4ServerProxy *anal = GetAnalysis(EventLbl->text().toLatin1().constData());
115 
116  if (anal)
117  anal->RemotePrintEvent(name.Data(),
118  PrintEventNum->value(),
119  PrintEventSid->value(),
120  HexBox->isChecked(),
121  LongBox->isChecked());
122 }
123 
125 {
126  TString itemname = Browser()->FindItemInAnalysis(defMbsEventName);
127 
128  // printf("Search item %s found %s\n", defMbsEventName, itemname.Data());
129 
130  if (itemname.Length() > 0)
131  WorkWithEvent(itemname.Data());
132 }
virtual void ResetWidget()
Definition: QGo4Widget.cpp:52
void ResetWidget() override
void linkedObjectUpdated(const char *linkname, TObject *obj) override
TGo4EventInfo(QWidget *parent=nullptr, const char *name=nullptr)
virtual void MbsButton_clicked()
TGo4BrowserProxy * Browser()
Definition: QGo4Widget.cpp:219
void RemoveAllLinks(bool blockreset=true)
Definition: QGo4Widget.cpp:196
void DropItem(const char *itemname, TClass *cl, int kind) override
void WorkWithEvent(const char *itemname)
void linkedObjectRemoved(const char *linkname) override
TString FindItemInAnalysis(const char *objname)
virtual void PrintEventClicked()
TGo4ServerProxy * GetAnalysis(const char *itemname=nullptr)
Definition: QGo4Widget.cpp:386
const char * defMbsEventName
virtual void RefreshClicked()
static void ProduceFolderAndName(const char *fullname, TString &foldername, TString &objectname)
Definition: TGo4Slot.cxx:646
virtual void RequestEventStatus(const char *evname, Bool_t astree, TGo4Slot *tgtslot)
bool IsAcceptDrag(const char *itemname, TClass *cl, int kind) override
TGo4ServerProxy * DefineAnalysisObject(const char *itemname, TString &analysisname)
virtual void RemotePrintEvent(const char *evname, Int_t evnumber, Int_t subid, Bool_t ishex, Bool_t islong)
TGo4Slot * AddSlot(const char *slotname)
Definition: QGo4Widget.cpp:141