1 #include <QApplication>
29 #define DbgLv(a) if(dbg_level>=a)qDebug()
32 int main(
int argc,
char* argv[] )
34 QApplication application( argc, argv );
42 return application.exec();
47 const QChar chlamb( 955 );
49 setWindowTitle( tr(
"Multi-Wavelength Raw Data Viewer" ) );
52 QGridLayout* settings =
new QGridLayout;
60 QFontMetrics fmet( sfont );
61 int fwid = fmet.maxWidth();
63 int swid = lwid + fwid;
66 QLabel* lb_run =
us_banner( tr(
"Load the Run" ) );
72 QLabel* lb_dir =
us_label( tr(
"Directory" ), -1 );
75 QLabel* lb_runID =
us_label( tr(
"Run ID:" ), -1 );
78 QLabel* lb_cellchn =
us_label( tr(
"Cell / Channel" ), -1 );
82 QLabel* lb_recavg =
us_label( tr(
"Record Average:" ), -1 );
91 QLabel* lb_prcntls =
us_banner( tr(
"Plot Range Controls" ) );
92 QLabel* lb_rstart =
us_label( tr(
"Radius Start:" ), -1 );
94 QLabel* lb_rend =
us_label( tr(
"Radius End:" ), -1 );
96 QLabel* lb_lstart =
us_label( tr(
"%1 Start:" ).arg( chlamb ), -1 );
98 QLabel* lb_lend =
us_label( tr(
"%1 End:" ).arg( chlamb ), -1 );
110 QLabel* lb_scanctl =
us_banner( tr(
"Scan Control" ) );
111 QLabel* lb_from =
us_label( tr(
"From:" ) );
112 QLabel* lb_to =
us_label( tr(
"To:" ) );
118 ct_from ->setMinimumWidth( lwid );
119 ct_from ->resize( rhgt, swid );
120 ct_to ->setFont( sfont );
121 ct_to ->setMinimumWidth( lwid );
122 ct_to ->resize( rhgt, swid );
124 ct_to ->setValue( 0 );
126 ct_to ->setStep ( 1 );
129 QLabel* lb_advplot =
us_banner( tr(
"Advanced Plotting Control" ) );
139 QLabel* lb_status =
us_banner( tr(
"Status" ) );
142 stpal.setColor( QPalette::Text, Qt::white );
143 stpal.setColor( QPalette::Base, Qt::blue );
154 connect(
pb_reset, SIGNAL( clicked() ),
158 connect(
cb_cellchn, SIGNAL( currentIndexChanged(
int ) ),
160 connect(
cb_rstart, SIGNAL( currentIndexChanged(
int ) ),
162 connect(
cb_rend, SIGNAL( currentIndexChanged(
int ) ),
164 connect(
cb_lstart, SIGNAL( currentIndexChanged(
int ) ),
166 connect(
cb_lend, SIGNAL( currentIndexChanged(
int ) ),
168 connect(
ct_recavg, SIGNAL( valueChanged(
double ) ),
170 connect(
cb_pltrec, SIGNAL( currentIndexChanged(
int ) ),
172 connect(
ck_xwavlen, SIGNAL( toggled (
bool ) ),
174 connect(
pb_prev, SIGNAL( clicked() ),
176 connect(
pb_next, SIGNAL( clicked() ),
178 connect(
ct_from, SIGNAL( valueChanged(
double ) ),
180 connect(
ct_to, SIGNAL( valueChanged(
double ) ),
198 connect( pb_help, SIGNAL( clicked() ),
199 this, SLOT (
help() ) );
200 connect( pb_close, SIGNAL( clicked() ),
201 this, SLOT ( close() ) );
205 settings->addWidget( lb_run, row++, 0, 1, 8 );
206 settings->addWidget( lb_dir, row++, 0, 1, 8 );
207 settings->addWidget(
le_dir, row++, 0, 1, 8 );
208 settings->addWidget( lb_runID, row, 0, 1, 2 );
209 settings->addWidget(
le_runID, row++, 2, 1, 6 );
210 settings->addWidget(
pb_loadMwl, row, 0, 1, 4 );
211 settings->addWidget(
pb_loadAUC, row++, 4, 1, 4 );
212 settings->addWidget(
pb_reset, row, 0, 1, 4 );
213 settings->addWidget(
pb_details, row++, 4, 1, 4 );
214 settings->addWidget( lb_cellchn, row, 0, 1, 4 );
215 settings->addWidget(
cb_cellchn, row++, 4, 1, 4 );
216 settings->addWidget( lb_prcntls, row++, 0, 1, 8 );
217 settings->addWidget( lb_rstart, row, 0, 1, 2 );
218 settings->addWidget(
cb_rstart, row, 2, 1, 2 );
219 settings->addWidget( lb_rend, row, 4, 1, 2 );
220 settings->addWidget(
cb_rend, row++, 6, 1, 2 );
221 settings->addWidget( lb_lstart, row, 0, 1, 2 );
222 settings->addWidget(
cb_lstart, row, 2, 1, 2 );
223 settings->addWidget( lb_lend, row, 4, 1, 2 );
224 settings->addWidget(
cb_lend, row++, 6, 1, 2 );
225 settings->addWidget( lb_recavg, row, 0, 1, 2 );
226 settings->addWidget(
ct_recavg, row, 2, 1, 2 );
227 settings->addWidget(
ck_xwavlen, row++, 4, 1, 4 );
228 settings->addWidget(
lb_pltrec, row, 0, 1, 2 );
229 settings->addWidget(
cb_pltrec, row, 2, 1, 2 );
230 settings->addWidget(
pb_prev, row, 4, 1, 2 );
231 settings->addWidget(
pb_next, row++, 6, 1, 2 );
232 settings->addWidget( lb_advplot, row++, 0, 1, 8 );
233 settings->addWidget(
pb_plot2d, row, 0, 1, 4 );
234 settings->addWidget(
pb_movie2d, row++, 4, 1, 4 );
235 settings->addWidget(
pb_plot3d, row, 0, 1, 4 );
236 settings->addWidget(
pb_movie3d, row++, 4, 1, 4 );
237 settings->addWidget(
pb_svplot, row, 0, 1, 4 );
238 settings->addWidget(
pb_svmovie, row++, 4, 1, 4 );
239 settings->addWidget(
ck_hcolorc, row++, 0, 1, 8 );
240 settings->addWidget( lb_scanctl, row++, 0, 1, 8 );
241 settings->addWidget( lb_from, row, 0, 1, 1 );
242 settings->addWidget(
ct_from, row, 1, 1, 3 );
243 settings->addWidget( lb_to, row, 4, 1, 1 );
244 settings->addWidget(
ct_to, row++, 5, 1, 3 );
245 settings->addWidget(
pb_exclude, row, 0, 1, 4 );
246 settings->addWidget(
pb_include, row++, 4, 1, 4 );
247 settings->addWidget( lb_status, row++, 0, 1, 8 );
248 settings->addWidget(
le_status, row++, 0, 1, 8 );
249 settings->addWidget( pb_help, row, 0, 1, 4 );
250 settings->addWidget( pb_close, row++, 4, 1, 4 );
254 tr(
"Intensity Data" ),
255 tr(
"Radius (in cm)" ),
260 data_plot->enableAxis( QwtPlot::xBottom,
true );
261 data_plot->enableAxis( QwtPlot::yLeft ,
true );
263 data_plot->setAxisScale( QwtPlot::xBottom, 5.8, 7.2 );
264 data_plot->setAxisScale( QwtPlot::yLeft , 0.0, 1.5 );
267 picker->setRubberBand ( QwtPicker::VLineRubberBand );
268 picker->setMousePattern ( QwtEventPattern::MouseSelect1,
269 Qt::LeftButton, Qt::ControlModifier );
273 QVBoxLayout* left =
new QVBoxLayout;
275 left->addLayout( settings );
277 QVBoxLayout* right =
new QVBoxLayout;
279 right->addLayout( plot );
281 QHBoxLayout*
main =
new QHBoxLayout(
this );
282 main->setSpacing ( 2 );
283 main->setContentsMargins ( 2, 2, 2, 2 );
285 main->addLayout( left );
286 main->addLayout( right );
288 main->setStretch( 0, 2 );
289 main->setStretch( 1, 4 );
316 ct_to ->setEnabled(
false );
321 ct_to ->setEnabled(
false );
345 data_plot->setAxisScale( QwtPlot::xBottom, 5.8, 7.2 );
346 data_plot->setAxisScale( QwtPlot::yLeft , 0.0, 1.5 );
349 connect(
cb_cellchn, SIGNAL( currentIndexChanged(
int ) ),
358 le_status->setText( tr(
"(no data loaded)" ) );
365 int status = QMessageBox::information(
this,
366 tr(
"New Data Warning" ),
367 tr(
"This will erase all data currently on the screen, and "
368 "reset the program to its starting condition. No hard-drive "
369 "data or database information will be affected. Proceed? " ),
370 tr(
"&OK" ), tr(
"&Cancel" ),
372 if ( status != 0 )
return;
378 data_plot->setTitle( tr(
"Intensity Data" ) );
409 ct_to ->setEnabled(
true );
424 for (
int jj = 0; jj <
npoint; jj++ )
425 slrads << QString().sprintf(
"%.3f",
radii[ jj ] );
427 for (
int jj = 0; jj <
nlambda; jj++ )
428 sllmbs << QString::number(
lambdas[ jj ] );
447 cb_rend ->setCurrentIndex( npoint - 1 );
449 cb_lend ->setCurrentIndex( nlambda - 1 );
458 cb_pltrec ->setCurrentIndex( nlambda / 2 );
459 qApp->processEvents();
470 if ( lddiag.exec() == QDialog::Rejected )
474 qApp->processEvents();
475 if ( dir.isEmpty() )
return;
476 dir.replace(
"\\",
"/" );
479 QDir dirdir( dir,
"*", QDir::Name, QDir::Files | QDir::Readable );
480 dirdir.makeAbsolute();
481 if ( dir.right( 1 ) !=
"/" ) dir +=
"/";
484 QStringList components = dir.split(
"/", QString::SkipEmptyParts );
485 QString runType =
"RI";
486 QString new_runID = components.last();
487 QRegExp rx(
"[^A-Za-z0-9_-]" );
490 bool runID_changed =
false;
491 while ( ( pos = rx.indexIn( new_runID ) ) != -1 )
493 new_runID.replace( pos, 1,
"_" );
494 runID_changed =
true;
500 QMessageBox::warning(
this,
501 tr(
"RunID Name Changed" ),
502 tr(
"The runID name has been changed. It may consist only "
503 "of alphanumeric \ncharacters, the underscore, and the "
504 "hyphen. New runID: " ) + new_runID );
514 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor) );
515 le_status->setText( tr(
"Reading Raw MWL data ..." ) );
522 QApplication::restoreOverrideCursor();
523 QApplication::restoreOverrideCursor();
524 mwl_fnames = dirdir.entryList( QStringList(
"*.mwrs" ),
525 QDir::Files, QDir::Name );
542 connect(
cb_cellchn, SIGNAL( currentIndexChanged(
int ) ),
548 DbgLv(1) <<
"RD: nwl wvlo wvhi" <<
nlambda << wvlo << wvhi;
565 if ( lddiag.exec() == QDialog::Rejected )
569 qApp->processEvents();
571 if ( dir.isEmpty() )
return;
573 dir.replace(
"\\",
"/" );
574 if ( dir.right( 1 ) !=
"/" ) dir +=
"/";
577 QStringList components = dir.split(
"/", QString::SkipEmptyParts );
578 QString new_runID = components.last();
580 QRegExp rx(
"^[A-Za-z0-9_-]{1,80}$" );
581 if ( rx.indexIn( new_runID ) < 0 )
583 QMessageBox::warning(
this,
584 tr(
"Bad runID Name" ),
585 tr(
"The runID name may consist only of alphanumeric\n"
586 "characters, the underscore, and the hyphen." ) );
599 QMessageBox::information(
this,
601 tr(
"The project was not found.\n"
602 "Please select an existing project and try again.\n" ) );
607 QMessageBox::information(
this,
608 tr(
"Disk Read Problem" ),
609 tr(
"Could not read data from the disk.\n"
610 "Disk status: " ) + QString::number( status ) );
614 le_status->setText( tr(
"Reading AUC Mwl data ..." ) );
615 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor) );
616 QDir dirdir( dir,
"*", QDir::Name, QDir::Files | QDir::Readable );
617 dirdir.makeAbsolute();
618 if ( dir.right( 1 ) !=
"/" ) dir +=
"/";
619 mwl_fnames = dirdir.entryList( QStringList(
"*.auc" ),
620 QDir::Files, QDir::Name );
628 for (
int ii = 0; ii <
ntriple; ii++ )
631 QString mwrfpath =
currentDir +
"/" + mwrfname;
638 QString celchn = QString::number( rdata.cell ) +
" / " +
639 QString( rdata.channel );
640 int lambda = qRound( rdata.scanData[ 0 ].wavelength );
645 if ( !
lambdas.contains( lambda ) )
648 le_status->setText( tr(
"Data in for triple %1 of %2" )
649 .arg( ii + 1 ).arg( ntriple ) );
650 qApp->processEvents();
661 DbgLv(1) <<
"RD: mwr ncellch nlambda nscan npoint"
664 le_status->setText( tr(
"All %1 raw AUCs have been loaded." )
666 QApplication::restoreOverrideCursor();
667 QApplication::restoreOverrideCursor();
668 qApp->processEvents();
681 double ofdmax = -1e99;
682 double o90max = -1e99;
683 double ow1max = -1e99;
684 double ow2max = -1e99;
685 double ow3max = -1e99;
686 double afdmax = -1e99;
687 double a90max = -1e99;
688 double aw1max = -1e99;
689 double aw2max = -1e99;
690 double aw3max = -1e99;
691 double ofdmin = 1e99;
692 double o90min = 1e99;
693 double ow1min = 1e99;
694 double ow2min = 1e99;
695 double ow3min = 1e99;
696 double afdmin = 1e99;
697 double a90min = 1e99;
698 double aw1min = 1e99;
699 double aw2min = 1e99;
700 double aw3min = 1e99;
730 int owvmd =
lambdas.indexOf( wvvmid );
731 int rplo = (
npoint * 5 ) / 100;
737 le_status->setText( tr(
"Computing data statistics..." ) );
738 qApp->processEvents();
739 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor) );
742 for (
int ii = 0; ii <
ntriple; ii++ )
744 wv1 = ( wvx == owvlo );
745 wv2 = ( wvx == owvmd );
746 wv3 = ( wvx == owvhi );
750 for (
int jj = 0; jj <
ntpoint; jj++ )
752 rdata =
allData[ ii ].reading( scx, rpx );
753 ofdmin = qMin( ofdmin, rdata );
754 ofdmax = qMax( ofdmax, rdata );
757 if ( rpx > rplo && rpx < rphi )
759 o90min = qMin( o90min, rdata );
760 o90max = qMax( o90max, rdata );
765 ow1min = qMin( ow1min, rdata );
766 ow1max = qMax( ow1max, rdata );
772 ow2min = qMin( ow2min, rdata );
773 ow2max = qMax( ow2max, rdata );
779 ow3min = qMin( ow3min, rdata );
780 ow3max = qMax( ow3max, rdata );
793 DbgLv(1) <<
"DDet: ow3min ow3avg" << ow3min << ow3avg;
802 for (
int ii = 0; ii <
ntriple; ii++ )
804 wv1 = ( wvx == awvlo );
805 wv2 = ( wvx == awvmd );
806 wv3 = ( wvx == awvhi );
809 int wvxs = wvx - nha1;
810 int wvxe = wvx + nha2;
812 wvxs = qMax( wvxs, 0 );
814 wvxe = qMax( wvxe, ( wvxs + 1 ) );
817 avsc = 1.0 / (double)( wvxe - wvxs );
819 for (
int jj = 0; jj <
ntpoint; jj++ )
822 for (
int kk = wvxs; kk < wvxe; kk++ )
823 rdata +=
allData[ kk ].reading( scx, rpx );
825 afdmin = qMin( afdmin, rdata );
826 afdmax = qMax( afdmax, rdata );
829 if ( rpx > rplo && rpx < rphi )
831 a90min = qMin( a90min, rdata );
832 a90max = qMax( a90max, rdata );
837 aw1min = qMin( aw1min, rdata );
838 aw1max = qMax( aw1max, rdata );
844 aw2min = qMin( aw2min, rdata );
845 aw2max = qMax( aw2max, rdata );
851 aw3min = qMin( aw3min, rdata );
852 aw3max = qMax( aw3max, rdata );
865 DbgLv(1) <<
"DDet: aw3min aw3avg" << aw3min << aw3avg;
866 le_status->setText( tr(
"Data statistics have been computed." ) );
867 qApp->processEvents();
868 QApplication::restoreOverrideCursor();
869 QApplication::restoreOverrideCursor();
872 ofdavg /= (double)ofdknt;
873 o90avg /= (double)o90knt;
874 ow1avg /= (double)ow1knt;
875 ow2avg /= (double)ow2knt;
876 ow3avg /= (double)ow3knt;
877 afdavg /= (double)afdknt;
878 a90avg /= (double)a90knt;
879 aw1avg /= (double)aw1knt;
880 aw2avg /= (double)aw2knt;
881 aw3avg /= (double)aw3knt;
882 int lx = ntriple - 1;
883 DbgLv(1) <<
"DDet: aw3knt aw3avg" << aw3knt << aw3avg <<
"lx" << lx;
884 double s1tem =
allData[ 0 ].scanData[ 0 ].temperature;
885 double s1rot =
allData[ 0 ].scanData[ 0 ].rpm;
886 double s1omg =
allData[ 0 ].scanData[ 0 ].omega2t;
887 double s1etm =
allData[ 0 ].scanData[ 0 ].seconds;
888 double s2tem =
allData[ lx ].scanData[ 0 ].temperature;
889 double s2rot =
allData[ lx ].scanData[ 0 ].rpm;
890 double s2omg =
allData[ lx ].scanData[ 0 ].omega2t;
891 double s2etm =
allData[ lx ].scanData[ 0 ].seconds;
894 DbgLv(1) <<
"DDet: owvmin owvmax" << owvmin << owvmax;
895 double owvain = ( owvmax - owvmin ) / (
double)(
nlambda - 1 );
896 double awvain = ( owvmax - owvmin ) / (
double)(
nlambda - 1 );
897 double wavv1 = owvmin;
898 double wavv2 =
lambdas[ owvmd ];
899 double wavv3 = owvmax;
900 DbgLv(1) <<
"DDet: owvmd wavv2" << owvmd << wavv2;
902 DbgLv(1) <<
"DDet: ffname" << ffname;
905 DbgLv(1) <<
"DDet: lfname" << lfname;
906 QString msg = tr(
"Multi-Wavelength Statistics for RunID %1,\n" )
908 msg += tr(
" from Directory %1\n\n" ).arg(
currentDir );
909 msg += tr(
"General Data Set Values and Counts.\n" );
910 msg += tr(
" First File Name: %1\n" ).arg( ffname );
911 msg += tr(
" Last File Name: %1\n" ).arg( lfname );
912 msg += tr(
" Scans: %1\n" ).arg(
nscan );
913 msg += tr(
" Radius Data Points: %1\n" ).arg(
npoint );
914 msg += tr(
"Values for 1st Cell/Channel Scan 1.\n" );
915 msg += tr(
" Temperature %1\n" ).arg( s1tem );
916 msg += tr(
" Omega^2T %1\n" ).arg( s1omg );
917 msg += tr(
" Elapsed Time %1\n" ).arg( s1etm );
918 msg += tr(
" RotorSpeed %1\n" ).arg( s1rot );
919 msg += tr(
"Values for Last Cell/Channel Scan %1.\n" ).arg(
nscan );
920 msg += tr(
" Temperature %1\n" ).arg( s2tem );
921 msg += tr(
" Omega^2T %1\n" ).arg( s2omg );
922 msg += tr(
" Elapsed Time %1\n" ).arg( s2etm );
923 msg += tr(
" RotorSpeed %1\n" ).arg( s2rot );
924 msg += tr(
"Original Data Wavelengths.\n" );
925 msg += tr(
" Count of Wavelengths: %1\n" ).arg(
nlambda );
926 msg += tr(
" Minimum: %1\n" ).arg( owvmin );
927 msg += tr(
" Maximum: %1\n" ).arg( owvmax );
928 msg += tr(
" Average Increment: %1\n" ).arg( owvain );
929 msg += tr(
"%1-point Averaged Data Wavelengths.\n" ).arg(
navgrec );
930 msg += tr(
" Count of Wavelengths: %1\n" ).arg(
klambda );
931 msg += tr(
" Minimum: %1\n" ).arg( owvmin );
932 msg += tr(
" Maximum: %1\n" ).arg( owvmax );
933 msg += tr(
" Average Increment: %1\n" ).arg( awvain );
934 msg += tr(
"\nOriginal Full Intensity Data.\n" );
935 msg += tr(
" Minimum: %1\n" ).arg( ofdmin );
936 msg += tr(
" Maximum: %1\n" ).arg( ofdmax );
937 msg += tr(
" Average: %1\n" ).arg( ofdavg );
938 msg += tr(
"%1-point Averaged Full Intensity Data.\n" ).arg(
navgrec );
939 msg += tr(
" Minimum: %1\n" ).arg( afdmin );
940 msg += tr(
" Maximum: %1\n" ).arg( afdmax );
941 msg += tr(
" Average: %1\n" ).arg( afdavg );
942 msg += tr(
"Original Middle 90% Intensity Data.\n" );
943 msg += tr(
" Minimum: %1\n" ).arg( o90min );
944 msg += tr(
" Maximum: %1\n" ).arg( o90max );
945 msg += tr(
" Average: %1\n" ).arg( o90avg );
946 msg += tr(
"%1-point Averaged Middle 90% Intensity Data.\n" ).arg(
navgrec );
947 msg += tr(
" Minimum: %1\n" ).arg( a90min );
948 msg += tr(
" Maximum: %1\n" ).arg( a90max );
949 msg += tr(
" Average: %1\n" ).arg( a90avg );
950 msg += tr(
"%1 nm Original Middle 90% Intensity Data.\n" )
952 msg += tr(
" Minimum: %1\n" ).arg( ow1min );
953 msg += tr(
" Maximum: %1\n" ).arg( ow1max );
954 msg += tr(
" Average: %1\n" ).arg( ow1avg );
955 msg += tr(
"%1 nm %2-point Averaged Middle 90% Intensity Data.\n" )
957 msg += tr(
" Minimum: %1\n" ).arg( aw1min );
958 msg += tr(
" Maximum: %1\n" ).arg( aw1max );
959 msg += tr(
" Average: %1\n" ).arg( aw1avg );
960 msg += tr(
"%1 nm Original Middle 90% Intensity Data.\n" )
962 msg += tr(
" Minimum: %1\n" ).arg( ow2min );
963 msg += tr(
" Maximum: %1\n" ).arg( ow2max );
964 msg += tr(
" Average: %1\n" ).arg( ow2avg );
965 msg += tr(
"%1 nm %2-point Averaged Middle 90% Intensity Data.\n" )
967 msg += tr(
" Minimum: %1\n" ).arg( aw2min );
968 msg += tr(
" Maximum: %1\n" ).arg( aw2max );
969 msg += tr(
" Average: %1\n" ).arg( aw2avg );
970 msg += tr(
"%1 nm Original Middle 90% Intensity Data.\n" )
972 msg += tr(
" Minimum: %1\n" ).arg( ow3min );
973 msg += tr(
" Maximum: %1\n" ).arg( ow3max );
974 msg += tr(
" Average: %1\n" ).arg( ow3avg );
975 msg += tr(
"%1 nm %2-point Averaged Middle 90% Intensity Data.\n" )
977 msg += tr(
" Minimum: %1\n" ).arg( aw3min );
978 msg += tr(
" Maximum: %1\n" ).arg( aw3max );
979 msg += tr(
" Average: %1\n" ).arg( aw3avg );
983 editd->setWindowTitle( tr(
"Multi-Wavelength Data Statistics" ) );
984 editd->move( pos() + QPoint( 200, 200 ) );
985 editd->resize( 600, 500 );
988 editd->
e->setText( msg );
996 DbgLv(1) <<
"chgCC: cellch" << cellch <<
"last_xmin" <<
last_xmin;
1000 if ( last_xmin < 0.0 )
1016 last_xmin = qMin( last_xmin, edata->
xvalues[ rdx ] );
1030 for (
int trx = trxs; trx < trxe; trx++ )
1034 for (
int scx = 0; scx <
nscan; scx++ )
1043 DbgLv(1) <<
"chgCC: trxs trxe" << trxs << trxe;
1048 QwtScaleDiv* sdx =
data_plot->axisScaleDiv( QwtPlot::xBottom );
1049 QwtScaleDiv* sdy =
data_plot->axisScaleDiv( QwtPlot::yLeft );
1050 last_xmin = sdx->lowerBound();
1055 DbgLv(1) <<
"chgCC: xmin xmax ymin ymax"
1082 QString cell = cellch.section(
"/", 0, 0 ).simplified();
1083 QString chan = cellch.section(
"/", 1, 1 ).simplified();
1084 QString prec =
cb_pltrec->currentText();
1087 QString title =
"Radial Intensity Data\nRun ID: " +
runID +
1088 "\n Cell: " + cell +
" Channel: " + chan;
1090 QString yLegend =
"Radial Intensity at " + prec;
1094 title += QString(
" Wavelength: " ) + prec;
1095 xLegend = QString(
"Radius (in cm)" );
1096 yLegend += QString(
" nm" );
1101 title += QString(
" Radius: " ) + prec;
1102 xLegend = QString(
"Wavelength (in nm)" );
1103 yLegend += QString(
" cm" );
1107 data_plot->setAxisTitle( QwtPlot::yLeft, yLegend );
1108 data_plot->setAxisTitle( QwtPlot::xBottom, xLegend );
1125 QVector< double > rvec(
kpoint );
1126 QVector< double > vvec(
kpoint );
1127 double* rr = rvec.data();
1128 double* vv = vvec.data();
1130 int scan_from = (int)
ct_from->value();
1131 int scan_to = (int)
ct_to ->value();
1133 QPen pen_red ( Qt::red );
1137 for (
int ptx = 0; ptx <
kpoint; ptx++ )
1140 for (
int scnx = 0; scnx <
nscan; scnx++ )
1142 if (
excludes.contains( scnx ) )
continue;
1144 for (
int ptx = 0; ptx <
kpoint; ptx++ )
1150 QString title = tr(
"Raw Data at scan " )
1151 + QString::number( scan_nbr );
1154 if ( scan_nbr > scan_to || scan_nbr < scan_from )
1155 curv->setPen( pen_plot );
1157 curv->setPen( pen_red );
1159 curv->setData( rr, vv, kpoint );
1167 data_plot->setAxisAutoScale( QwtPlot::yLeft );
1168 data_plot->setAxisAutoScale( QwtPlot::xBottom );
1181 QwtScaleDiv* sdx =
data_plot->axisScaleDiv( QwtPlot::xBottom );
1182 QwtScaleDiv* sdy =
data_plot->axisScaleDiv( QwtPlot::yLeft );
1194 DbgLv(1) <<
"chgRadius";
1205 QString citem = QString().sprintf(
"%.3f",
radii[ rdx ] );
1210 connect(
cb_pltrec, SIGNAL( currentIndexChanged(
int ) ),
1223 DbgLv(1) <<
"chgLambda";
1234 QString citem = QString::number(
lambdas[ wvx ] );
1239 connect(
cb_pltrec, SIGNAL( currentIndexChanged(
int ) ),
1254 bool plt_one = !
le_status->text().contains( tr(
"saving" ) );
1272 DbgLv(1) <<
"chgRtype: wlnrec" << wlnrec;
1283 lb_pltrec->setText( tr(
"Plot (W nm)" ) );
1290 lb_pltrec->setText( tr(
"Plot (R cm)" ) );
1305 int pltrx =
cb_pltrec->currentIndex() - 1;
1313 QwtScaleDiv* sdx =
data_plot->axisScaleDiv( QwtPlot::xBottom );
1314 QwtScaleDiv* sdy =
data_plot->axisScaleDiv( QwtPlot::yLeft );
1326 int pltrx =
cb_pltrec->currentIndex() + 1;
1329 if ( ( pltrx + 2 ) > nitems )
1335 QwtScaleDiv* sdx =
data_plot->axisScaleDiv( QwtPlot::xBottom );
1336 QwtScaleDiv* sdy =
data_plot->axisScaleDiv( QwtPlot::yLeft );
1348 DbgLv(1) <<
"chgAvg:";
1362 QVector< double > fillv;
1367 int kavgh = kavgc / 2;
1368 int arxs =
recx - kavgh;
1369 int arxe =
recx + kavgh;
1370 arxs = qMax( arxs, 0 );
1371 arxe = qMin( arxe,
krecs - 1 ) + 1;
1372 arxe = qMax( arxe, ( arxs + 1 ) );
1373 kavgc = arxe - arxs;
1375 DbgLv(1) <<
"BldC: kavgc" << kavgc <<
"arxs arxe" << arxs << arxe;
1378 for (
int krx = arxs; krx < arxe; krx++, jrx++ )
1381 DbgLv(1) <<
"BldC: krx" << krx <<
"prx" << prx;
1408 double avgscl = 1.0 / (double)kavgc;
1409 DbgLv(1) <<
"BldA: kavgc" << kavgc <<
"ktpoint" <<
ktpoint;
1417 for (
int ptx = 0; ptx <
ktpoint; ptx++ )
1421 for (
int rcx = 0; rcx < kavgc; rcx++ )
1424 if(ptx==(ktpoint/2))
1425 DbgLv(1) <<
"BldA: ptx rcx" << ptx << rcx <<
"cdat dsum"
1439 QVector< double >& rdata )
1454 for (
int scnx = 0; scnx <
nscan; scnx++ )
1456 if (
excludes.contains( scnx ) )
continue;
1458 for (
int radx =
radxs; radx <
radxe; radx++ )
1460 rdata <<
allData[ trpx ].reading( scnx, radx );
1465 DbgLv(1) <<
"BldR: kscan" <<
kscan <<
"rd size" << rdata.size();
1475 for (
int scnx = 0; scnx <
nscan; scnx++ )
1477 if (
excludes.contains( scnx ) )
continue;
1479 for (
int wavx = wavxs; wavx < wavxe; wavx++ )
1481 rdata <<
allData[ wavx ].reading( scnx, recx );
1518 for (
int jj = radxs; jj <
radxe; jj++ )
1526 for (
int jj = lmbxs; jj <
lmbxe; jj++ )
1539 connect(
cb_cellchn, SIGNAL( currentIndexChanged(
int ) ),
1541 connect(
cb_rstart, SIGNAL( currentIndexChanged(
int ) ),
1543 connect(
cb_rend, SIGNAL( currentIndexChanged(
int ) ),
1545 connect(
cb_lstart, SIGNAL( currentIndexChanged(
int ) ),
1547 connect(
cb_lend, SIGNAL( currentIndexChanged(
int ) ),
1549 connect(
cb_pltrec, SIGNAL( currentIndexChanged(
int ) ),
1567 int scan_from = (int)sfr;
1568 int scan_to = (int)
ct_to ->value();
1570 if ( scan_to < scan_from )
1572 ct_to ->disconnect();
1573 ct_to ->setValue( scan_from );
1575 connect(
ct_to, SIGNAL( valueChanged(
double ) ),
1585 int scan_to = (int)sto;
1586 int scan_from = (int)
ct_from->value();
1588 if ( scan_from > scan_to )
1593 connect(
ct_from, SIGNAL( valueChanged(
double ) ),
1603 int scan_from = (int)
ct_from->value();
1604 int scan_to = (int)
ct_to ->value();
1607 for (
int scnx = 0; scnx <
nscan; scnx++ )
1609 if (
excludes.contains( scnx ) )
continue;
1611 if ( scan_knt >= scan_from && scan_knt <= scan_to )
1625 ct_to ->disconnect();
1628 connect(
ct_from, SIGNAL( valueChanged(
double ) ),
1630 connect(
ct_to, SIGNAL( valueChanged(
double ) ),
1632 ct_to ->setValue( 0 );
1648 ct_to ->setValue( 0 );
1652 ct_to ->disconnect();
1655 connect(
ct_from, SIGNAL( valueChanged(
double ) ),
1657 connect(
ct_to, SIGNAL( valueChanged(
double ) ),
1659 ct_to ->setValue( 0 );
1666 DbgLv(1) <<
"Show 2D Movie";
1672 for (
int prx = 0; prx <
krecs; prx++ )
1675 qApp->processEvents();
1679 qApp->processEvents();
1685 DbgLv(1) <<
"Plt3D";
1688 DbgLv(1) <<
"Plt3D: open MPC";
1695 int cx = qApp->desktop()->width() -
p3d_ctld->width() - 40;
1698 connect(
p3d_ctld, SIGNAL( has_closed() ),
1714 QString ptitle = tr(
"MWL 3-D Plot, Scan " )
1715 + QString::number( scan_nbr );
1740 QMessageBox::warning(
this,
1741 tr(
"3-D Plot Window Not Opened" ),
1742 tr(
"You cannot start a 3-D movie until you have first"
1743 " opened the small plot control dialog by clicking"
1744 " on the \"Plot 3D\" button in this program's main"
1745 " window. From that control dialog you must click"
1746 " on the \"3D Plot\" button to open the 3-D plotting"
1747 " window.\n\nYou should insure that scale and"
1748 " orientation are correct for the current plot, as"
1749 " these will be in force for each movie frame."
1750 " You may then again click on \"Show 3D Movie\"." ) );
1760 DbgLv(1) <<
"sh3M: fscnx lscnx krscan" << fscnx << lscnx << krscan;
1762 QString statmsg = (
nscan == krscan )
1763 ? tr(
"Of %1 scans, showing: Scan " ).arg(
nscan )
1764 : tr(
"Of %1 in-range, included scans (%2 total),"
1765 " showing: Scan " ).arg( krscan ).arg(
nscan );
1766 QString ptbase = tr(
"MWL 3-D Plot, Scan SSS" );
1767 QString ptitle = tr(
"MWL 3-D Plot, Scan 1" );
1771 for (
int scnx = fscnx; scnx <= lscnx; scnx++ )
1773 if (
excludes.contains( scnx ) )
continue;
1779 str_scan = QString::number( ( scnx + 1 ) );
1780 ptitle = QString( ptbase ).replace(
"SSS", str_scan );
1783 DbgLv(1) <<
"sh3M: scnx ptitle" << scnx << ptitle;
1785 le_status->setText( statmsg + str_scan );
1786 qApp->processEvents();
1793 DbgLv(1) <<
"Save Plot";
1795 QDir().mkpath( savedir );
1796 savedir = savedir.replace(
"\\",
"/" ) +
"/";
1798 ?
".radRec_RRRRR_2D.png"
1799 :
".lmbRec_RRRRR_2D.png" );
1800 QString fname3d =
runID +
".Scan_SSSS_3D.png";
1802 int nfiles = (
p3d_pltw != NULL ) ? 2 : 1;
1806 int scan_fr = (int)
ct_from->value();
1807 int scan_to = (int)
ct_to ->value();
1808 scan_fr = ( scan_to < 1 ) ? 1 : scan_fr;
1812 for (
int scnx = 0; scnx <
nscan; scnx++ )
1814 if (
excludes.contains( scnx ) )
continue;
1816 if ( scan_knt < scan_fr )
continue;
1817 scan_nbr = scnx + 1;
1822 QString s_scan = QString().sprintf(
"%04d", scan_nbr );
1823 fname3d = fname3d.replace(
"SSSS", s_scan );
1824 QString fpath3d = savedir + fname3d;
1826 p3d_pltw->save_plot( fpath3d, QString(
"png" ) );
1830 QString ccr =
cb_cellchn->currentText().remove(
" / " );
1831 QString rec_str = ccr +
cb_pltrec->currentText().remove(
"." );
1832 fname2d = fname2d.replace(
"RRRRR", rec_str );
1833 QString fpath2d = savedir + fname2d;
1838 QString mtitle = ( nfiles == 1 )
1839 ? tr(
"Plot File Saved" )
1840 : tr(
"Plot Files Saved" );
1841 QString msg = tr(
"In the directory\n %1,\n\n" ).arg( savedir );
1843 msg += tr(
"File\n %1 was saved." ).arg( fname2d );
1845 msg += tr(
"Files\n %1 ; and\n %2\nwere saved." )
1846 .arg( fname3d ).arg( fname2d );
1848 QMessageBox::information(
this, mtitle, msg );
1854 bool save_2d =
true;
1855 bool save_3d = (
p3d_pltw != NULL );
1857 DbgLv(1) <<
"Save Movie";
1860 QMessageBox msgBox(
this );
1861 msgBox.setWindowTitle( tr(
"Multiple Possible Movie Saves" ) );
1862 msgBox.setTextFormat( Qt::RichText );
1864 tr(
"A 3-D plot window is opened, so you may save both a "
1865 "3-D movie and a 2-D one; or you may choose to save "
1866 "only one.<br/><br/>Save both?<ul>"
1867 "<li><b>Yes</b> to save both movies;</li>"
1868 "<li><b>No</b> to save just the 3-D movie;</li>"
1869 "<li><b>Cancel</b> to cancel any save in order "
1870 "to edit/close the 3-D window.</li></ul>" ) );
1871 msgBox.addButton( QMessageBox::Yes );
1872 msgBox.addButton( QMessageBox::No );
1873 msgBox.addButton( QMessageBox::Cancel );
1874 msgBox.setDefaultButton( QMessageBox::Yes );
1875 int stat = msgBox.exec();
1877 save_3d = ( stat != QMessageBox::Cancel );
1878 save_2d = ( stat == QMessageBox::Yes );
1891 DbgLv(1) <<
"Save 2D Movie";
1897 QDir().mkpath( savedir );
1898 savedir = savedir.replace(
"\\",
"/" ) +
"/";
1900 ?
".radRec_RRRRR_2D_frame_XXXXX.png"
1901 :
".lmbRec_RRRRR_2D_frame_XXXXX.png" );
1902 QString ccr =
cb_cellchn->currentText().remove(
" / " );
1903 QString bstat = tr(
"Of %1 records, saving record " ).arg( krecs );
1906 for (
int prx = 0; prx <
krecs; prx++ )
1909 qApp->processEvents();
1911 QString rec_str = ccr +
cb_pltrec->currentText().remove(
"." );
1912 QString frm_str = QString().sprintf(
"%05d", ( prx + 1 ) );
1913 QString fname = QString( bfname ).replace(
"RRRRR", rec_str )
1914 .replace(
"XXXXX", frm_str );
1915 QString fpath = savedir + fname;
1917 le_status->setText( bstat + rec_str +
", frame " + frm_str );
1924 qApp->processEvents();
1926 QMessageBox::information(
this, tr(
"Frame Files Saved" ),
1927 tr(
"In the directory\n %1,\n\n%2 2-D movie frame files"
1928 " were saved:\n %3\n ...\n %4 ." )
1929 .arg( savedir ).arg( krecs ).arg( fnames[ 0 ] )
1930 .arg( fnames[ krecs - 1 ] ) );
1936 DbgLv(1) <<
"Save 3-D Movie";
1948 QMessageBox::warning(
this,
1949 tr(
"3-D Plot Window Not Opened" ),
1950 tr(
"You cannot save a 3-D movie until you have first"
1951 " opened a 3-D plotting window by clicking on the"
1952 " \"3D Plot\" button in the small plot control"
1953 " dialog.\n\nYou should insure that scale and"
1954 " orientation are correct for the current plot, as"
1955 " these will be in force for each movie frame."
1956 " You may then again click on \"Save Movie(s)\"." ) );
1968 QStringList ffnames;
1969 QString imgtype(
"png" );
1970 QString ptbase = tr(
"MWL 3-D Plot, Scan SSS" );
1971 QString statmsg = tr(
"Of %1 included in-range scans,"
1972 " saving: Scan " ).arg( krscan );
1974 QDir().mkpath( savedir );
1975 savedir = savedir.replace(
"\\",
"/" ) +
"/";
1976 QString bfname =
runID +
".Scan_SSSS_3D_frame_XXXX.png";
1977 QApplication::setOverrideCursor( QCursor( Qt::WaitCursor) );
1981 for (
int scnx = fscnx; scnx <= lscnx; scnx++ )
1983 if (
excludes.contains( scnx ) )
continue;
1990 int scan_nbr = scnx + 1;
1991 QString t_scan = QString::number( scan_nbr );
1992 QString ptitle = QString( ptbase ).replace(
"SSS", t_scan );
1997 qApp->processEvents();
2000 QString s_scan = QString().sprintf(
"%04d", scan_nbr );
2001 QString s_frame = QString().sprintf(
"%04d", kframe );
2002 QString fname = QString( bfname ).replace(
"SSSS", s_scan )
2003 .replace(
"XXXX", s_frame );
2004 QString fpath = savedir + fname;
2006 p3d_pltw->save_plot( fpath, imgtype );
2009 qApp->processEvents();
2012 QApplication::restoreOverrideCursor();
2013 QApplication::restoreOverrideCursor();
2016 QMessageBox::information(
this,
2017 tr(
"Frame Files Saved" ),
2018 tr(
"In the directory\n %1,\n\n%2 3-D movie frame files"
2019 " were saved:\n %3\n ...\n %4 ." )
2020 .arg( savedir ).arg( kframe ).arg( ffnames[ 0 ] )
2021 .arg( ffnames[ kframe - 1 ] ) );
2027 const double eps = 1.e-4;
2029 int indx = dvec.indexOf( dval );
2034 for (
int jj = 0; jj < dvec.size(); jj++ )
2036 double ddif = qAbs( dvec[ jj ] - dval );
2058 int scan_fr = (int)
ct_from->value();
2059 int scan_to = (int)
ct_to ->value();
2060 scan_fr = ( scan_to < 1 ) ? 1 : scan_fr;
2061 scan_to = ( scan_to < 1 ) ?
kscan : scan_to;
2068 for ( scnx = 0; scnx <
nscan; scnx++ )
2070 if (
excludes.contains( scnx ) )
continue;
2072 if ( scan_knt >= scan_fr )
2081 for ( scnx = 0; scnx <
nscan; scnx++ )
2083 if (
excludes.contains( scnx ) )
continue;
2085 if ( scan_knt >= scan_fr && scan_knt <= scan_to && scnx == scan )
2092 if ( scnx >=
nscan )
2094 qDebug() <<
"BldXYZ: *ERROR* scan invalid:" << scan <<
nscan;
2098 QVector< int > lmb3d;
2099 QVector< double > rad3d;
2102 for (
int lmbx =
lmbxs; lmbx <
lmbxe; lmbx++ )
2106 for (
int radx =
radxs; radx <
radxe; radx++ )
2107 rad3d <<
radii[ radx ];
2112 << lmb3d[0] << lmb3d[
k3dlamb-1];
2114 << rad3d[0] << rad3d[
k3drads-1];
2121 for (
int klx = 0; klx <
k3dlamb; klx++, wvx++ )
2123 int lambda = lmb3d[ klx ];
2124 int wvxs = qMax( ( wvx - nhavg ), 0 );
2126 int kavgc = wvxe - wvxs;
2127 int trxs =
trpxs + wvxs;
2128 int trxe =
trpxs + wvxe;
2130 double yval = (double)lambda;
2132 for (
int krx = 0; krx <
k3drads; krx++, rdx++ )
2134 double xval = rad3d[ krx ];
2137 for (
int trx = trxs; trx < trxe; trx++ )
2138 zval +=
allData[ trx ].reading( scnx, rdx );
2140 zval /= (double)kavgc;
2142 xyzd << QVector3D( xval, yval, zval );
2143 DbgLv(2) <<
"Bxyz: k" << xyzd.count() <<
"x y z" << xval << yval << zval;
2147 k3dtot = xyzd.count();
2154 DbgLv(1) <<
"Bxyz: k3dtot" << k3dtot <<
"k3l k3r" << k3dlamb <<
k3drads;
2155 DbgLv(1) <<
"Bxyz: xyz0" << xyzd[0] << 0;
2156 DbgLv(1) <<
"Bxyz: xyz1" << xyzd[1] << 1;
2157 DbgLv(1) <<
"Bxyz: xyzh" << xyzd[
h] <<
h;
2158 DbgLv(1) <<
"Bxyz: xyzi" << xyzd[i] << i;
2159 DbgLv(1) <<
"Bxyz: xyzj" << xyzd[j] << j;
2160 DbgLv(1) <<
"Bxyz: xyzj" << xyzd[k] << k;
2161 DbgLv(1) <<
"Bxyz: xyzm" << xyzd[m] << m;
2162 DbgLv(1) <<
"Bxyz: xyzn" << xyzd[n] << n;
2182 int scan_fr = (int)
ct_from->value();
2183 int scan_to = (int)
ct_to ->value();
2184 scan_fr = ( scan_to < 1 ) ? 1 : scan_fr;
2185 scan_to = ( scan_to < 1 ) ?
nscan : scan_to;
2188 for (
int scnx = 0; scnx <
nscan; scnx++ )
2190 if (
excludes.contains( scnx ) )
continue;
2194 if ( scan_knt < scan_fr || scan_knt > scan_to )
continue;
2203 if ( fsP != NULL ) *fsP = fscnx;
2204 if ( lsP != NULL ) *lsP = lscnx;
2205 if ( ksP != NULL ) *ksP = krscan;
2207 return ( fscnx + 1 );