Skip to content

Commit

Permalink
GMP: 1.EXP - [progress on] working on switch btw SV & ABDE expTypes: …
Browse files Browse the repository at this point in the history
…different dynamic initializations of gui/internalts for Report|ReportItems, proper saving in memory for duration of certain type of exptype...
  • Loading branch information
alexsav815 committed Apr 8, 2024
1 parent cbf7d75 commit f996b42
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 89 deletions.
239 changes: 150 additions & 89 deletions gui/us_report_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ US_ReportGui::US_ReportGui( QMap < QString, US_ReportGMP* > report_map ) : US_Wi
this->report_map = report_map;

QList < QString > report_map_keys = report_map.keys();
QStringList wvl_passed;
wvl_passed. clear();
for ( int i=0; i < report_map_keys.size(); ++i )
wvl_passed << report_map_keys[ i ];

Expand All @@ -37,7 +37,7 @@ US_ReportGui::US_ReportGui( QMap < QString, US_ReportGMP* > report_map ) : US_Wi
if ( wvl_passed.size() == 1 && !wvl_passed[0].toInt() )
wvl_passed.clear();

int init_index = 0; // 1st in a QMap;
init_index = 0; // 1st in a QMap;

this->report = report_map[ report_map_keys[ init_index ] ];
this->report_copy_original = *report;
Expand All @@ -53,17 +53,73 @@ US_ReportGui::US_ReportGui( QMap < QString, US_ReportGMP* > report_map ) : US_Wi
/////////////////////////////////////////////////

setWindowTitle( tr( "Channel Report Editor"));

//setPalette( US_GuiSettings::frameColor() );
setPalette( US_GuiSettings::normalColor() );

main = new QVBoxLayout( this );
main->setSpacing( 2 );
main->setContentsMargins( 2, 2, 2, 2 );

//Top level parameters
QLabel* bn_report = us_banner( QString( tr( "Report Parameters for channel: %1" ) ).arg( report->channel_name ), 1 );
bn_report->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
main->addWidget( bn_report );
main->addWidget( bn_report ); // row++, 0, 1,-1 );

//Main Table
bn_report_t = NULL;
params = NULL;
genL = NULL;
addRem_buttons = NULL;
reportmask = NULL;
lower_buttons = NULL;

build_report_layout();

}

//ABDE
void US_ReportGui::abde_mode_passed( void )
{
abde_mode = true;
build_report_layout();
}

//Exp. Durat. counters
void US_ReportGui::ssChgDuratTime_dd( int val )
{
report->exp_time_changed = true;
}
void US_ReportGui::ssChgDuratTime_hh( int val )
{
report->exp_time_changed = true;
}
void US_ReportGui::ssChgDuratTime_mm( int val )
{
report->exp_time_changed = true;
}
void US_ReportGui::ssChgDuratTime_ss( int val )
{
report->exp_time_changed = true;
}

//Layout build
void US_ReportGui::build_report_layout( void )
{
qDebug() << "Building Tabular Layout -- ";

//clean params: upper panel
if ( params != NULL && params->layout() != NULL )
{
QLayoutItem* item;
while ( ( item = params->layout()->takeAt( 0 ) ) != NULL )
{
delete item->widget();
delete item;
}
delete params;
delete topContainerWidget;
}
qDebug() << "after params deletion";
//End cleaning layout

params = new QGridLayout();
params ->setSpacing ( 2 );
Expand Down Expand Up @@ -158,30 +214,56 @@ US_ReportGui::US_ReportGui( QMap < QString, US_ReportGMP* > report_map ) : US_Wi
////////////////////////////////////////////////////////////////////////////

row = 0;
params->addWidget( lb_tot_conc, row, 0, 1, 2 );
params->addWidget( le_tot_conc, row, 2, 1, 2 );

params->addWidget( lb_tot_conc_tol, row, 4, 1, 2 );
params->addWidget( le_tot_conc_tol, row, 6, 1, 2 );

params->addWidget( lb_rmsd_limit, row, 8, 1, 2 );
params->addWidget( le_rmsd_limit, row, 10, 1, 2 );

params->addWidget( lb_wvl, row, 12, 1, 2 );
params->addWidget( cb_wvl, row++, 14, 1, 2 );

params->addWidget( lb_duration, row, 0, 1, 2 );
params->addLayout( lo_duratlay, row, 2, 1, 2 );

params->addWidget( lb_duration_tol, row, 4, 1, 2 );
params->addWidget( le_duration_tol, row, 6, 1, 2 );

params->addWidget( lb_av_intensity, row, 8, 1, 2 );
params->addWidget( le_av_intensity, row, 10, 1, 2 );

params->addWidget( pb_prev_wvl, row, 12, 1, 2 );
params->addWidget( pb_next_wvl, row++, 14, 1, 2 );
params->addWidget( pb_apply_all, row++, 14, 1, 2 );
if (!abde_mode )
{
params->addWidget( lb_tot_conc, row, 0, 1, 2 );
params->addWidget( le_tot_conc, row, 2, 1, 2 );

params->addWidget( lb_tot_conc_tol, row, 4, 1, 2 );
params->addWidget( le_tot_conc_tol, row, 6, 1, 2 );

params->addWidget( lb_rmsd_limit, row, 8, 1, 2 );
params->addWidget( le_rmsd_limit, row, 10, 1, 2 );

params->addWidget( lb_wvl, row, 12, 1, 2 );
params->addWidget( cb_wvl, row++, 14, 1, 2 );

params->addWidget( lb_duration, row, 0, 1, 2 );
params->addLayout( lo_duratlay, row, 2, 1, 2 );

params->addWidget( lb_duration_tol, row, 4, 1, 2 );
params->addWidget( le_duration_tol, row, 6, 1, 2 );

params->addWidget( lb_av_intensity, row, 8, 1, 2 );
params->addWidget( le_av_intensity, row, 10, 1, 2 );

params->addWidget( pb_prev_wvl, row, 12, 1, 2 );
params->addWidget( pb_next_wvl, row++, 14, 1, 2 );
params->addWidget( pb_apply_all, row++, 14, 1, 2 );
}
else
{
params->addWidget( lb_duration, row, 0, 1, 2 );
params->addLayout( lo_duratlay, row, 2, 1, 2 );

params->addWidget( lb_duration_tol, row, 4, 1, 2 );
params->addWidget( le_duration_tol, row, 6, 1, 2 );

lb_tot_conc -> setVisible( false );
le_tot_conc -> setVisible( false );
lb_tot_conc_tol -> setVisible( false );
le_tot_conc_tol -> setVisible( false );
lb_rmsd_limit -> setVisible( false );
le_rmsd_limit -> setVisible( false );
lb_wvl -> setVisible( false );
cb_wvl -> setVisible( false );
lb_av_intensity -> setVisible( false );
le_av_intensity -> setVisible( false );
pb_prev_wvl -> setVisible( false );
pb_next_wvl -> setVisible( false );
pb_apply_all -> setVisible( false );

}

// int ihgt = le_tot_conc->height();
// QSpacerItem* spacer1 = new QSpacerItem( 20, 0.75*ihgt, QSizePolicy::Expanding );
Expand All @@ -193,7 +275,7 @@ US_ReportGui::US_ReportGui( QMap < QString, US_ReportGMP* > report_map ) : US_Wi
main->addWidget( topContainerWidget );

////////////////////////////////////////////////////////////////////////////
if ( report_map_keys.size() == 1) //single-wvl
if ( report_map.keys().size() == 1) //single-wvl
{
pb_prev_wvl ->setEnabled( false );
pb_next_wvl ->setEnabled( false );
Expand All @@ -212,52 +294,16 @@ US_ReportGui::US_ReportGui( QMap < QString, US_ReportGMP* > report_map ) : US_Wi
if ( (init_index + 1 ) == cb_wvl->count() )
pb_next_wvl ->setEnabled( false );

//main->addLayout( params );

//Banner for Table
QLabel* bn_report_t = us_banner( tr( "Report Parameters: Type | Method" ) );
if ( bn_report_t != NULL )
delete bn_report_t;

bn_report_t = us_banner( tr( "Report Parameters: Type | Method" ) );
bn_report_t->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
main->addWidget( bn_report_t );

//Main Table
genL = NULL;
addRem_buttons = NULL;
reportmask = NULL;
lower_buttons = NULL;

build_report_layout();

}

//ABDE
void US_ReportGui::abde_mode_passed( void )
{
abde_mode = true;
build_report_layout();
}

//Exp. Durat. counters
void US_ReportGui::ssChgDuratTime_dd( int val )
{
report->exp_time_changed = true;
}
void US_ReportGui::ssChgDuratTime_hh( int val )
{
report->exp_time_changed = true;
}
void US_ReportGui::ssChgDuratTime_mm( int val )
{
report->exp_time_changed = true;
}
void US_ReportGui::ssChgDuratTime_ss( int val )
{
report->exp_time_changed = true;
}

//Layout build
void US_ReportGui::build_report_layout( void )
{
qDebug() << "Building Tabular Layout -- ";

//Clean genL layout first:
if ( genL != NULL && genL->layout() != NULL )
{
Expand All @@ -278,7 +324,7 @@ void US_ReportGui::build_report_layout( void )
genL = new QGridLayout();
genL ->setSpacing ( 2 );
genL ->setContentsMargins ( 2, 2, 2, 2 );

//Table Header
QLabel* lb_type = us_label( tr( "Type" ) );
QLabel* lb_method = us_label( tr( "Method" ) );
Expand All @@ -292,6 +338,7 @@ void US_ReportGui::build_report_layout( void )


row = 0;
//genL->addWidget( bn_report_t, row++, 0, 1,-1 );
genL->addWidget( lb_type, row, 0, 1, 2 );
if (!abde_mode )
{
Expand Down Expand Up @@ -436,11 +483,12 @@ void US_ReportGui::build_report_layout( void )
genL->addWidget( le_high, row, 5, 1, 2 );
genL->addWidget( le_total, row, 7, 1, 2 );
genL->addWidget( le_tol, row, 9, 1, 2 );
genL->addWidget( ck_combined_plot, row, 11, 1, 2 );
genL->addWidget( ck_ind_plot, row++, 13, 1, 2 );
genL->addWidget( ck_combined_plot, row, 11, 1, 2, Qt::AlignHCenter );
genL->addWidget( ck_ind_plot, row++, 13, 1, 2, Qt::AlignHCenter );

cb_method ->setVisible( false );
le_intval ->setVisible( false );
le_intval ->setVisible( false );
us_setReadOnly ( le_total, false );
}

//Slots for cb_type | cb_method
Expand Down Expand Up @@ -667,16 +715,29 @@ void US_ReportGui::build_report_layout( void )

row = 0;
reportmask->addWidget( bn_repmask_t, row++, 0, 1, 6 );
reportmask->addWidget( ck_tot_conc, row, 0, 1, 2 );
reportmask->addWidget( ck_min_intensity, row, 2, 1, 2 );
reportmask->addWidget( pseudo3d_box, row++, 4, 4, 2 );

reportmask->addWidget( ck_rmsd, row, 0, 1, 2 );
reportmask->addWidget( ck_integration, row++, 2, 1, 2 );

reportmask->addWidget( ck_exp_duration, row, 0, 1, 2 );
reportmask->addWidget( ck_plots, row++, 2, 1, 2 );

if( !abde_mode )
{
reportmask->addWidget( ck_tot_conc, row, 0, 1, 2 );
reportmask->addWidget( ck_min_intensity, row, 2, 1, 2 );
reportmask->addWidget( pseudo3d_box, row++, 4, 4, 2 );

reportmask->addWidget( ck_rmsd, row, 0, 1, 2 );
reportmask->addWidget( ck_integration, row++, 2, 1, 2 );

reportmask->addWidget( ck_exp_duration, row, 0, 1, 2 );
reportmask->addWidget( ck_plots, row++, 2, 1, 2 );
}
else
{
reportmask->addWidget( ck_exp_duration, row++, 0, 1, 2 );
reportmask->addWidget( ck_integration, row++, 0, 1, 2 );
reportmask->addWidget( ck_plots, row++, 0, 1, 2 );

ck_tot_conc -> setVisible( false );
ck_min_intensity -> setVisible( false );
ck_rmsd -> setVisible( false );
pseudo3d_box -> setVisible( false );
}
main->addLayout( reportmask );

//Build | Re-build Lower buttons layout
Expand Down Expand Up @@ -810,7 +871,7 @@ void US_ReportGui::verify_text( const QString& text )
isErrorField[ oname ] = false;

//ALEXEY: for a given row, compute 'Fraction of Total' (read-only) as '(Int_Val / Total Conc.) * 100%'
if ( oname.contains(": intval") )
if ( oname.contains(": intval") && !abde_mode )
{
double tot_conc_val = le_tot_conc ->text().toDouble();
if ( text.toDouble() > tot_conc_val )
Expand All @@ -826,7 +887,7 @@ void US_ReportGui::verify_text( const QString& text )
fraction_of_total_widget -> setPalette( *palette );
}
//ALEXEY: check the same for tot_conc: apply to all ReportItems' 'Fraction of Total'
if ( oname.contains("tot_conc") )
if ( oname.contains("tot_conc") && !abde_mode )
{
int r_item_num = report->reportItems.size();

Expand Down Expand Up @@ -1062,7 +1123,7 @@ void US_ReportGui::add_row( void )

//Compute 'Fraction of Total' based on tot_conc:
double tot_conc_val = le_tot_conc -> text().toDouble();
initItem.total_percent = ( initItem.integration_val / tot_conc_val) * 100.0;
initItem.total_percent = ( abde_mode ) ? 95 : ( initItem.integration_val / tot_conc_val) * 100.0;

report->reportItems.push_back( initItem );

Expand Down
4 changes: 4 additions & 0 deletions gui/us_report_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class US_GUI_EXTERN US_ReportGui: public US_Widgets
QHBoxLayout* lower_buttons;
QGridLayout* reportmask;

QLabel* bn_report_t;

QLineEdit* le_tot_conc;
QLineEdit* le_tot_conc_tol;
QLineEdit* le_rmsd_limit;
Expand Down Expand Up @@ -93,6 +95,8 @@ class US_GUI_EXTERN US_ReportGui: public US_Widgets
QPushButton* pb_repmask;

QMap< QString, bool > isErrorField;
QStringList wvl_passed;
int init_index;

void build_report_layout( void );
void gui_to_report( void );
Expand Down

0 comments on commit f996b42

Please sign in to comment.