UltraScan III
us_clipdata.cpp
Go to the documentation of this file.
1 #include "us_clipdata.h"
2 #include "us_gui_settings.h"
3 
4 US_ClipData::US_ClipData( double& concentration, double& radius,
5  double meniscus, double loading, QWidget* p, Qt::WindowFlags f )
6  : US_WidgetsDialog( p, f ), conc( concentration ), rad( radius )
7 {
8  setPalette ( US_GuiSettings::frameColor() );
9  setAttribute ( Qt::WA_DeleteOnClose );
10 
11  QGridLayout* main = new QGridLayout( this );
12  main->setContentsMargins ( 2, 2, 2, 2 );
13  main->setSpacing( 2 );
14 
15  setWindowTitle( tr( "Select Finite Element Simulation"
16  " Data Range" ) );
17 
18  QLabel* lb_info = us_banner( tr( "Please select the Cropping Range\n"
19  "for the Data to be saved" ) );
20 
21  QLabel* lb_conc = us_label ( tr( "Maximum Concentration:" ) );
22 
23  QString s;
24  s.sprintf( "%4.2f", loading );
25 
26  QLabel* lb_loading = us_label( tr( "( Loading concentration: " )
27  + QString().sprintf( "%4.2f" , loading ) + " )" );
28 
29  ct_conc = us_counter( 2, loading, conc, loading * 2 );
30  ct_conc->setStep( 0.1 );
31 
32  QLabel* lb_rad = us_label( tr( "Maximum Radius:" ) );
33 
34  ct_rad = us_counter( 2, meniscus, rad, rad );
35  ct_rad->setStep( 0.01 );
36 
37  QBoxLayout* buttons = new QHBoxLayout();
38  QPushButton* pb_help = us_pushbutton( tr( "Help" ) );
39  QPushButton* pb_cancel = us_pushbutton( tr( "Cancel" ) );
40  QPushButton* pb_accept = us_pushbutton( tr( "OK" ) );
41 
42  connect( pb_help, SIGNAL( clicked() ), SLOT( help() ) );
43  connect( pb_cancel, SIGNAL( clicked() ), SLOT( reject() ) );
44  connect( pb_accept, SIGNAL( clicked() ), SLOT( ok() ) );
45 
46  buttons->addWidget( pb_help );
47  buttons->addWidget( pb_cancel );
48  buttons->addWidget( pb_accept );
49 
50  QTextEdit* te_guide = us_textedit();
51  us_setReadOnly( te_guide, true );
52  te_guide->setTextColor( Qt::blue );
53  te_guide->setText( "<div style='color:blue'>" +
54  tr( "To accept the data as computed, with no"
55  " limits on amplitude or radius range,"
56  " click on the <b>Cancel</b> button.<br/><br/>"
57  "To impose amplitude or radius limits on"
58  " exported data, set the maximum concentration"
59  " value and/or maximum radius and then click"
60  " on the <b>OK</b> button.<br/><br/>"
61  "( The current maximum OD is %1 )." ).arg( conc )
62  + "</div>" );
63 
64  int row = 0;
65  main->addWidget( lb_info, row++, 0, 1, 2 );
66  main->addWidget( lb_loading, row++, 0, 1, 2 );
67  main->addWidget( lb_conc, row, 0, 1, 1 );
68  main->addWidget( ct_conc, row++, 1, 1, 1 );
69  main->addWidget( lb_rad, row, 0, 1, 1 );
70  main->addWidget( ct_rad, row++, 1, 1, 1 );
71  main->addLayout( buttons, row++, 0, 1, 2 );
72  main->addWidget( te_guide, row++, 0, 5, 2 );
73 
74  adjustSize();
75 qDebug() << "(1) size" << size();
76  int rowht = ct_conc->height();
77  int wwid = width();
78  int whgt = rowht * ( row + 7 );
79 qDebug() << "(2) size" << QSize( wwid, whgt );
80  resize( wwid, whgt );
81 qDebug() << "(3) size" << size();
82 }
83 
84 void US_ClipData::ok( void )
85 {
86  conc = ct_conc->value();
87  rad = ct_rad ->value();
88  accept();
89 }
90