Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

/Go4GUI/TGo4GSIHistoClient.ui.h

Go to the documentation of this file.
00001 //---------------------------------------------------------------
00002 //        Go4 Release Package v2.10-5 (build 21005) 
00003 //                      03-Nov-2005
00004 //---------------------------------------------------------------
00005 //       The GSI Online Offline Object Oriented (Go4) Project
00006 //       Experiment Data Processing at DVEE 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 /****************************************************************************
00017 ** ui.h extension file, included from the uic-generated form implementation.
00018 **
00019 ** If you wish to add, delete or rename slots use Qt Designer which will
00020 ** update this file, preserving your code. Create an init() slot in place of
00021 ** a constructor, and a destroy() slot in place of a destructor.
00022 *****************************************************************************/
00023 
00024 #include <iostream.h>
00025 
00026 extern "C"
00027 {
00028    INTS4 f_his_getdir( const char *  , int  ,  const char *, const char * , const char * ,INTS4**  ,INTS4*);
00029    INTS4 f_his_gethis( const char *  , int  ,  const char *,const char *, const char *, s_his_head **,   INTS4 **, INTS4 *);
00030 }
00031 
00032 
00033 void TGo4GSIHistoClient::init()
00034 {
00035     // TGo4LockGuard glob;
00036     fxTGo4GUIRegistry = TGo4GUIRegistry::Instance();
00037     fxTGo4BrowserSlots = (TGo4BrowserSlots *) fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots");
00038     StopMonitorB->setDisabled(TRUE);
00039     fbMonitorDone=true;
00040     
00041     fxMontimer = new QTimer(this);
00042     connect(fxMontimer, SIGNAL(timeout()), this, SLOT(MonitorFunction()));
00043     TGo4DockBrowserTabs=dynamic_cast<QTabWidget *> (parentWidget()->parentWidget()->parentWidget()) ;
00044     
00045     TGo4QSettings settings;
00046     QString servernode = settings.readEntry( TGo4QSettings::GetSettingsName()+"/HistogramClient/server", "");
00047     QString base = settings.readEntry( TGo4QSettings::GetSettingsName()+"/HistogramClient/base", "");
00048     QString filter  = settings.readEntry( TGo4QSettings::GetSettingsName()+"/HistogramClient/filter", "*");
00049     QString port = settings.readEntry( TGo4QSettings::GetSettingsName()+"/HistogramClient/port", "6009");
00050     
00051     ServerName->setText(servernode);
00052     BaseName->setText(base);
00053     FilterList->setText(filter);
00054     PortNo->setText(port);
00055     fxDragItem=0;
00056     fxContextMenu = new QPopupMenu( ClientHistListView );
00057     Q_CHECK_PTR( fxContextMenu );
00058     fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "right" ), "Copy selected to local memory", this, SLOT(SendToLocal()));
00059     fxContextMenu->insertSeparator();
00060     fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "refresh.png" ), "Refresh histogram list", this, SLOT(ConnectServ())); 
00061 }
00062 
00063 void TGo4GSIHistoClient::destroy()
00064 {
00065     SaveSettings();
00066 }
00067 
00068 void TGo4GSIHistoClient::SaveSettings()
00069 {
00070    TGo4QSettings settings;
00071    settings.writeEntry( TGo4QSettings::GetSettingsName()+"/HistogramClient/server", ServerName->text());
00072    settings.writeEntry( TGo4QSettings::GetSettingsName()+"/HistogramClient/base", BaseName->text());
00073    settings.writeEntry( TGo4QSettings::GetSettingsName()+"/HistogramClient/filter", FilterList->text());
00074    settings.writeEntry( TGo4QSettings::GetSettingsName()+"/HistogramClient/port", PortNo->text());
00075 }
00076 
00077 void TGo4GSIHistoClient::ConnectServ()
00078 {
00079    StopMonitoring();
00080    ClientHistListView->clear();
00081    INTS4*pl_all_h=0;
00082    int l_histos=0;
00083    int result= f_his_getdir( ServerName->text().data()   , PortNo->text().toInt() ,
00084                BaseName->text().data(),UserPass->text().data(), FilterList->text().data() , &pl_all_h, (INTS4 *)&l_histos);
00085    if(result!=0) {
00086       QString mess="Histogram Client: Could not receive histogram list!";
00087       mess.append(" Please check specified server properties.");
00088       //cout << mess << endl;
00089       TGo4MainWindow *MW= dynamic_cast<TGo4MainWindow *>(fxTGo4GUIRegistry->GetMainWindow());
00090       if(MW) MW->StatusMessage(mess);
00091       return;
00092    }
00093 
00094    if(l_histos>0){
00095        s_his_head * ps_his_head = (s_his_head *) pl_all_h;
00096        for(int i_j=0;i_j<l_histos;i_j++) {
00097       if (ps_his_head->l_bins_2>1){
00098           QString HisType="TH2";
00099           if(strstr(ps_his_head->c_dtype,"r")!=0) HisType=HisType+"F";
00100           new TGo4QTH2Item(ClientHistListView, ps_his_head->c_name,HisType,ps_his_head->c_data_time_cre);
00101       }else{
00102                  QString HisType="TH1";
00103           if(strstr(ps_his_head->c_dtype,"r")!=0) HisType=HisType+"F";
00104           new TGo4QTH1Item(ClientHistListView, ps_his_head->c_name, HisType,ps_his_head->c_data_time_cre);
00105       }
00106       ps_his_head++;
00107        }
00108    }
00109    free(pl_all_h);
00110    SaveSettings();
00111 }
00112 
00113 void TGo4GSIHistoClient::MonitorFunction()
00114 {
00115   if(!fbMonitorDone) return; // avoid double call of monitor if timer is faster than SendTolocal function!
00116   fbMonitorDone=false;
00117   SendToLocal();
00118   fbMonitorDone=true;
00119 }
00120 
00121 void TGo4GSIHistoClient::SendToLocal()
00122 {
00123     // TGo4LockGuard Global();
00124     if (fxTGo4BrowserSlots!=0){
00125       QListViewItemIterator it(ClientHistListView);
00126       // iterate through all items of the list view
00127       for ( ; it.current(); ++it ) {
00128           if ( it.current()->isSelected() ){
00129          GetSelectedItem(  it.current(), 0,0);
00130             }
00131       }
00132     }
00133 
00134 }
00135 
00136 
00137 
00138 void TGo4GSIHistoClient::ClientHistListView_doubleClicked( QListViewItem *selectedItem)
00139 {
00140     fxDragItem=0; // no drag start after mouse up
00141     GetSelectedItem(selectedItem, 0,0);
00142     if(TGo4DockBrowserTabs!=0) TGo4DockBrowserTabs->setCurrentPage(1);
00143 }
00144 
00145 
00146 void TGo4GSIHistoClient::GetSelectedItem( QListViewItem *selectedItem , TQRootCanvas* rc, TPad* pad)
00147 {
00148    INTS4 * pl_all =NULL;
00149    REAL4 *pr_all=NULL;
00150    INTS4 *pl_start;
00151    int l_status=0;
00152    s_his_head * ps_his_head=NULL;
00153    INTS4 l_size=0;
00154    Stat_t entries=0;
00155    Stat_t val=0;
00156 
00157     l_status = f_his_gethis(ServerName->text().data()   , PortNo->text().toInt() ,
00158             BaseName->text().data(),UserPass->text().data(), selectedItem->text(0).data(),(s_his_head **)&ps_his_head,(INTS4 **)&pl_all,(INTS4 *)&l_size);
00159    //cout <<"f_his_gethis returns status:"<<l_status << endl;
00160     if(l_status!=0)
00161         {
00162          QString mess="Histogram Client: Could not receive item ";
00163          mess.append(selectedItem->text(0));
00164          mess.append(". Please try Connect to server again to update list.");
00165          //cout << mess << endl;
00166          TGo4MainWindow *MW= dynamic_cast<TGo4MainWindow *>(fxTGo4GUIRegistry->GetMainWindow());
00167          if(MW) MW->StatusMessage(mess);
00168          return;
00169         }
00170 
00171    if(l_size!=0){
00172        int i1=ps_his_head->l_bins_1;
00173        int i2=ps_his_head->l_bins_2;
00175        if(strstr(ps_his_head->c_dtype,"r")!=0){
00176          pr_all =(REAL4 *) pl_all;
00177        }else{
00178          pr_all = NULL;
00179        }
00180         pl_start=pl_all; //keep the pionter to free it later
00182 
00183        if(i2==1){         
00184       TH1F *h1 = new TH1F(ps_his_head->c_name,ps_his_head->c_name,i1,
00185                 ps_his_head->r_limits_low,ps_his_head->r_limits_up);
00186       h1->SetDirectory(0);
00188 
00189             if(pr_all !=0){
00190              for (int k = 0; k<i1; k++){
00191                         val=(REAL4) *(pr_all+k);
00192                         h1->SetBinContent(k,val);
00193                         entries+=val;
00194                     }
00195             }else{
00196              for (int k = 0; k<i1;k++){
00197                     val=(REAL4) *(pl_all+k);
00198                     h1->SetBinContent(k,val);
00199                     entries+=val;
00200                 }
00201             }
00203          h1->SetEntries(entries);
00204             h1->GetXaxis()->SetTitle(ps_his_head->c_lettering_1);
00205          h1->GetXaxis()->CenterTitle();
00206          h1->GetYaxis()->SetTitle(ps_his_head->c_lettering_res);
00207          h1->GetYaxis()->CenterTitle();
00208 
00209             if(rc==0)
00210                 fxTGo4BrowserSlots->AddObject(h1);
00211             else
00212                 fxTGo4BrowserSlots->AddObject(h1,rc,pad); // for dragndrop
00213          delete h1;
00214 
00215        }else{            
00216          TH2F *h2 = new TH2F(ps_his_head->c_name,ps_his_head->c_name,i1,
00217                    ps_his_head->r_limits_low,ps_his_head->r_limits_up,i2,ps_his_head->r_limits_low_2,ps_his_head->r_limits_up_2);
00218           h2->SetDirectory(0);
00220          if(pr_all !=0) {
00221 
00222              for (int k = 0;k<i2; k++){
00223                for (int k1 = 0; k1<i1; k1++){
00224                          // swapped x and y JA
00225                          val=(REAL4) *(pr_all++);
00226                     h2->SetBinContent(k1,k,val);
00227                          entries+=val;
00228                }
00229              }
00230          }else {
00231              for (int k = 0;k<i2; k++){
00232                for (int k1 = 0; k1<i1; k1++) {
00233                         // swapped x and y JA
00234                         val=(REAL4) *(pl_all++);
00235                    h2->SetBinContent(k1,k,val);
00236                         entries+=val;
00237                }
00238              }
00239          }
00241          h2->SetEntries(entries);
00242             h2->GetXaxis()->SetTitle(ps_his_head->c_lettering_1);
00243          h2->GetXaxis()->CenterTitle();
00244          h2->GetYaxis()->SetTitle(ps_his_head->c_lettering_2);
00245          h2->GetYaxis()->CenterTitle();
00246          if(rc==0)
00247                 fxTGo4BrowserSlots->AddObject(h2);
00248             else
00249                 fxTGo4BrowserSlots->AddObject(h2,rc,pad); // for dragndrop
00250          delete h2;
00251        }
00252    }
00253    free(pl_start);
00254    free(ps_his_head);
00255 }
00256 
00257 
00258 
00259 
00260 
00261 void TGo4GSIHistoClient::SetListFocus()
00262 {
00263 ClientHistListView->setFocus();
00264 }
00265 
00266 
00267 void TGo4GSIHistoClient::StartMonitoring()
00268 {
00269     fxMontimer->start(update_time->value()*1000);
00270     update_time->setDisabled(TRUE);
00271     StartMonitorB->setDisabled(TRUE);
00272     StopMonitorB->setDisabled(FALSE);
00273     ClientHistListView->setDisabled(TRUE);
00274 }
00275 
00276 
00277 void TGo4GSIHistoClient::StopMonitoring()
00278 {
00279     if(fxMontimer->isActive()) fxMontimer->stop();
00280     update_time->setDisabled(FALSE);
00281     StartMonitorB->setDisabled(FALSE);
00282     StopMonitorB->setDisabled(TRUE);
00283     ClientHistListView->setDisabled(FALSE);
00284 }
00285 
00286 
00287 void TGo4GSIHistoClient::ClientHistListView_returnPressed( QListViewItem * item)
00288 {
00289     ClientHistListView_doubleClicked(item);
00290 }
00291 
00292 
00293 
00294 
00295 void TGo4GSIHistoClient::ClientHistListView_pressed( QListViewItem * SelectedItem)
00296 {
00297 fxDragItem=SelectedItem;
00298 int timems=QApplication::startDragTime();
00299 //cout <<"FileListView_pressed starts timer with "<<timems << endl;
00300 QTimer::singleShot( timems, this, SLOT(StartListviewDrag()) );     
00301 }
00302 
00303 
00304 void TGo4GSIHistoClient::ClientHistListView_clicked( QListViewItem * )
00305 {
00306 fxDragItem=0; // no drag start after mouse up
00307 }
00308 
00309 
00310 void TGo4GSIHistoClient::StartListviewDrag()
00311 {
00312 if(fxDragItem==0) return;
00313 ClientHistListView->setCurrentItem(fxDragItem); // drop will always refer to currently selected item 
00314 QDragObject *d = new QTextDrag(fxDragItem->text(0),ClientHistListView);
00315 d->dragCopy();
00316 fxDragItem=0;
00317 }
00318 
00319 
00320 void TGo4GSIHistoClient::ClientHistListView_contextMenuRequested( QListViewItem* selitem, const QPoint& pt, int )
00321 {
00322 fxDragItem=0;// no drag start after context menu  
00323 if(selitem==0) return;
00324 fxContextMenu->exec(pt);
00325 
00326 
00327 
00328 }
00329 
00330 //----------------------------END OF GO4 SOURCE FILE ---------------------

Generated on Tue Nov 8 10:56:00 2005 for Go4-v2.10-5 by doxygen1.2.15