Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4ConditionInfo.h"
00015
00016 #include "TClass.h"
00017 #include "TDatime.h"
00018 #include "TH1.h"
00019 #include "TGo4Log.h"
00020 #include "TGo4Condition.h"
00021 #include "TGo4WinCond.h"
00022
00023
00024
00025 TGo4ConditionInfo::TGo4ConditionInfo(QWidget *parent, const char* name)
00026 : QGo4Widget(parent, name)
00027 {
00028 setupUi(this);
00029 setWindowTitle("Condition Info:");
00030 }
00031
00032
00033 bool TGo4ConditionInfo::IsAcceptDrag(const char* itemname, TClass* cl, int kind)
00034 {
00035 return cl==0 ? false : cl->InheritsFrom(TGo4Condition::Class());
00036 }
00037
00038 void TGo4ConditionInfo::DropItem(const char* itemname, TClass* cl, int kind)
00039 {
00040 if (cl==0) return;
00041 if (cl->InheritsFrom(TGo4Condition::Class()))
00042 WorkWithCondition(itemname);
00043 }
00044
00045 void TGo4ConditionInfo::linkedObjectUpdated(const char* linkname, TObject* obj)
00046 {
00047 if (strcmp(linkname,"Condition")==0)
00048 RefreshWidget(dynamic_cast<TGo4Condition*>(obj));
00049 }
00050
00051
00052 void TGo4ConditionInfo::ConInfoButton_clicked()
00053 {
00054 WorkWithCondition(CondnameLbl->text().toLatin1().constData());
00055 }
00056
00057 void TGo4ConditionInfo::ConPrintButton_clicked()
00058 {
00059 ServiceCall("PrintAnalysisConditions");
00060 }
00061
00062 void TGo4ConditionInfo::ConEditButton_clicked()
00063 {
00064 EditItem(CondnameLbl->text());
00065 }
00066
00067 void TGo4ConditionInfo::PrintLog_clicked()
00068 {
00069 QString textbuffer;
00070 textbuffer="Condition ";
00071 textbuffer+=CondnameLbl->text();
00072 textbuffer+=" Status: \n ";
00073 textbuffer+="Title: ";
00074 textbuffer+=PropertyBox->item(CONTITLE)->text();
00075 textbuffer+=" Class: ";
00076 textbuffer+=PropertyBox->item(CONCLASS)->text();
00077 textbuffer+=" ";
00078 textbuffer+=PropertyBox->item(CONDIM)->text();
00079 textbuffer+=" ";
00080 textbuffer+=PropertyBox->item(CONMODE)->text();
00081 textbuffer+="\n ";
00082 textbuffer+=PropertyBox->item(CONX)->text();
00083 textbuffer+=" ";
00084 textbuffer+=PropertyBox->item(CONY)->text();
00085 textbuffer+="\n ";
00086 textbuffer+=PropertyBox->item(CONCOUNTS)->text();
00087 textbuffer+=" ";
00088 textbuffer+=PropertyBox->item(CONRESULT)->text();
00089 textbuffer+="\n ";
00090 textbuffer+=PropertyBox->item(CONSIZE)->text();
00091 textbuffer+=" Status received at: ";
00092 textbuffer+=PropertyBox->item(CONTIME)->text();
00093
00094 TGo4Log::Message(1, textbuffer.toLatin1().constData());
00095 }
00096
00097 void TGo4ConditionInfo::WorkWithCondition(const char* itemname)
00098 {
00099 ResetWidget();
00100
00101 CondnameLbl->setText(itemname);
00102
00103 AddLink(itemname, "Condition");
00104
00105 TObject* obj = GetLinked("Condition", 2);
00106
00107 RefreshWidget(dynamic_cast<TGo4Condition*>(obj));
00108
00109 setFocus();
00110 }
00111
00112 void TGo4ConditionInfo::ResetWidget()
00113 {
00114 QGo4Widget::ResetWidget();
00115 PropertyBox->item(CONTITLE)->setText("Title");
00116 PropertyBox->item(CONCLASS)->setText("Class:");
00117 PropertyBox->item(CONX)->setText("X Testrange");
00118 PropertyBox->item(CONY)->setText("Y Testrange");
00119 PropertyBox->item(CONDIM)->setText("Dimension");
00120 PropertyBox->item(CONCOUNTS)->setText("Counts");
00121 PropertyBox->item(CONRESULT)->setText("Result");
00122 PropertyBox->item(CONMODE)->setText("Test mode");
00123 PropertyBox->item(CONSIZE)->setText("Size");
00124 TDatime now;
00125 PropertyBox->item(CONTIME)->setText(now.AsSQLString());
00126 ensurePolished();
00127 update();
00128 show();
00129 raise();
00130 }
00131
00132 void TGo4ConditionInfo::RefreshWidget(TGo4Condition* cond)
00133 {
00134 if(cond==0) return;
00135
00136 TString str;
00137 PropertyBox->item(CONTITLE)->setText(cond->GetTitle());
00138 PropertyBox->item(CONCLASS)->setText(cond->ClassName());
00139 int dimension = 0;
00140 if(cond->InheritsFrom(TGo4WinCond::Class())) {
00141 TGo4WinCond* wcon = (TGo4WinCond*) cond;
00142 double xmin, xmax, ymin, ymax;
00143 wcon->GetValues(dimension, xmin, xmax, ymin, ymax);
00144 str.Form("X: [%.1f,%.1f]",xmin, xmax);
00145 PropertyBox->item(CONX)->setText(str.Data());
00146 str.Form("Y: [%.1f,%.1f]",ymin, ymax);
00147 PropertyBox->item(CONY)->setText(str.Data());
00148 } else {
00149 PropertyBox->item(CONX)->setText("X:-");
00150 PropertyBox->item(CONY)->setText("Y:-");
00151 dimension = 2;
00152 }
00153
00154 str.Form("Dim:%d", dimension);
00155 PropertyBox->item(CONDIM)->setText(str.Data());
00156 str.Form("Counts:%d", cond->Counts());
00157 PropertyBox->item(CONCOUNTS)->setText(str.Data());
00158 str.Form("True:%d",cond->TrueCounts());
00159 PropertyBox->item(CONRESULT)->setText(str.Data());
00160
00161 if(cond->IsEnabled()) str = "test enabled"; else
00162 if(cond->FixedResult()) str = "always true";
00163 else str = "always false";
00164 if(cond->IsTrue()) str += " - regular";
00165 else str += " - inverse";
00166 PropertyBox->item(CONMODE)->setText(str.Data());
00167
00168 str.Form("size:%d b",cond->GetMemorySize());
00169 PropertyBox->item(CONSIZE)->setText(str.Data());
00170
00171 TDatime now;
00172 PropertyBox->item(CONTIME)->setText(now.AsSQLString());
00173 ensurePolished();
00174 update();
00175 show();
00176 raise();
00177 if(TGo4Log::IsAutoEnabled()) PrintLog_clicked();
00178 }