7 #include "qwt_scale_engine.h"
10 const QString& t_project,
int t_model,
bool status,
11 bool position_win, QWidget* parent, Qt::WindowFlags flags )
23 setWindowTitle( tr(
"Equilibrium Concentration Distribution" ) );
25 QBoxLayout*
main =
new QHBoxLayout(
this );
26 main->setContentsMargins( 2, 2, 2, 2 );
27 main->setSpacing( 2 );
29 QBoxLayout* controls =
new QVBoxLayout;
31 QLabel* lb_header=
us_banner( tr(
"Species Distribution in\n"
32 "Self-Associating System" ), -2 );
33 lb_header->setMargin( 10 );
34 controls->addWidget( lb_header );
36 QLabel* lb_stoich=
us_banner( tr(
"Stoichiometries:" ), -2 );
37 controls->addWidget( lb_stoich );
40 QGridLayout* params =
new QGridLayout;
43 QLabel* lb_assoc1 =
us_label(
"Association1:" );
44 params->addWidget( lb_assoc1, row, 0 );
47 connect(
le_assoc1, SIGNAL( textChanged (
const QString& ) ),
51 QLabel* lb_assoc2 =
us_label(
"Association2:" );
52 params->addWidget( lb_assoc2, row, 0 );
55 connect(
le_assoc2, SIGNAL( textChanged (
const QString& ) ),
60 QLabel* lb_equil=
us_banner( tr(
"Equilibrium Constants:" ), -2 );
61 params->addWidget( lb_equil, row++, 0, 1, 2 );
63 QLabel* lb_equil1 =
us_label(
"ln( Constant1 ):" );
64 params->addWidget( lb_equil1, row, 0 );
67 connect(
le_equil1, SIGNAL( textChanged(
const QString& ) ),
73 connect(
c_equil1, SIGNAL( valueChanged (
double ) ),
75 params->addWidget(
c_equil1, row++, 0, 1, 2 );
77 QLabel* lb_equil2 =
us_label(
"ln( Constant2 ):" );
78 params->addWidget( lb_equil2, row, 0 );
81 connect(
le_equil2, SIGNAL( textChanged(
const QString& ) ),
87 connect(
c_equil2, SIGNAL( valueChanged (
double ) ),
89 params->addWidget(
c_equil2, row++, 0, 1, 2 );
91 controls->addLayout( params );
94 QLabel* lb_model=
us_banner( tr(
"Equilibrium Model:" ), -2 );
95 controls->addWidget( lb_model );
100 te_model->setText( models[
model ] );
101 te_model->setReadOnly(
true );
102 te_model->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
103 te_model->setMaximumHeight( 100 );
105 p.setColor( QPalette::Base, Qt::lightGray );
106 te_model->setPalette( p );
107 controls->addWidget( te_model );
109 QLabel* lb_project=
us_banner( tr(
"Project Name:" ), -2 );
110 controls->addWidget( lb_project );
113 le_project->setReadOnly(
true );
114 le_project->setPalette( p );
115 controls->addWidget( le_project );
117 controls->addStretch();
120 QPushButton* pb_save =
us_pushbutton( tr(
"Save Data to File" ) );
121 connect( pb_save, SIGNAL( clicked() ), SLOT(
save() ) );
122 controls->addWidget( pb_save );
125 connect( pb_help, SIGNAL( clicked() ), SLOT(
help() ) );
126 controls->addWidget( pb_help );
129 connect( pb_close, SIGNAL( clicked() ), SLOT( close() ) );
130 controls->addWidget( pb_close );
132 main->addLayout( controls );
133 QBoxLayout* rightSide =
new QVBoxLayout;
137 tr(
"Self-Association Profile for" ) +
project,
138 tr(
"Total Concentration" ),
139 tr(
"% of Total Concentration" ) );
141 plot->setAxisScaleEngine( QwtPlot::xBottom,
new QwtLog10ScaleEngine );
143 pick->setRubberBand( QwtPicker::VLineRubberBand );
144 connect(
pick, SIGNAL( selected (
const QwtDoublePoint& ) ),
145 SLOT (
new_value(
const QwtDoublePoint& ) ) );
146 connect(
pick, SIGNAL( moved (
const QwtDoublePoint& ) ),
147 SLOT (
new_value(
const QwtDoublePoint& ) ) );
148 connect(
pick, SIGNAL( mouseDown(
const QwtDoublePoint& ) ),
149 SLOT (
mouseD (
const QwtDoublePoint& ) ) );
150 connect(
pick, SIGNAL( mouseUp (
const QwtDoublePoint& ) ),
151 SLOT (
mouseU (
const QwtDoublePoint& ) ) );
155 const double inc = 20.0;
167 curve1->setPen( QPen( QBrush( Qt::green ), 2.0 ) );
168 curve2->setPen( QPen( QBrush( Qt::yellow ), 2.0 ) );
169 curve3->setPen( QPen( QBrush( Qt::cyan ), 2.0 ) );
173 QGridLayout* legend =
new QGridLayout;
176 QLabel* lb_species1=
us_label( tr(
"Species 1:" ) );
177 p.setColor( QPalette::WindowText, Qt::green );
178 lb_species1->setPalette( p );
179 legend->addWidget( lb_species1, 0, 0 );
185 QLabel* lb_species2=
us_label( tr(
"Species 2:" ) );
186 p.setColor( QPalette::WindowText, Qt::yellow );
187 lb_species2->setPalette( p );
188 legend->addWidget( lb_species2, 0, 2 );
194 QLabel* lb_species3=
us_label( tr(
"Species 3:" ) );
195 p.setColor( QPalette::WindowText, Qt::cyan );
196 lb_species3->setPalette( p );
197 legend->addWidget( lb_species3, 0, 4 );
203 QLabel* conc =
us_label( tr(
"Total Concentration:" ) );
204 legend->addWidget( conc, 1, 0 );
208 legend->addWidget(
le_conc, 1, 1 );
211 tr(
"Drag mouse through plot area to see relative concentrations" ) );
213 legend->addWidget( le_conc, 1, 2, 1, 4 );
215 rightSide->addLayout(
plot1 );
216 rightSide->addLayout( legend);
217 main->addLayout( rightSide);
243 double monomer = total / 2;
244 double diff = monomer / 2;
245 double diff1 = monomer - diff;
248 while ( fabs( diff1 ) > 1.0e-15 )
250 double monomer_old = monomer;
253 monomer = monomer - diff;
255 monomer = monomer + diff;
258 diff = fabs( monomer - monomer_old ) / 2;
259 diff1 = monomer_old - monomer;
291 if ( total >= 1.0e-10 && total <= 100.0 &&
updating )
294 while (
x[ i ] < total ) i++;
299 le_conc ->setText( QString::number( total ) +
" M" );
313 stoich[ 0 ] = s.toDouble();
319 stoich[ 1 ] = s.toDouble();
325 eq[ 0 ] = s.toDouble();
332 eq[ 1 ] = s.toDouble();
340 le_equil1->setText( QString::number( value ) );
347 le_equil2->setText( QString::number( value ) );
354 QString::number(
model ) +
".dis";
360 if ( QMessageBox::warning(
this,
362 tr(
"Attention:\nThis file exists already!\n\n" )
364 tr(
"\n\nDo you want to overwrite it?" ),
365 QMessageBox::Yes, QMessageBox::No ) == QMessageBox::No )
372 if ( f.open( QIODevice::WriteOnly | QIODevice::Text ) )
374 QTextStream ts( &f );
375 ts << tr(
"\"Total Concentration\"\t\"% Monomer\"\t\"% " )
376 <<
stoich[ 0 ] <<
"-mer\"\t\"% " <<
stoich[ 1 ] <<
"-mer\"\n";
380 ts <<
x [ i ] <<
"\t"
392 if ( ! dir.exists( reportDir ) ) dir.mkpath( reportDir );
394 filename = reportDir +
"/" +
project +
"-" +
395 QString::number(
model ) +
".distribution.png";
397 QRect r = QRect( 2, 2,
plot->width() - 4,
plot->height() - 4 );
398 QPixmap
p = QPixmap::grabWidget(
plot, r );