00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "tqrootdialog.h"
00029
00030 #include <iostream.h>
00031
00032 #include "qevent.h"
00033 #include "qpainter.h"
00034 #include "qprinter.h"
00035 #include "qtoolbar.h"
00036 #include "qtoolbutton.h"
00037 #include "qspinbox.h"
00038 #include "qtooltip.h"
00039 #include "qrect.h"
00040 #include "qpoint.h"
00041 #include "qcolordialog.h"
00042 #include "qfiledialog.h"
00043 #include "qcursor.h"
00044 #include "qimage.h"
00045 #include "qstrlist.h"
00046 #include "qpopupmenu.h"
00047 #include "qintdict.h"
00048 #include "qpushbutton.h"
00049 #include "qaction.h"
00050 using namespace std;
00051 #include "qdial.h"
00052 #include "qapplication.h"
00053 #include "qimage.h"
00054 #include "qpixmap.h"
00055 #include "qtoolbar.h"
00056 #include "qtoolbutton.h"
00057 #include "qmenubar.h"
00058 #include "qkeycode.h"
00059 #include "qfile.h"
00060 #include "qfiledialog.h"
00061 #include "qstatusbar.h"
00062 #include "qmessagebox.h"
00063 #include "qwhatsthis.h"
00064 #include "qdialog.h"
00065 #include "qlabel.h"
00066
00067 #include "TPad.h"
00068 #include "TList.h"
00069 #include "TObject.h"
00070 #include "TROOT.h"
00071 #include "TString.h"
00072 #include "TH1.h"
00073 #include "TList.h"
00074 #include "TIterator.h"
00075 #include "TMethod.h"
00076 #include "TCanvas.h"
00077 #include "TDataType.h"
00078 #include "TMethodCall.h"
00079 #include "TPad.h"
00080 #include "TObjArray.h"
00081 #include "TObjString.h"
00082 #include "TIterator.h"
00083
00084 #include "lockguard.h"
00085
00086 TQRootDialog::TQRootDialog(QWidget *parent, const char *name, WFlags f,
00087 TObject* obj, TMethod *method ) :
00088 QVBox(parent,name, f | WType_Modal | WStyle_Dialog ){
00089
00090 Qtrootlockguard threadlock;
00091 fCurObj=obj;
00092 fCurMethod=method;
00093
00094 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,
00095 QSizePolicy::Expanding));
00096
00097 fArgBox = new QVBox(this, "args");
00098
00099
00100 fArgBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,
00101 QSizePolicy::Expanding));
00102
00103 QHBox *hbox = new QHBox(this,"buttons");
00104 QPushButton *bOk = new QPushButton("Apply",hbox,"apply");
00105 QPushButton *bCancel = new QPushButton("Cancel",hbox,"close");
00106 connect(bCancel,SIGNAL (clicked()), this, SLOT(close()));
00107 connect(bOk,SIGNAL( clicked() ), this, SLOT( executeMethod() ));
00108
00109
00110
00111
00112
00113
00114
00115 fLineEdit=0;
00116
00117 fPrevMethod=0; fPrevObj=0;
00118 fParent = parent;
00119
00120 }
00121
00122
00123 void TQRootDialog::executeMethod(){
00124 Qtrootlockguard threadlock;
00125 Bool_t deletion = kFALSE;
00126
00127 qDebug("DIAL executeMethod: simple version\n");
00128 TVirtualPad *psave = gROOT->GetSelectedPad();
00129
00130 qDebug("DIAL saved pad: %s gPad:%s \n",psave->GetName(),gPad->GetName());
00131
00132 qDebug(" fCurObj %p \n", fCurObj);
00133 if (fCurObj)
00134 qDebug("DIAL obj:%s meth:%s \n",fCurObj->GetName(), fCurMethod->GetName());
00135
00136
00137
00138 TObjArray tobjlist(fCurMethod->GetListOfMethodArgs()->LastIndex()+1);
00139 for ( QLineEdit* st = aList.first(); st; st = aList.next()) {
00140 QString s = st->text();
00141 qDebug( "** QString values (first ) :%s \n", (const char*) s );
00142 TObjString *t = new TObjString( (const char*) s );
00143 tobjlist.AddLast((TObject*) t) ;
00144 }
00145
00146 if ( fCurObj ){
00147 if( strcmp(fCurMethod->GetName(),"Delete") == 0 ){
00148
00149 qDebug(" DIAL obj name deleted :%s \n", fCurObj->GetName());
00150 if (fCurObj) {
00151 delete fCurObj; fCurObj=0;
00152 deletion = kTRUE;
00153 }
00154
00155 qDebug(" DIAL deletion done closing ... \n");
00156
00157 }else if ( strcmp(fCurMethod->GetName(),"SetCanvasSize") == 0 ){
00158 int value[2];
00159 int l=0;
00160 for ( QLineEdit* st = aList.first(); st; st = aList.next()) {
00161 QString s = st->text();
00162 qDebug( "** QString values (first ) :%s \n", (const char*) s );
00163 value[l++] = atoi ( s );
00164 }
00165 qDebug( " do resize with %i %i \n", value[0], value[1]);
00166
00167 fParent->resize(value[0],value[1]);
00168 }else{
00169
00170 qDebug("TCint::Execute called !\n");
00171 fCurObj->Execute( fCurMethod, &tobjlist);
00172 }
00173
00174 }
00175
00176 if(!deletion ){
00177 qDebug("DIAL set saved pad: %s herit:%s gPad:%s\n",
00178 psave->GetName(), psave->IsA()->GetName(), gPad->GetName());
00179 gROOT->SetSelectedPad(psave);
00180 gROOT->GetSelectedPad()->Modified();
00181 gROOT->GetSelectedPad()->Update();
00182 qDebug("DIAL update done on %s \n", gROOT->GetSelectedPad()->GetName());
00183 }else{
00184 gROOT->SetSelectedPad( gPad );
00185
00186 gROOT->GetSelectedPad()->Update();
00187 }
00188 }
00189
00190
00191
00192 void TQRootDialog::executeMethod1(){
00193
00194
00195 Qtrootlockguard threadlock;
00196
00197 TVirtualPad *psave = gROOT->GetSelectedPad();
00198
00199
00200 printf(" TQRootDialog::executeMethod: \n");
00201 printf(" curObj:%p curMeth:%p prevObj:%p prevMeth:%p \n",
00202 fCurObj, fCurMethod, fPrevObj, fPrevMethod );
00203
00204 if ( !fCurMethod && fPrevMethod && fPrevObj) {
00205 loop:
00206 if( strcmp(fPrevMethod->GetName(),"Delete") == 0 ) return;
00207
00208 printf(" curObj:%p curMeth:%p prevObj:%p prevMeth:%p \n",
00209 fCurObj, fCurMethod, fPrevObj, fPrevMethod );
00210
00211
00212 TObjArray tobjlist(fPrevMethod->GetListOfMethodArgs()->LastIndex()+1);
00213
00214 for ( QLineEdit* st = aList.first(); st; st = aList.next()) {
00215 st->update();
00216 QString s = st->text();
00217 qDebug( "** QString values :%s \n", (const char*) s );
00218 TObjString *t = new TObjString( (const char*) s );
00219 tobjlist.AddLast((TObject*) t) ;
00220 }
00221 if( strcmp(fPrevMethod->GetName(),"Delete") != 0 ){
00222 fPrevObj->Execute( fPrevMethod, &tobjlist);
00223 }
00224
00225
00226
00227 gROOT->GetSelectedPad()->Modified();
00228 gROOT->GetSelectedPad()->Update();
00229 return;
00230 }else{
00231
00232 TObjArray tobjlist(fCurMethod->GetListOfMethodArgs()->LastIndex()+1);
00233 for ( QLineEdit* st = aList.first(); st; st = aList.next()) {
00234 QString s = st->text();
00235 qDebug( "** QString values (first ) :%s \n", (const char*) s );
00236 TObjString *t = new TObjString( (const char*) s );
00237 tobjlist.AddLast((TObject*) t) ;
00238 }
00239
00240
00241
00242 #if DEBUG_LEVEL>2
00243
00244 qDebug("TQRootDialog::executeMethod :from Qt list \n ");
00245 qDebug("Obj array size:%i \n", tobjlist.GetEntries());
00246 qDebug("Method name:%s \n" ,fCurMethod->GetName());
00247 qDebug("Obj name: %s\n",fCurObj->IsA()->GetName());
00248 TList *argList = fCurMethod->GetListOfMethodArgs();
00249 int nparms = argList->LastIndex()+1;
00250 int ag = &tobjlist ? tobjlist.LastIndex()+1:0;
00251 cout << nparms << ag << endl;
00252 cout << "** from ROOT " << endl;
00253 TIter next(&tobjlist);
00254 TObjString* str=0;
00255 while (( str = (TObjString *) next())) {
00256 const char *s= (str->GetString()).Data();
00257 qDebug(" values %s \n",s);
00258 }
00259
00260 #endif
00261
00262
00263 if( strcmp(fCurMethod->GetName(),"Delete") == 0 ){
00264
00265 printf(" DIAL obj name del :%s \n", fCurObj->GetName());
00266 if (fCurObj) {fCurObj->Delete(); fCurObj=0;}
00267 printf (" deletion done closing ... \n");
00268
00269 }else{
00270
00271 printf("Execute called !\n");
00272 fCurObj->Execute( fCurMethod, &tobjlist);
00273 }
00274
00275
00276 gROOT->SetSelectedPad(psave);
00277 printf("DIAL prepare update for pad %p \n",
00278 gROOT->GetSelectedPad() );
00279 gROOT->GetSelectedPad()->Update();
00280 gROOT->GetSelectedPad()->Modified();
00281 printf(" DIAL update done for pad: %s \n",
00282 gROOT->GetSelectedPad()->GetName() );
00283 fPrevObj=fCurObj;
00284 fPrevMethod=fCurMethod;
00285 fPrevObj=fCurObj;
00286 fCurObj=0;
00287 fCurMethod=0;
00288
00289
00290
00291 goto loop;
00292 }
00293 }
00294
00295
00296
00297
00298
00299
00300
00301
00302 void TQRootDialog::add(const char* argname, const char* value, const char* type){
00303 Qtrootlockguard threadlock;
00304 QString s;
00305 s=value;
00306
00307
00308 new QLabel(argname,fArgBox);
00309 QLineEdit* fLineEdit= new QLineEdit(fArgBox);
00310 fLineEdit->setGeometry(10,10, 130, 30);
00311 fLineEdit->setFocus();
00312 fLineEdit->setText(s);
00313 aList.append( fLineEdit );
00314
00315
00316
00317
00318
00319 #if DEBUG_LEVEL>2
00320 qDebug("TQRootDialog::add %s %s %s \n", argname, value, type);
00321 #endif
00322
00323 }
00324
00325 void TQRootDialog::popup(){
00326 Qtrootlockguard threadlock;
00327 show();
00328 }
00329 void TQRootDialog::closeEvent( QCloseEvent* ce )
00330 {
00331 Qtrootlockguard threadlock;
00332 ce->accept();
00333 delete this;
00334 }
00335
00336