00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 void TGo4Browser::init()
00017 {
00018
00019 fxDragItem=0;
00020 TGo4GUIRegistry *fxTGo4GUIRegistry;
00021 fxTGo4GUIRegistry = TGo4GUIRegistry::Instance();
00022 fxTGo4BrowserSlots = (TGo4BrowserSlots *) fxTGo4GUIRegistry->GetSlotClass("TGo4BrowserSlots");
00023 if(fxTGo4BrowserSlots !=0) {
00024 fxTGo4BrowserSlots->SetGUI(this);
00025 }else{
00026 fxTGo4BrowserSlots = new TGo4BrowserSlots ("TGo4BrowserSlots", "Slots Class for Qt GUI", this);
00027 }
00028 fxTGo4BrowserStatus = (TGo4BrowserStatus *) fxTGo4BrowserSlots->GetStatus();
00029
00030 fxContextMenu = new QPopupMenu( ListViewLocal );
00031 Q_CHECK_PTR( fxContextMenu );
00032 fiPlotID=fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "h1_t" ), "Plot", this, SLOT(PlotLocal()));
00033 fiSuperID=fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "superimpose.png" ), "Superimpose", this, SLOT(SuperImposeLocal()));
00034 fiClearID=fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "clear.png" ), "Clear local and remote", this, SLOT(ResetRemoteObjects()));
00035 fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "delete.png" ), "Delete from local memory", this, SLOT(LocalListDeleteSelection()));
00036 fxContextMenu->insertSeparator();
00037 fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "saveall.png" ), "Save selected...", this, SLOT(SaveSelectedItemsToRootFile()));
00038 fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "editcopy" ), "Export selected...", this, SLOT(ExportSelectedItems()));
00039 fxContextMenu->insertSeparator();
00040
00041 fxContextMenu->insertItem(TGo4MainWindow::uic_load_pixmap( "refresh.png" ), "Refresh from analysis", this, SLOT(UpdateLocalList()));
00042
00043
00044 }
00045
00046
00047 void TGo4Browser::destroy( )
00048 {
00049
00050 ListViewLocal->clear();
00051 fxTGo4BrowserSlots->SetGUI(0);
00052 }
00053
00054 void TGo4Browser::LocalItemDoubleClicked( QListViewItem *Item )
00055 {
00056 fxDragItem=0;
00057 fxTGo4BrowserSlots->LocalItemDoubleClicked(Item);
00058 }
00059
00060
00061 void TGo4Browser::SaveLocalListToRootFile()
00062 {
00063
00064 QString fileName;
00065 if(ListViewLocal->lastItem()!=0)
00066 {
00067 QFileDialog* fd = new QFileDialog( 0,"Save Selection To Root File", TRUE );
00068 QString fdCaption = "Save all local objects to a ROOT file";
00069 fd->setCaption(fdCaption);
00070 fd->setMode( QFileDialog::AnyFile );
00071 fd->setName( "Save All");
00072 fd->setFilter( "Root files (*.root)" );
00073 if ( fd->exec() == QDialog::Accepted )
00074 {
00075 fileName = fd->selectedFile();
00076 if(!fileName.endsWith(".root")) fileName.append(".root");
00077 bool ok=false;
00078 QString fileComment="Content of Go4 memory browser list";
00079 QString input = QInputDialog::getText(
00080 "Enter optional comment (TFile title):",
00081 0,
00082 QLineEdit::Normal, QString::null, &ok);
00083 if ( ok && !input.isNull() ) fileComment=input;
00084 fxTGo4BrowserSlots->ExportSelectedItems(fileName.data(),0,"ROOT",fileComment.data(),true);
00085 }
00086 delete fd;
00087 }
00088 else
00089 {
00090 QMessageBox::warning( this, "Nothing To Save", "Nothing To Save" );
00091 }
00092 }
00093
00094 void TGo4Browser::UpdateLocalList()
00095 {
00096 fxTGo4BrowserSlots->UpdateLocalList();
00097 }
00098
00099 void TGo4Browser::LocalListDeleteSelection()
00100 {
00101 fxTGo4BrowserSlots->LocalListDeleteSelection();
00102 }
00103
00104 void TGo4Browser::PlotLocal()
00105 {
00106 fxTGo4BrowserSlots->PlotLocal();
00107 }
00108
00109 void TGo4Browser::SuperImposeLocal()
00110 {
00111 fxTGo4BrowserSlots->SuperImposeLocal();
00112 }
00113
00114
00115
00116 void TGo4Browser::SaveSelectedItemsToRootFile()
00117 {
00118
00119 if(ListViewLocal->lastItem()!=0)
00120 {
00121 QString fileName;
00122 QFileDialog* fd = new QFileDialog( this, "Save Selection To Root File", TRUE );
00123 QString fdCaption = "Save Selected local objects to a ROOT file";
00124 fd->setCaption(fdCaption);
00125 fd->setMode( QFileDialog::AnyFile );
00126 fd->setName( "Save Selection To Root File ");
00127 fd->setFilter( "Root files (*.root)" );
00128 if ( fd->exec() == QDialog::Accepted )
00129 {
00130 fileName = fd->selectedFile();
00131 if(!fileName.endsWith(".root")) fileName.append(".root");
00132 bool ok=false;
00133 QString fileComment="Selection of Go4 memory browser list";
00134 QString input = QInputDialog::getText(
00135 "Enter optional comment (TFile title):",
00136 0,
00137 QLineEdit::Normal, QString::null, &ok);
00138 if ( ok && !input.isNull() ) fileComment=input;
00139 fxTGo4BrowserSlots->ExportSelectedItems(fileName.data(),0,"ROOT",fileComment.data(),false);
00140 }
00141 delete fd;
00142 }
00143 else
00144 {
00145 QMessageBox::warning( this, "Nothing To Save", "Select Objects to be saved" );
00146 }
00147 }
00148
00149 void TGo4Browser::closeEvent( QCloseEvent * ce )
00150 {
00151
00152 ce->accept();
00153 delete this;
00154 }
00155
00156 void TGo4Browser::Syncronize()
00157 {
00158 fxTGo4BrowserSlots->SynchronizeWithMemory();
00159 }
00160
00161 void TGo4Browser::OverWriteMode( int )
00162 {
00163 if (OverWrite->isChecked()) {
00164 fxTGo4BrowserSlots->SetOverWriteMode(TRUE);
00165
00166 }else {
00167 fxTGo4BrowserSlots->SetOverWriteMode(FALSE);
00168
00169 }
00170 }
00171
00172 QPtrList <TGo4QItem>* TGo4Browser::GetSelectedItems()
00173 {
00174
00175
00176 QPtrList <TGo4QItem> *lst = new QPtrList <TGo4QItem>;
00177 if(ListViewLocal->isMultiSelection()){
00178 QListViewItemIterator it(ListViewLocal);
00179
00180 for ( ; it.current(); ++it )
00181 if ( it.current()->isSelected() )
00182 lst->append((TGo4QItem *)it.current() );
00183 }
00184 return lst;
00185 }
00186
00187 void TGo4Browser::ResetRemoteObjects()
00188 {
00189 QListViewItem *SelectedItem;
00190 SelectedItem = ListViewLocal->selectedItem();
00191 if(ListViewLocal->isMultiSelection())
00192 {
00193 QListViewItemIterator it(ListViewLocal);
00194
00195 for ( ; it.current(); ++it )
00196 {
00197 if (it.current()->isSelected())
00198 ResetItem(it.current());
00199 }
00200 }
00201 else
00202 {
00203 if (SelectedItem !=0)
00204 ResetItem(SelectedItem);
00205 }
00206 fxTGo4BrowserSlots->UpdateLocalList();
00207
00208 }
00209
00210
00211 void TGo4Browser::ResetItem( QListViewItem * itm )
00212 {
00213
00214
00215 TGo4QItem* hitem=dynamic_cast<TGo4QItem*>(itm);
00216 if(hitem) {
00217 TH1* histo=dynamic_cast<TH1*>(hitem->GetItemObject());
00218 if (histo) histo->Reset();
00219 hitem->UpdateDrawPad();
00220 }
00221
00222 QString purename = itm->text(0).section(",",0,0);
00223 if(!purename.contains("THStack"))
00224 fxTGo4BrowserSlots->ResetRemoteObj(purename);
00225 }
00226
00227 void TGo4Browser::ExportSelectedItems()
00228 {
00229 QFileDialog* fd = new QFileDialog( this, "export", kTRUE );
00230
00231 fd->setMode( QFileDialog::AnyFile);
00232
00233 fd->setCaption("Export selected objects to directory");
00234 fd->setFilters(QString("ASCII (*.hdat *.gdat);;Radware/gf3 (*.spe);;ROOT (*.root)"));
00235 fd->setSelection("export.root");
00236 if ( fd->exec() == QDialog::Accepted ) {
00237 QString selfile = fd->selectedFile();
00238 QString filedir = fd->dirPath();
00239 QString expformat = fd->selectedFilter();
00240
00241 fxTGo4BrowserSlots->ExportSelectedItems(selfile.data(), filedir.data(), expformat.data());
00242 }
00243 delete fd;
00244 }
00245
00246
00247 void TGo4Browser::ExportLocalList()
00248 {
00249
00250 }
00251
00252
00253 void TGo4Browser::SetListFocus()
00254 {
00255 ListViewLocal->setFocus();
00256 }
00257
00258
00259 void TGo4Browser::ListViewLocal_pressed( QListViewItem * SelectedItem)
00260 {
00261 fxDragItem=SelectedItem;
00262 int timems=QApplication::startDragTime();
00263 QTimer::singleShot( timems, this, SLOT(StartListviewDrag()) );
00264 }
00265
00266
00267 void TGo4Browser::ListViewLocal_clicked( QListViewItem * )
00268 {
00269 fxDragItem=0;
00270 }
00271
00272
00273 void TGo4Browser::StartListviewDrag()
00274 {
00275 if(fxDragItem==0) return;
00276 ListViewLocal->setCurrentItem(fxDragItem);
00277 QTextDrag *d = new QTextDrag(fxDragItem->text(0),ListViewLocal);
00278 d->dragCopy();
00279 fxDragItem=0;
00280 }
00281
00282
00283 void TGo4Browser::ListViewLocal_contextMenuRequested( QListViewItem* selitem, const QPoint& pt, int )
00284 {
00285 fxDragItem=0;
00286 if(selitem==0) return;
00287 bool canplot=(dynamic_cast<TGo4QTHItem*> (selitem)!=0);
00288 fxContextMenu-> setItemEnabled (fiPlotID, canplot);
00289 fxContextMenu-> setItemEnabled (fiSuperID, canplot);
00290 fxContextMenu-> setItemEnabled (fiClearID, canplot);
00291 fxContextMenu->exec(pt);
00292
00293
00294
00295 }
00296
00297