36 #include <qmessagebox.h>
40 using std::runtime_error;
44 using namespace hippodraw;
61 const string xml (
".xml" );
62 const string tnt (
".tnt" );
65 #define STRING_CLEAR_DEFECT
68 #ifdef STRING_CLEAR_DEFECT
87 const string root (
".root" );
94 const string fits (
".fits" );
99 const string gzfits (
".fits.gz" );
112 #ifdef STRING_CLEAR_DEFECT
123 const string fits (
".fits" );
128 const string gzfits (
".fits.gz" );
143 const string xml (
".xml" );
144 const string tnt (
".tnt" );
147 #define STRING_CLEAR_DEFECT
150 #ifdef STRING_CLEAR_DEFECT
199 return suffix ==
".root";
206 return suffix ==
".fits";
213 return suffix ==
".gz";
228 #if QT_VERSION < 0x040000
231 = Q3FileDialog::getSaveFileName ( QString::null,
236 "Save data source to file ...",
239 if ( filename == QString::null )
return tmp;
241 if (( filename.
endsWith (
".tnt" ) == false ) &&
242 ( filename.
endsWith (
".fits" ) == false ) &&
243 ( filename.
endsWith (
".fits.gz" )==false ))
247 if ( extname ==
"FITS ntuples(*.fits)" )
251 else if (extname ==
"Compressed FITS ntuples(*.fits.gz)")
253 filename+=
".fits.gz";
264 bool yes = info.
exists ();
265 if ( yes ==
false )
break;
267 string message (
"File exists. \n\n" );
268 message +=
"Over write existing file?";
274 if ( result == QMessageBox::Yes )
break;
277 string name = filename.
latin1();
302 controller -> createNTuple ( filename );
304 catch (
const std::exception & e )
307 QString message(
"Unable to open file\n" );
308 message.
append(e.what ());
328 fits_file = controller ->
openFile ( fn );
329 if ( fits_file != 0 ) yes =
true;
343 const vector < string > & dups = source -> getDuplicatedLabels ();
344 if ( dups.empty () == false ) {
345 QString message (
"This data source contains two or more columns with\n"
346 "the same label. The offending labels were\n\n" );
347 for (
unsigned int i = 0; i < dups.size(); i++ ) {
348 message += dups[i].c_str();
351 message +=
"\nThe first column encountered will be used";
365 unsigned int index = 0;
368 const vector < string > & names
369 = controller -> getNTupleNames ( filename );
371 if ( names.size () > 1 ) {
372 if ( names.size () >= 2 ) {
374 dialog -> setNames ( names );
375 int retval = dialog -> exec ();
377 if ( retval == QDialog::Accepted ) {
378 index = dialog -> selectedItem ();
381 if ( retval == QDialog::Rejected )
return;
390 controller -> createNTuple ( filename, names [ index ], index );
393 catch (
const runtime_error & e ) {
410 unsigned int index = 0;
413 const vector < string > & tree_names
414 = controller -> getNTupleNames ( filename );
415 if ( tree_names.size () > 1 ) {
417 dialog -> setNames ( tree_names );
419 int retval = dialog -> exec ();
421 if ( retval == QDialog::Rejected )
return;
422 index = dialog -> selectedItem ();
425 if ( tree_names.empty () ) {
426 string message (
"There were no ntuple objects found in this file." );
427 message +=
"\nFile not opened.";
439 controller -> createNTuple ( filename, tree_names[index] );
442 catch (
const runtime_error & e ) {
459 const string tuple_name =
462 -> getSelectedDataSourceName ();
468 catch (
const std::exception & e ) {
469 QString message (
"An error occurred in writing file.\n\n" );
475 QMessageBox::NoButton,
476 QMessageBox::NoButton );
485 const string tuple_name =
488 -> getSelectedDataSourceName ();
495 catch (
const std::exception & e ) {
496 QString message (
"An error occurred in writing file.\n\n" );
502 QMessageBox::NoButton,
503 QMessageBox::NoButton );