18 #include <QMessageBox>
19 #include <QFileDialog>
21 #include <QHeaderView>
25 #include "TObjArray.h"
28 #include "TDataMember.h"
29 #include "TDataType.h"
30 #include "TBaseClass.h"
31 #include "TGo4LockGuard.h"
46 PleaseUpdateLabel->setVisible(
false);
47 parentWidget()->adjustSize();
49 ParamNameLbl->setText(
"");
50 ParamClassLbl->setText(
"");
54 MemberTable->setContextMenuPolicy(Qt::CustomContextMenu);
55 MemberTable->horizontalHeader()->setStretchLastSection(
true);
70 return (cl==0) ?
false : cl->InheritsFrom(TGo4Parameter::Class());
76 ((cl!=0) && cl->InheritsFrom(TGo4Parameter::Class())))
82 if (strcmp(linkname,
"Parameter")==0)
85 if (strcmp(linkname,
"ParStatus")==0)
93 if (strcmp(linkname,
"Fitter")!=0)
99 if (PleaseUpdateLabel->isVisible() && !isrefresh) {
102 if ((par!=0) && (previtem!=0)) {
103 int res = QMessageBox::warning(
this,
"Parameter editor",
104 QString(
"Current parameter %1 is modified!\n"
105 "New parameter %2 is selected.").arg(previtem).arg(itemname),
106 QString(
"Continue with current"),
107 QString(
"Start with new"), QString::null, 0);
116 ParamNameLbl->setText(itemname);
120 QString iconname =
":/icons/right.png";
121 QString tooltip =
"Refresh parameter values from analysis";
128 AddLink(itemname,
"ParameterLock");
130 iconname =
":/icons/refresh.png";
131 tooltip =
"Refresh parameter values from source";
132 AddLink(itemname,
"Parameter");
137 RefreshButton->setIcon(QIcon(iconname));
138 RefreshButton->setToolTip(tooltip);
147 ParamNameLbl->setText(
"");
148 ParamClassLbl->setText(
"");
152 RefreshButton->setEnabled(
false);
153 ApplyButton->setEnabled(
false);
160 PleaseUpdateLabel->setVisible(
false);
165 RefreshButton->setEnabled(par!=0);
166 ApplyButton->setEnabled(par!=0);
169 fItems =
new TObjArray(100);
174 ParamClassLbl->setText(QString(
" - ")+par->ClassName());
179 PleaseUpdateLabel->setVisible(
false);
185 RefreshButton->setEnabled(status!=0);
196 ParamClassLbl->setText(QString(
" - ") + status->
GetObjectClass());
201 PleaseUpdateLabel->setVisible(
false);
207 MemberTable->setRowCount(0);
215 MemberTable->horizontalHeaderItem(
fiColType)->setText(
"Type");
216 MemberTable->horizontalHeaderItem(
fiColName)->setText(
"Name");
217 MemberTable->horizontalHeaderItem(
fiColValue)->setText(
"Value");
218 MemberTable->horizontalHeaderItem(
fiColComment)->setText(
"Comments");
220 int memnum =
fItems->GetLast()+1;
221 MemberTable->setRowCount(memnum);
223 MemberTable->verticalHeader()->hide();
225 int ih=QApplication::fontMetrics().height();
227 for(
int row=0; row<memnum; row++) {
228 MemberTable->setRowHeight(row, ih);
231 QTableWidgetItem* item =
new QTableWidgetItem(info->
GetTypeName());
232 item->setFlags(item->flags() & ~
Qt::ItemIsEditable);
233 MemberTable->setItem(row,
fiColType, item);
235 item =
new QTableWidgetItem(info->
GetFullName(buf));
236 item->setFlags(item->flags() & ~
Qt::ItemIsEditable);
237 MemberTable->setItem(row,
fiColName, item);
241 item->setFlags(item->flags() | Qt::ItemIsEditable);
243 item->setFlags(item->flags() & ~ Qt::ItemIsEditable);
246 item =
new QTableWidgetItem(info->GetTitle());
247 item->setFlags(item->flags() & ~
Qt::ItemIsEditable);
250 MemberTable->setRowHidden(row, !info->
IsVisible());
267 for(
int n=0;n<=
fItems->GetLast();n++) {
272 PleaseUpdateLabel->setVisible(
true);
280 QString txt = MemberTable->item(row, col)->text();
283 PleaseUpdateLabel->setVisible(
true);
305 QTableWidgetItem* item = MemberTable->itemAt (pnt);
307 if ((item==0) || (MemberTable->column(item) !=
fiColName))
return;
309 int row = MemberTable->row(item);
315 QMenu contextMenu(
this );
316 contextMenu.addAction(
"Array View");
318 if (row<fItems->GetLast()) {
321 contextMenu.addAction(
"++ \t(next index)",
this, SLOT(
IncArrayIndex()));
327 contextMenu.addAction(
"-- \t(prev index)",
this, SLOT(
DecArrayIndex()));
331 contextMenu.exec(QCursor::pos());
336 QMenu contextMenu(
this );
337 contextMenu.addAction(
"Modify Fitter");
339 contextMenu.addAction(
"Edit...",
this, SLOT(
EditFitter()));
343 if ((fitter!=0) && (info->
GetObject()!=fitter))
345 contextMenu.exec(QCursor::pos());
354 for(
int n=0;n<=
fItems->GetLast();n++) {
393 fitter=
new TGo4Fitter(
"Fitter",
"Fitter from parameter editor");
400 PleaseUpdateLabel->setVisible(
true);
411 if (fitter!=0) info->
SetObject(fitter, kTRUE);
425 PleaseUpdateLabel->setVisible(
false);
429 if (parclass==0)
return;
430 if (gROOT->GetClass(parclass)==0) {
431 QMessageBox::warning(
this,
"Parameter editor",
432 QString(
"Parameter class ") + parclass +
" not known to gui");
435 TString foldname, parname;
443 QMessageBox::warning(
this,
"Parameter editor",
444 QString(
"Can not crate parameter object of class ") + parclass);
448 QFileDialog fd(
this, QString(
"Save ") +
fItemName +
" in root file",
449 QString(),
"ROOT (*.root);;ROOT XML (*.xml)");
450 fd.setFileMode( QFileDialog::AnyFile);
451 fd.setAcceptMode(QFileDialog::AcceptSave);
452 fd.selectFile(
"file.root");
453 if (fd.exec() != QDialog::Accepted)
return;
455 QStringList flst = fd.selectedFiles();
456 if (flst.isEmpty())
return;
458 TFile* f = TFile::Open(flst[0].toLatin1().constData(),
"UPDATE");
460 f->WriteTObject(par, par->GetName(),
"WriteDelete") > 0;
477 TString foldname, parname;
481 if (parclass==0)
return;
489 PleaseUpdateLabel->setVisible(
false);
TObject * GetObject() const
virtual void linkedObjectRemoved(const char *linkname)
virtual void DropItem(const char *itemname, TClass *cl, int kind)
const char * GetFullName(TString &buf)
virtual void ChangedTable(int row, int col)
virtual void GetFitterFromEditor()
TGo4ServerProxy * DefineServerObject(const char *itemname, TString *objname=0, Bool_t onlyanalysis=kTRUE)
virtual void ApplyClicked()
virtual void WorkWithParameter(const char *itemname, bool isrefresh)
Bool_t CanStrEdit() const
virtual void RefreshWidget(TGo4Parameter *par)
void SetStrValue(const char *value)
TObjArray * GetMemberValues(Bool_t takeit=kFALSE)
virtual void linkedObjectUpdated(const char *linkname, TObject *obj)
void SetObject(TObject *obj, Bool_t owner)
Bool_t IsArrayItem() const
TGo4ParaEdit(QWidget *parent=0, const char *name=0)
void RequestObjectStatus(const char *name, TGo4Slot *tgtslot)
const char * ItemClassName(const char *name)
virtual Bool_t CanSubmitObjects()
virtual void clearTextFields()
Bool_t SetMemberValues(TObjArray *fItems)
virtual void ExpandShrinkArray()
const char * GetObjectClass() const
const char * GetStrValue() const
static void ProduceFolderAndName(const char *fullname, TString &foldername, TString &objectname)
virtual void EditFitter()
virtual void IncArrayIndex()
Bool_t AssignObject(TObject *obj, Bool_t owner)
const char * GetTypeName() const
void SetVisible(Bool_t on=kTRUE)
virtual void TableDoubleClick(int row, int col)
virtual bool IsAcceptDrag(const char *itemname, TClass *cl, int kind)
Int_t GetMemberId() const
virtual void DecArrayIndex()
virtual void ShowVisibleItems()
virtual void RefreshClicked()
Bool_t IsFitterItem() const
virtual void ResetWidget()
virtual void ContextMenu(const QPoint &)
void GetMemberValues(TObjArray *fItems)