Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

tqrootdialog.cpp

Go to the documentation of this file.
00001 //-------------------------------------------------------------
00002 //        Go4 Release Package v3.04-01 (build 30401)
00003 //                      28-November-2008
00004 //---------------------------------------------------------------
00005 //   The GSI Online Offline Object Oriented (Go4) Project
00006 //   Experiment Data Processing at EE department, GSI
00007 //---------------------------------------------------------------
00008 //
00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI
00010 //                    Planckstr. 1, 64291 Darmstadt, Germany
00011 //Contact:            http://go4.gsi.de
00012 //----------------------------------------------------------------
00013 //This software can be used under the license agreements as stated
00014 //in Go4License.txt file which is part of the distribution.
00015 //----------------------------------------------------------------
00016 //Author : Denis Bertini 01.11.2000
00017 
00018 /**************************************************************************
00019 * Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI           *
00020 *                     Planckstr. 1, 64291 Darmstadt, Germany              *
00021 *                     All rights reserved.                                *
00022 * Contact:            http://go4.gsi.de                                   *
00023 *                                                                         *
00024 * This software can be used under the license agreements as stated in     *
00025 * Go4License.txt file which is part of the distribution.                  *
00026 ***************************************************************************/
00027 
00028 #include "tqrootdialog.h"
00029 
00030 #include "Riostream.h"
00031 #include <stdlib.h>
00032 
00033 #include "qevent.h"
00034 #include "qpainter.h"
00035 #include "qprinter.h"
00036 #include "qtoolbar.h"
00037 #include "qtoolbutton.h"
00038 #include "qspinbox.h"
00039 #include "qtooltip.h"
00040 #include "qrect.h"
00041 #include "qpoint.h"
00042 #include "qcolordialog.h"
00043 #include "qfiledialog.h"
00044 #include "qcursor.h"
00045 #include "qimage.h"
00046 #include "qstrlist.h"
00047 #include "qpopupmenu.h"
00048 #include "qintdict.h"
00049 #include "qpushbutton.h"
00050 #include "qaction.h"
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 #include "qlineedit.h"
00067 
00068 #include "TPad.h"
00069 #include "TList.h"
00070 #include "TObject.h"
00071 #include "TROOT.h"
00072 #include "TString.h"
00073 #include "TH1.h"
00074 #include "TList.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 
00083 #include "lockguard.h"
00084 #include "tqcanvasmenu.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 //  QPushButton *bOk = new QPushButton("Ok",hbox,"ok");
00110 //   QPushButton *bCancel = new QPushButton("Cancel",hbox,"cancel");
00111 //   connect(bCancel,SIGNAL (clicked()), this, SLOT(close()));
00112 //   connect(bOk,SIGNAL( clicked() ), this, SLOT( executeMethod() ));
00113 
00114 
00115   fPrevMethod=0;
00116   fPrevObj=0;
00117   fParent = parent;
00118   fMenu = 0;
00119 }
00120 
00121 TQRootDialog::~TQRootDialog()
00122 {
00123    if(fArgBox) delete fArgBox;
00124    aList.remove();
00125 }
00126 
00127 void TQRootDialog::receive()
00128 {
00129    executeMethod();
00130 }
00131 
00132 void TQRootDialog::executeMethod()
00133 {
00134    Qtrootlockguard threadlock;
00135    Bool_t deletion = kFALSE;
00136 
00137    qDebug("DIAL executeMethod:  simple version\n");
00138    TVirtualPad *psave =  gROOT->GetSelectedPad();
00139 
00140    qDebug("DIAL saved pad: %s gPad:%s \n",psave->GetName(),gPad->GetName());
00141 
00142    qDebug(" fCurObj %p \n", fCurObj);
00143    if (fCurObj)
00144       qDebug("DIAL obj:%s meth:%s \n",fCurObj->GetName(), fCurMethod->GetName());
00145 
00146    //cout<< "executeMethod" << fCurMethod->GetName() << endl;
00147 
00148    TObjArray tobjlist(fCurMethod->GetListOfMethodArgs()->LastIndex()+1);
00149    for ( QLineEdit* st = aList.first(); st; st = aList.next()) {
00150       QString s = st->text();
00151       qDebug( "** QString values (first ) :%s \n", (const char*) s );
00152       TObjString *t = new TObjString( (const char*) s );
00153       tobjlist.AddLast((TObject*) t) ;
00154    }
00155      // handle command if existing object
00156    if (fCurObj != 0) {
00157      if(strcmp(fCurMethod->GetName(),"Delete") == 0) {
00158          // here call explicitely the dtor
00159          qDebug(" DIAL obj name deleted :%s \n", fCurObj->GetName());
00160          if (fCurObj) {
00161             if (fMenu!=0)
00162                fMenu->EmitMenuCommandExecuted(fCurObj,"Delete");
00163             delete fCurObj;
00164             fCurObj = 0;
00165             deletion = kTRUE;
00166          }
00167 
00168        qDebug(" DIAL deletion done closing ... \n");
00169 
00170      } else
00171      if (strcmp(fCurMethod->GetName(), "SetCanvasSize") == 0) {
00172         int value[2];
00173         int l=0;
00174         for ( QLineEdit* st = aList.first(); st; st = aList.next()) {
00175            QString s = st->text();
00176            qDebug( "** QString values (first ) :%s \n", (const char*) s );
00177            value[l++] = atoi ( s );
00178         }
00179         qDebug( " do resize with %i %i \n", value[0], value[1]);
00180         fParent->resize(value[0],value[1]);
00181         if (fMenu!=0)
00182           fMenu->EmitMenuCommandExecuted(fCurCanvas, "SetCanvasSize");
00183      } else {
00184        // here call cint call
00185         qDebug("TCint::Execute called !\n");
00186         
00187         fCurObj->Execute(fCurMethod, &tobjlist);
00188 
00189         if (fCurObj->TestBit(TObject::kNotDeleted)) {
00190            if (fMenu!=0)
00191               fMenu->EmitMenuCommandExecuted(fCurObj, fCurMethod->GetName());
00192         } else {
00193            deletion = TRUE; 
00194            fCurObj = 0; 
00195         }
00196      }
00197 
00198    } // ! fCurrent Obj
00199 
00200    if(!deletion ) {
00201       qDebug("DIAL set saved pad: %s herit:%s gPad:%s\n",
00202              psave->GetName(), psave->ClassName(), gPad->GetName());
00203       gROOT->SetSelectedPad(psave);
00204       gROOT->GetSelectedPad()->Modified();
00205       gROOT->GetSelectedPad()->Update();
00206       qDebug("DIAL update done on %s \n", gROOT->GetSelectedPad()->GetName());
00207    } else {
00208       gROOT->SetSelectedPad( gPad );
00209       gROOT->GetSelectedPad()->Update();
00210    }
00211 }
00212 
00213 void TQRootDialog::add(const char* argname, const char* value, const char* type)
00214 {
00215    Qtrootlockguard threadlock;
00216    
00217    new QLabel(argname,fArgBox);
00218    QLineEdit* le = new  QLineEdit(fArgBox);
00219    le->setGeometry(10,10, 130, 30);
00220    le->setFocus();
00221    le->setText(value);
00222    aList.append( le );
00223 
00224 #if DEBUG_LEVEL>2
00225   qDebug("TQRootDialog::add %s %s %s \n", argname, value, type);
00226 #endif
00227 
00228 }
00229 
00230 void TQRootDialog::popup()
00231 {
00232    Qtrootlockguard threadlock;
00233    show();
00234 }
00235 
00236 void TQRootDialog::closeEvent( QCloseEvent* ce )
00237 {
00238    Qtrootlockguard threadlock;
00239    ce->accept();
00240    delete this;
00241 }
00242 
00243 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Fri Nov 28 12:59:33 2008 for Go4-v3.04-1 by  doxygen 1.4.2