3 #include <QApplication>
4 #include <QDomDocument>
16 #define DbgLv(a) if(dbg_level>=a)qDebug()
22 int main(
int argc,
char* argv[] )
24 QApplication application( argc, argv );
32 return application.exec();
38 setWindowTitle( tr(
"Fluorescence Data File Manager" ) );
41 QVBoxLayout* top =
new QVBoxLayout(
this );
42 top->setSpacing ( 2 );
43 top->setContentsMargins ( 2, 2, 2, 2 );
46 QHBoxLayout* runInfo =
new QHBoxLayout();
47 QLabel* lb_info =
us_label( tr(
"Dataset Info:" ), -1 );
48 runInfo->addWidget( lb_info );
54 top->addLayout( runInfo );
56 QHBoxLayout*
main =
new QHBoxLayout();
57 QVBoxLayout* left =
new QVBoxLayout;
60 QGridLayout* specs =
new QGridLayout;
67 connect( pb_load, SIGNAL( clicked() ), SLOT(
load() ) );
68 specs->addWidget( pb_load, s_row, 0, 1, 1 );
75 lbl_progress->setAlignment( Qt::AlignLeft );
76 specs->addWidget( lbl_progress, s_row, 0, 1, 1 );
79 specs->addWidget(
progress, s_row++, 1, 1, 3 );
81 QLabel* lb_triple =
us_label( tr(
"Cell / Channel / Wavelength:" ), -1 );
82 specs->addWidget( lb_triple, s_row, 0, 1, 2 );
85 specs->addWidget(
cb_triple, s_row++, 2, 1, 2 );
88 specs->addWidget(
lbl_rpms, s_row, 0, 1, 2 );
91 specs->addWidget(
cb_rpms, s_row++, 2, 1, 2 );
94 specs->addWidget(
lbl_gains, s_row, 0, 1, 2 );
97 specs->addWidget(
cb_gains, s_row++, 2, 1, 2 );
100 specs->addWidget(
lbl_scans, s_row, 0, 1, 2 );
104 specs->addWidget(
le_scans, s_row++, 2, 1, 2 );
109 specs->addWidget(
lbl_from, s_row, 0, 1, 2 );
113 specs->addWidget(
ct_from, s_row++, 2, 1, 2 );
114 connect(
ct_from, SIGNAL( valueChanged (
double ) ),
120 specs->addWidget(
lbl_to, s_row, 0, 1, 2 );
124 specs->addWidget(
ct_to, s_row++, 2, 1, 2 );
125 connect(
ct_to , SIGNAL( valueChanged (
double ) ),
130 specs->addWidget(
pb_exclude, s_row, 0, 1, 2 );
164 specs->addWidget(
pb_undo, s_row, 0, 1, 2 );
166 connect(
pb_undo, SIGNAL( clicked() ),
171 specs->addWidget(
pb_write, s_row++, 2, 1, 2 );
176 specs->addWidget(
lbl_prefix, s_row, 0, 1, 2 );
180 specs->addWidget(
ct_prefix, s_row++, 2, 1, 2 );
181 connect(
ct_prefix, SIGNAL( valueChanged (
double ) ),
185 QBoxLayout* buttons =
new QHBoxLayout;
188 connect( pb_reset, SIGNAL( clicked() ), SLOT(
reset() ) );
189 buttons->addWidget( pb_reset );
192 connect( pb_help, SIGNAL( clicked() ), SLOT(
help() ) );
193 buttons->addWidget( pb_help );
196 connect( pb_accept, SIGNAL( clicked() ), SLOT( close() ) );
197 buttons->addWidget( pb_accept );
201 tr(
"Fluorescence Data" ),
202 tr(
"Radius (in cm)" ), tr(
"Fluorescence Intensity" ) );
205 data_plot->enableAxis( QwtPlot::xBottom,
true );
206 data_plot->enableAxis( QwtPlot::yLeft ,
true );
208 left->addLayout( specs );
210 left->addLayout( buttons );
212 main->addLayout( left );
213 main->addLayout(
plot );
214 main->setStretchFactor(
plot, 3 );
215 top ->addLayout( main );
225 fd.setFileMode(QFileDialog::Directory);
227 tr(
"Raw Data Directory" ),
229 QFileDialog::DontResolveSymlinks);
242 QDir readDir(
source_dir,
"*.[F,f][I,i][1-8]", QDir::Name, QDir::Files | QDir::Readable );
243 readDir.makeAbsolute();
245 files = QDir( readDir ).entryList(
246 QDir::Files | QDir::NoDotAndDotDot, QDir::Name );
256 QString line, str, str1, str2;
257 QStringList tokens, triplelist;
260 for ( i=0; i<
files.size(); i++)
263 if (
files.at(i).contains(
"A", Qt::CaseInsensitive ) )
272 if ( f.open( QFile::ReadOnly ) )
275 line = ts.readLine();
276 tokens = line.split(
" ", QString::SkipEmptyParts);
284 line = ts.readLine();
285 tokens = line.split(
" ", QString::SkipEmptyParts);
302 line = ts.readLine();
304 tokens = line.split(
" ", QString::SkipEmptyParts);
315 QMessageBox::warning (
this, tr(
"Attention:" ),
316 tr(
"The selected directory does not contain fluorescence files...\n"
317 "Please try again." ),
321 triplelist.removeDuplicates();
324 connect(
cb_triple, SIGNAL( currentIndexChanged(
int ) ),
338 for (
int i=0; i<
scaninfo.size(); i++)
342 rpmlist.append(str.setNum(
scaninfo[i].rpm));
345 rpmlist.removeDuplicates();
348 connect(
cb_rpms, SIGNAL( currentIndexChanged(
int ) ),
359 QStringList gainlist;
363 for (
int i=0; i<
scaninfo.size(); i++)
369 gainlist.append(
scaninfo[i].gainset);
372 gainlist.removeDuplicates();
375 connect(
cb_gains, SIGNAL( currentIndexChanged(
int ) ),
382 QString str, str1, str2, str3;
389 ct_to ->setValue(0.0);
390 connect(
ct_from, SIGNAL( valueChanged (
double ) ),
392 connect(
ct_to, SIGNAL( valueChanged (
double ) ),
394 le_info->setText(
"Loaded " + str.setNum(
scaninfo.size()) +
" scans containing "
396 +
" triples. The current triple (" +
cb_triple->currentText() +
") contains "
397 + str2.setNum(
cb_rpms->count()) +
" speed(s) and "
398 + str3.setNum(
cb_gains->count()) +
" gain setting(s)." );
406 QList < QwtPlotCurve * > c;
410 for (
int i=0; i<
scaninfo.size(); i++)
436 double x[npts], y[npts];
437 for (
int j=0; j<npts; j++)
444 curve->setData( x, y, npts );
446 if (
from == 0 &&
to == 0 )
448 curve->setPen( QPen( Qt::yellow ) );
450 else if (i >=
from-1 && i <=
to-1 )
452 curve->setPen( QPen( Qt::red ) );
456 curve->setPen( QPen( Qt::yellow ) );
458 data_plot->setAxisAutoScale( QwtPlot::yLeft );
459 data_plot->setAxisAutoScale( QwtPlot::xBottom );
470 else if (c.size() == 1)
478 else if (c.size() == 0)
492 data_plot->setAxisScale( QwtPlot::xBottom, 5.7, 7.3 );
493 data_plot->setAxisScale( QwtPlot::yLeft , 0.0, 1.5 );
500 ct_to ->setMinValue( 0 );
501 ct_to ->setMaxValue( 0 );
502 ct_to ->setValue ( 0 );
520 pb_undo ->setEnabled (
false );
545 for (
int i=0; i<
scaninfo.size(); i++)
595 for (
int i=0; i<
scanindex.size() - 1; i++)
615 for (
int i=0; i<
scaninfo.size(); i++)
630 if (
from == 0 &&
to == 0 )
634 else if (i >=
from-1 && i <=
to-1 )
649 ct_to ->disconnect();
650 ct_to ->setValue( 0.0 );
652 connect(
ct_from, SIGNAL( valueChanged (
double ) ),
654 connect(
ct_to, SIGNAL( valueChanged (
double ) ),
669 ct_to->setValue( scan );
671 connect(
ct_to, SIGNAL( valueChanged (
double ) ),
689 connect(
ct_from, SIGNAL( valueChanged (
double ) ),
698 if ( from == 0 && to == 0 )
713 prefix = str.setNum( val );
730 fd.setFileMode(QFileDialog::Directory);
731 target_dir = fd.getExistingDirectory(
this,
732 tr(
"Please select or create an output directory for the ordered fluorescence data (ANY EXISITNG DATA WILL BE DELETED!!):" ),
734 QFileDialog::DontResolveSymlinks);
736 target_dir.replace(
"\\",
"/" );
738 if ( target_dir.isEmpty() )
744 le_info->setText(
"Writing all files to " + target_dir);
745 QDir target(target_dir);
748 if ( target_dir.right( 1 ) !=
"/" ) target_dir +=
"/";
750 QString filename, str1, str2;
761 triples.removeDuplicates();
762 for ( i=0; i<triples.size(); i++ )
764 tmp_tripleCounts.
name = triples.at(i);
765 tmp_tripleCounts.
index = 0;
804 str1 = tr(
"The file:\n\n ") + filename + tr(
"\n\nalready exists in:\n\n ") + target_dir +
"\n\n"
805 + tr(
"Please use a different directory or prefix, or create a new directory and try again.");
806 QMessageBox::warning (
this, tr(
"Attention:" ), str1, QMessageBox::Ok );