17 #include <QMessageBox>
19 #include <QtCore/QSignalMapper>
45 #if QT_VERSION >= QT_VERSION_CHECK(4,6,0)
46 LCDCounts->setDigitCount(10);
47 LCDTrueCounts->setDigitCount(10);
49 LCDCounts->setNumDigits(10);
50 LCDTrueCounts->setNumDigits(10);
53 setWindowTitle(
"Condition editor");
56 parentWidget()->adjustSize();
60 CutTable->setContextMenuPolicy(Qt::CustomContextMenu);
67 if (cl==0)
return false;
68 bool res = cl->InheritsFrom(TGo4Condition::Class());
77 if (cl->InheritsFrom(TGo4Condition::Class()))
102 if (strcmp(linkname,
"Condition")==0) {
112 if (strcmp(linkname,
"Condition")==0)
121 if ((con!=0) && (con->
IsChanged()!=0) && (strcmp(conditemname,itemname)!=0)) {
123 int res = QMessageBox::warning(
this,
"Condition editor",
124 QString(
"Current condition %1 is modified!\n"
125 "New condition %2 is selected.").arg(conditemname).arg(itemname),
126 QString(
"Continue with current"),
127 QString(
"Start with new"), QString::null, 0);
133 if ((conditemname==0) || (strcmp(conditemname,itemname)!=0)) {
135 CondNameLbl->setText(itemname);
136 AddLink(itemname,
"Condition");
139 QString iconname =
":/icons/right.png";
140 QString tooltip =
"Refresh condition from analysis";
142 iconname =
":/icons/refresh.png";
143 tooltip =
"Refresh condition from source";
145 RefreshButton->setIcon( QIcon(iconname) );
146 RefreshButton->setToolTip(tooltip);
168 CondNameLbl->setText(
"");
169 CondClassLbl->setText(
"");
171 PleaseUpdateLabel->setVisible(
false);
173 ArrayAllButton->setVisible(
false);
174 ArrayElements->setVisible(
false);
176 HistogramChk->setVisible(
false);
177 HistogramChk->setChecked(
false);
178 HistogramChk->setText(
"null");
179 HistogramChk->setEnabled(
false);
181 CondVisibleChk->setVisible(
false);
182 DrawInfoLbl->setText(
"");
183 CondTabs->setEnabled(
false);
185 LCDCounts->display(0);
186 LCDTrueCounts->display(0);
188 Win1_low->setDisabled(
true);
189 Win1_up->setDisabled(
true);
190 Win2_low->setDisabled(
true);
191 Win2_up->setDisabled(
true);
193 ResultCombo->setEnabled(
false);
194 InvertCombo->setEnabled(
false);
212 PleaseUpdateLabel->setVisible(cond->
IsChanged()!=0);
217 if ((panel!=0) && (pad!=0)) {
223 if (selname==cond->GetName())
227 if (histo==0) histo =
dynamic_cast<TH1*
>(
GetLinked(
"Histogram", 0));
233 ArrayAllButton->setVisible(arr!=0);
234 ArrayElements->setVisible(arr!=0);
238 ArrayElements->setMaximum(arr->
GetNumber()-1);
246 ModifyButton->setVisible((panel!=0) && ((arr==0) || (
fiSelectedIndex>=0)));
255 CondClassLbl->setText(
"Win 2-D ");
257 CondClassLbl->setText(
"Win 1-D ");
262 CondClassLbl->setText(
"Ellipse ");
264 CondClassLbl->setText(
"Circle ");
265 else if (econd->
IsBox())
266 CondClassLbl->setText(
"Box ");
268 CondClassLbl->setText(
"Free shape ");
271 CondClassLbl->setText(
"Polygon ");
274 CondClassLbl->setText(
"");
279 if ((hname==0) || (*hname==0)) {
280 HistogramChk->setChecked(
false);
281 HistogramChk->setText(
"null");
282 HistogramChk->setEnabled(
false);
286 HistogramChk->setText(hname);
287 HistogramChk->setEnabled(
true);
289 if (hitemname.length()>0)
290 infolbl += hitemname;
296 CondVisibleChk->setVisible(
true);
297 CondVisibleChk->setChecked(cond->
IsVisible());
300 if (infolbl.length()>0) infolbl+=
" ";
301 infolbl +=
"Drawn: ";
302 infolbl += panel->objectName();
303 if ((pad!=0) && (pad!=(TPad*)panel->
GetCanvas())) {
305 infolbl += pad->GetName();
308 DrawInfoLbl->setText(infolbl);
310 CondTabs->setEnabled(
true);
312 ResultCombo->setEnabled(
true);
313 InvertCombo->setEnabled(
true);
316 ResultCombo->setCurrentIndex(0);
319 ResultCombo->setCurrentIndex(1);
321 ResultCombo->setCurrentIndex(2);
323 if(cond->
IsTrue()) InvertCombo->setCurrentIndex(0);
324 else InvertCombo->setCurrentIndex(1);
326 LCDCounts->display(cond->
Counts());
333 if ((ratio>=0.) && (ratio<=100.))
334 sratio.sprintf(
"%4.2f%s",ratio*100.,
"%");
337 PercentLabel->setText(sratio);
342 Win1_low->setText(QString::number(cond->
GetXLow()));
343 Win1_up->setText(QString::number(cond->
GetXUp()));
346 Win2_low->setText(QString::number(cond->
GetYLow()));
347 Win2_up->setText(QString::number(cond->
GetYUp()));
349 Win2_low->setText(
"");
350 Win2_up->setText(
"");
354 Win1_low->setEnabled(
true);
355 Win1_up->setEnabled(
true);
359 Win1_low->setDisabled(
true);
360 Win1_up->setDisabled(
true);
361 Win2_low->setDisabled(
true);
362 Win2_up->setDisabled(
true);
366 int oldindex = CondTabs->currentIndex();
367 CondTabs->setCurrentIndex(2);
368 CondTabs->setCurrentIndex(oldindex);
370 if ((pcond==0) && ((CondTabs->currentIndex()==1) || (CondTabs->currentIndex()==2)))
371 CondTabs->setCurrentIndex(0);
373 if ((econd==0) && (pcond!=0) && (CondTabs->currentIndex()==2))
374 CondTabs->setCurrentIndex(1);
377 CondTabs->setTabEnabled(1, (pcond!=0));
378 CondTabs->setTabEnabled(2, (econd!=0));
409 IntBox->setText(QString(
"Integr: ") + QString::number(cond->
GetIntegral(histo,
"")));
410 MaxXBox->setText(QString(
"MaxX: ") + QString::number(cond->
GetXMax(histo)));
411 MaxYBox->setText(QString(
"MaxY: ") + QString::number(cond->
GetYMax(histo)));
412 MaxCBox->setText(QString(
"Max: ") + QString::number(cond->
GetCMax(histo)));
414 XMeanBox->setText(QString(
"XMean: ") + QString::number(cond->
GetMean(histo, 1)));
415 XRMSBox->setText(QString(
"XRMS: ") + QString::number(cond->
GetRMS(histo, 1)));
416 YMeanBox->setText(QString(
"YMean: ") + QString::number(cond->
GetMean(histo, 2)));
417 YRMSBox->setText(QString(
"YRMS: ") + QString::number(cond->
GetRMS(histo, 2)));
424 if ((panel==0) && HistogramChk->isChecked() &&
434 if (cond==0)
return 0;
443 if (fiSelectedIndex<arr->GetNumber())
456 PleaseUpdateLabel->setVisible(
true);
471 ArrayElements->setValue(-1);
479 case 0: cond->
Enable();
break;
480 case 1: cond->
Disable(kTRUE);
break;
481 case 2: cond->
Disable(kFALSE );
break;
482 default: cond->
Enable();
break;
500 if ((con==0) || (conditemname==0))
return;
530 bool okx1, okx2, res =
false;
531 Double_t x1 = Win1_low->text().toDouble(&okx1);
532 Double_t x2 = Win1_up->text().toDouble(&okx2);
536 Double_t y1 = Win2_low->text().toDouble(&oky1);
537 Double_t y2 = Win2_up->text().toDouble(&oky2);
538 if (okx1 && okx2 && oky1 && oky2) {
689 if (conditemname==0)
return;
695 DrawItem(conditemname, panel, 0,
false, 0);
720 const char* hname = 0;
729 panel =
DrawItem(hitemname.Data(), 0);
731 AddLink(hitemname.Data(),
"Histogram");
732 DrawItem(conditemname, panel, 0,
false, 0);
743 if (conditemname==0)
return;
749 if (panel==0)
return;
765 cond->
Print(
"go4log-limits-stats");
772 if (cond==0)
return false;
777 if ((hname!=0) && (strlen(hname)!=0)) {
778 TString foldername, objname;
794 if ((panel==0) || (pad==0))
return;
811 CutTable->setRowCount(0);
812 NPointsSpin->setValue(0);
814 CutTable->setRowCount(cut->GetN());
815 NPointsSpin->setValue(cut->GetN());
816 for (
int n=0;n<cut->GetN();n++) {
818 cut->GetPoint(n, x,y);
819 CutTable->setItem(n, 0,
new QTableWidgetItem(QString::number(x)));
820 CutTable->setItem(n, 1,
new QTableWidgetItem(QString::number(y)));
821 CutTable->setVerticalHeaderItem(n,
new QTableWidgetItem(QString::number(n)));
833 double a1=0,a2=0,x=0,y=0;
837 elli-> GetCenter(x,y);
840 EllipseCxSpinbox->setValue(x);
841 EllipseCySpinbox->setValue(y);
842 EllipseA1Spinbox->setValue(a1);
843 EllipseA2Spinbox->setValue(a2);
844 EllipseTiltDial->setValue(theta);
845 EllipseTiltEdit->setText(QString::number(theta));
847 CircleBox->setChecked(elli->
IsCircle());
848 EllipseBox->setChecked(elli->
IsEllipse());
849 BoxshapeBox->setChecked(elli->
IsBox());
859 EllipseCxSpinbox->setVisible(show);
860 EllipseCySpinbox->setVisible(show);
861 EllipseA1Spinbox->setVisible(show);
862 EllipseA2Spinbox->setVisible(show);
863 EllipseTiltDial->setVisible(show);
864 EllipseTiltEdit->setVisible(show);
866 ShapegroupBox->setVisible(show);
867 CircleBox->setVisible(show);
868 EllipseBox->setVisible(show);
869 BoxshapeBox->setVisible(show);
870 FreeshapeBox->setVisible(show);
871 EllipseNptsSpin->setVisible(show);
873 AutoRefreshBox->setVisible(show);
874 EllipseCenterLabel->setVisible(show);
875 EllipseTitlLabel->setVisible(show);
876 EllipseRadiusLabel->setVisible(show);
877 EllipseNptsLabel->setVisible(show);
878 EllipsCxLabel->setVisible(show);
879 EllipsCyLabel->setVisible(show);
880 EllipsA1Label->setVisible(show);
881 EllipsA2Label->setVisible(show);
883 verticalLayout_2->setEnabled(show);
884 verticalLayout_5->setEnabled(show);
885 horizontalLayout_4->setEnabled(show);
895 if (pcond==0)
return;
897 TCutG* cut = pcond->
GetCut(kFALSE);
900 cut =
new TCutG(
"conditioncut", npoint);
902 for (
int n=0;n<npoint-1; n++)
903 cut->SetPoint(n, n*10, n*10);
904 cut->GetPoint(0, x, y);
905 cut->SetPoint(npoint-1, x, y);
912 int old = cut->GetN();
914 if (old>1) cut->GetPoint(old-2, x, y);
916 for(
int n= (old-1>=0 ? old-1 : 0); n<npoint-1; n++)
917 cut->SetPoint(n, x, y+(n-old+2)*10);
918 cut->GetPoint(0, x, y);
919 cut->SetPoint(npoint-1, x, y);
935 TCutG* cut = pcond==0 ? 0 : pcond->
GetCut(kFALSE);
939 double zn = CutTable->item(nrow, ncol)->text().toDouble(&ok);
942 if (ncol==0) cut->GetX()[nrow] = zn;
943 else cut->GetY()[nrow] = zn;
944 if ((nrow==0) || (nrow==cut->GetN()-1)) {
945 int nrow1 = (nrow==0) ? cut->GetN()-1 : 0;
947 CutTable->setItem(nrow1, ncol,
new QTableWidgetItem(CutTable->item(nrow, ncol)->text()));
948 if (ncol==0) cut->GetX()[nrow1] = zn;
949 else cut->GetY()[nrow1] = zn;
963 QTableWidgetItem* item = CutTable->itemAt (pos);
966 TCutG* cut = pcond==0 ? 0 : pcond->
GetCut(kFALSE);
967 if ((cut==0) || (item==0))
return;
969 int nrow = CutTable->row(item);
972 QSignalMapper map(
this);
975 AddIdAction(&menu, &map,
"Delete point", nrow+1000000, (nrow>0) && (nrow<cut->GetN()-1));
977 menu.exec(CutTable->mapToGlobal(pos));
983 TCutG* cut = pcond==0 ? 0 : pcond->
GetCut(kFALSE);
988 cut->RemovePoint(
id);
990 Int_t npoints = cut->GetN();
991 if (
id>=npoints)
return;
996 for(
int n=npoints;n>id;n--) {
997 cut->GetPoint(n-1, x, y);
998 cut->SetPoint(n, x, y);
1003 cut->GetPoint(
id-1, x1, y1);
1004 cut->SetPoint(
id, (x1+x)/2., (y+y1)/2.);
1021 EllipseTiltEdit->setText(QString::number(deg));
1025 if(econd) econd->
SetTheta((
double) deg);
1041 double y=EllipseCySpinbox->value();
1056 double x=EllipseCxSpinbox->value();
1106 Int_t theta = EllipseTiltEdit->text().toInt(&ok);
1107 if(theta<0) theta=0;
1108 theta = theta % 360;
1111 EllipseTiltDial->setValue(theta);
1130 std::cout <<
"UpdateEllipse did not find ellipse condition!!!"<< std::endl;
1136 if (FreeshapeBox->isChecked())
1142 double cx = EllipseCxSpinbox->value();
1143 double cy = EllipseCySpinbox->value();
1144 double a1 = EllipseA1Spinbox->value();
1145 double a2 = EllipseA2Spinbox->value();
1146 double th = EllipseTiltDial->value();
1155 TCutG* cut=econd->
GetCut(
false);
1156 Int_t n = cut->GetN();
1157 Double_t* xarr=cut->GetX();
1158 Double_t* yarr=cut->GetY();
1160 for (
int i=0; i<n; ++i)
1162 rarr[i]= TMath::Sqrt(TMath::Power((xarr[i]-cx),2) + TMath::Power((yarr[i]-cy),2));
1164 Int_t nrmax=TMath::LocMax(n,rarr.GetArray());
1165 Int_t nrmin=TMath::LocMin(n,rarr.GetArray());
1171 th= TMath::ACos((econd->
GetXUp() - cx)/a1) * 180/TMath::Pi();
1176 if (CircleBox->isChecked())
1177 econd->
SetCircle(cx, cy, a1, EllipseNptsSpin->value());
1178 else if (EllipseBox->isChecked())
1179 econd->
SetEllipse(cx, cy, a1, a2, th, EllipseNptsSpin->value());
1180 else if (BoxshapeBox->isChecked())
1190 econd->
SetBox(cx, cy, a1, a2, th);
virtual void ShootRepaintTimer()
void SetTheta(Double_t angle)
virtual Bool_t IsYRMSDraw()
virtual void SetYMeanDraw(bool on)
virtual void SetChanged(Bool_t on)
virtual void LimitsReturnPressed()
void GetRadius(Double_t &a1, Double_t &a2)
virtual Bool_t IsLabelDraw()
void SetEllipse(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta=0, Int_t npoints=0)
virtual void enterEvent(QEvent *)
virtual Double_t GetXUp()
virtual Double_t GetXMax(TH1 *histo)
virtual Double_t GetMean(TH1 *histo, Int_t axis=1)
virtual const char * GetDrawObjectLinkName(TPad *pad, TObject *obj)
virtual void SetLimitsDraw(Bool_t on)
virtual void SelectedCond(int t)
virtual void RefreshWidget(bool checkindex)
virtual void SetActivePad(TPad *pad)
virtual void PrintConditionLog()
virtual Double_t GetCMax(TH1 *histo)
virtual void ClearCounters()
virtual QString GetSelectedMarkerName(TPad *pad)
virtual void StartConditionEditing(TPad *pad)
virtual Int_t IsChanged()
virtual void SetXMeanDraw(bool on)
virtual void leaveEvent(QEvent *)
virtual void SetYRMSDraw(Bool_t on)
virtual void SetChangeFlag(bool changed)
virtual void EllipseTheta_valueChanged(int deg)
virtual Bool_t IsXMeanDraw()
virtual void PrintCondition(Bool_t full=kTRUE)
virtual bool PrepareForAnalysis()
virtual Bool_t IsLimitsDraw()
virtual void DisplayPressed()
virtual void EllipseNPoints_valueChanged(int npoint)
virtual void ResetWidget()
TGo4ServerProxy * DefineServerObject(const char *itemname, TString *objname=0, Bool_t onlyanalysis=kTRUE)
virtual Bool_t IsYMeanDraw()
virtual Double_t GetYUp()
virtual void EllipseA1_valueChanged(double r1)
virtual void SetVisible(Bool_t on)
virtual TGo4Condition * SelectedCondition()
virtual void SetYRMSDraw(bool on)
virtual void SetXMaxDraw(Bool_t on)
void SetCenter(Double_t x, Double_t y)
virtual void SetYMaxDraw(bool on)
virtual void ChangeConditionProperty(int id, bool on)
virtual void SetIntDraw(bool on)
virtual void ShowEllipseWidget(bool show)
virtual void linkedObjectRemoved(const char *linkname)
virtual Bool_t IsIntDraw()
virtual void ResetCounts()
virtual Bool_t IsXRMSDraw()
virtual void ClearAnalysisObject(const char *fullpath)
Bool_t FixedResult() const
virtual void LimitsChanged(const QString &)
virtual void EllipseCircleBox_toggled(bool on)
virtual void SetYMaxDraw(Bool_t on)
virtual bool IsAcceptDrag(const char *itemname, TClass *cl, int kind)
virtual void SetValues(Double_t *x, Double_t *y, Int_t len)
virtual void SetInvertMode(int mode)
TCutG * GetCut(Bool_t changeowner)
virtual void RedrawCondition()
virtual void ModifyButton_clicked()
virtual Double_t GetYUp()
virtual Bool_t IsXMaxDraw()
virtual void SetSelectedMarker(TPad *pad, const QString &selname, int selindex)
virtual Bool_t IsVisible()
virtual void ContextMenuSlot(int)
virtual void SetIntDraw(Bool_t on)
virtual void MarkPadModified(TPad *pad)
virtual void EllipseCy_valueChanged(double y)
virtual void Print(Option_t *opt="") const
virtual void DrawCondition(bool useactive)
void SetCircle(Double_t cx, Double_t cy, Double_t r, Int_t npoints=0)
virtual void SetCMaxDraw(bool on)
bool fbEllipseAutoRefresh
virtual bool UpdateLimits()
virtual void SetYMeanDraw(Bool_t on)
virtual TPad * FindPadWithItem(const char *itemname)
void SetHistogram(const char *name)
virtual void SetXRMSDraw(bool on)
virtual void Disable(Bool_t result)
virtual Bool_t CanSubmitObjects()
Bool_t DefineRelatedObject(const char *itemname, const char *objectname, TString &objectitem, Int_t mask=3)
TGo4ConditionEditor(QWidget *parent=0, const char *name=0)
virtual void FillCutWidget(TCutG *cut)
virtual int GetSelectedMarkerIndex(TPad *pad)
void SetMultiEdit(Bool_t on)
virtual void CutTable_valueChanged(int ncol, int nrow)
virtual Double_t GetXLow()
virtual void SetXMeanDraw(Bool_t on)
virtual void UpdatePressed()
virtual void UpdateEllipse()
virtual void RefreshClicked()
virtual void EllipseRefreshBox_toggled(bool on)
static void ProduceFolderAndName(const char *fullname, TString &foldername, TString &objectname)
virtual void EllipseTheta_returnPressed()
virtual void EllipseA2_valueChanged(double r2)
virtual TH1 * GetPadHistogram(TPad *pad)
virtual void FillEllipseWidget(TGo4ShapedCond *elli)
virtual void EllipseCx_valueChanged(double x)
virtual Double_t GetYMax(TH1 *histo)
virtual void SetLabelDraw(Bool_t on)
virtual void SetDrawLimits(bool on)
virtual void SetLabel(bool on)
virtual void PleaseUpdateSlot()
TGo4ServerProxy * DefineAnalysisObject(const char *itemname, TString &analysisname)
virtual void SetXMaxDraw(bool on)
virtual void NPointsSpin_valueChanged(int npoint)
TGo4Condition * At(Int_t i)
virtual Double_t GetXUp()
virtual Double_t GetRMS(TH1 *histo, Int_t axis=1)
virtual void SetResultMode(int mode)
virtual void SetCurrentIndex(Int_t ix)
void SetBox(Double_t cx, Double_t cy, Double_t a1, Double_t a2, Double_t theta=0)
const char * GetLinkedHistogram()
virtual void SetCondVisible(bool on)
virtual Int_t TrueCounts()
virtual void linkedObjectUpdated(const char *linkname, TObject *obj)
virtual Bool_t IsCMaxDraw()
virtual void SetXRMSDraw(Bool_t on)
virtual TPad * GetActivePad()
virtual Double_t GetXLow()
virtual void CutTable_contextMenuRequested(const QPoint &)
virtual void DropItem(const char *itemname, TClass *cl, int kind)
virtual TCanvas * GetCanvas()
virtual void SaveCondition()
virtual Bool_t IsYMaxDraw()
virtual void WorkWithCondition(const char *itemname)
virtual Double_t GetIntegral(TH1 *histo, Option_t *opt="")
virtual void Invert(Bool_t on)
virtual void SetCMaxDraw(Bool_t on)
virtual Double_t GetYLow()
virtual Double_t GetYLow()