3 @author Bruno M. Carvalho and Deniz Sarioz
4 licensed under (open-source) QPL v1.0
5 which accompanies this distribution in the file QPL
10 #include "variables.h"
13 #include <qbuttongroup.h>
16 #include <qlineedit.h>
17 #include <qmultilineedit.h>
18 #include <qpushbutton.h>
19 #include <qradiobutton.h>
23 #include <qwhatsthis.h>
24 #include <qmessagebox.h>
27 * Constructs a executewindow which is a child of 'parent', with the
28 * name 'name' and widget flags set to 'f'
30 * The dialog will by default be modeless, unless you set 'modal' to
31 * TRUE to construct a modal dialog.
33 @author Bruno M. Carvalho (modified a little by deniz)
35 executewindow::executewindow( QWidget* parent, const char* name, bool modal, WFlags fl )
36 : QDialog( parent, name, modal, fl )
39 setName( "executewindow" );
41 setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sizePolicy().hasHeightForWidth() ) );
42 setMinimumSize( QSize( 400, 700 ) );
43 setMaximumSize( QSize( 400, 700 ) );
44 setCaption( tr( "Execute Window" ) );
46 executelabel = new QLabel( this, "executelabel" );
47 executelabel->setGeometry( QRect( 10, 10, 120, 30 ) );
48 executelabel->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, executelabel->sizePolicy().hasHeightForWidth() ) );
49 executelabel->setMinimumSize( QSize( 120, 30 ) );
50 executelabel->setMaximumSize( QSize( 120, 30 ) );
51 executelabel->setText( tr( "EXECUTE" ) );
53 executebuttongroup = new QButtonGroup( this, "executebuttongroup" );
54 executebuttongroup->setGeometry( QRect( 40, 40, 160, 170 ) );
55 executebuttongroup->setTitle( tr( "type" ) );
56 executebuttongroup->setAlignment( int( QButtonGroup::AlignHCenter ) );
58 zerobutton = new QRadioButton( executebuttongroup, "zerobutton" );
59 zerobutton->setGeometry( QRect( 10, 20, 130, 24 ) );
60 zerobutton->setText( tr( "ZERO" ) );
62 averagebutton = new QRadioButton( executebuttongroup, "averagebutton" );
63 averagebutton->setGeometry( QRect( 10, 50, 110, 24 ) );
64 averagebutton->setText( tr( "AVERAGE" ) );
66 continuebutton = new QRadioButton( executebuttongroup, "continuebutton" );
67 continuebutton->setGeometry( QRect( 10, 80, 110, 24 ) );
68 continuebutton->setText( tr( "CONTINUE" ) );
71 phantombutton = new QRadioButton( executebuttongroup, "phantombutton" );
72 phantombutton->setGeometry( QRect( 10, 110, 110, 24 ) );
73 phantombutton->setText( tr( "PHANTOM" ) );
75 nonebutton = new QRadioButton( executebuttongroup, "nonebutton" );
76 nonebutton->setGeometry( QRect( 10, 140, 80, 24 ) );
77 nonebutton->setText( tr( "NONE" ) );
78 nonebutton->setChecked(true);
80 algname = new QLineEdit( this, "algname" );
81 algname->setGeometry( QRect( 30, 230, 350, 28 ) );
83 algnamelabel = new QLabel( this, "algnamelabel" );
84 algnamelabel->setGeometry( QRect( 170, 210, 70, 20 ) );
85 algnamelabel->setText( tr( "algname" ) );
87 executebuttongroup2 = new QButtonGroup( this, "executebuttongroup2" );
88 executebuttongroup2->setGeometry( QRect( 40, 270, 160, 100 ) );
89 executebuttongroup2->setTitle( tr( "" ) );
90 executebuttongroup2->setAlignment( int( QButtonGroup::AlignHCenter ) );
92 contourbutton = new QRadioButton( executebuttongroup2, "contourbutton" );
93 contourbutton->setGeometry( QRect( 10, 10, 110, 30 ) );
94 contourbutton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, contourbutton->sizePolicy().hasHeightForWidth() ) );
95 contourbutton->setMinimumSize( QSize( 110, 30 ) );
96 contourbutton->setMaximumSize( QSize( 110, 30 ) );
97 contourbutton->setText( tr( "CONTOUR" ) );
98 QObject::connect(contourbutton,SIGNAL(clicked()),this,SLOT(activateContourSmoothFields()));
100 smoothbutton = new QRadioButton( executebuttongroup2, "smoothbutton" );
101 smoothbutton->setGeometry( QRect( 10, 40, 110, 30 ) );
102 smoothbutton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, smoothbutton->sizePolicy().hasHeightForWidth() ) );
103 smoothbutton->setMinimumSize( QSize( 110, 30 ) );
104 smoothbutton->setMaximumSize( QSize( 110, 30 ) );
105 smoothbutton->setText( tr( "SMOOTH" ) );
106 QObject::connect(smoothbutton,SIGNAL(clicked()),this,SLOT(activateContourSmoothFields()));
108 nonebutton2 = new QRadioButton( executebuttongroup2, "nonebutton2" );
109 nonebutton2->setGeometry( QRect( 10, 70, 130, 24 ) );
110 nonebutton2->setText( tr( "NONE" ) );
111 nonebutton2->setChecked(true);
112 QObject::connect(nonebutton2,SIGNAL(clicked()),this,SLOT(activateContourSmoothFields()));
114 nameoftheexecution = new QLineEdit( this, "nameoftheexecution" );
115 nameoftheexecution->setGeometry( QRect( 30, 390, 350, 28 ) );
117 nameoftheexecutionlabel = new QLabel( this, "nameoftheexecutionlabel" );
118 nameoftheexecutionlabel->setGeometry( QRect( 110, 370, 180, 20 ) );
119 nameoftheexecutionlabel->setText( tr( "name_of_the_execution" ) );
127 algvariables = new QMultiLineEdit( this, "algvariables" );
128 algvariables->setGeometry( QRect( 30, 568, 350, 60 ) );
130 algvariableslabel = new QLabel( this, "algvariableslabel" );
131 algvariableslabel->setGeometry( QRect( 100, 535, 220, 20 ) );
132 algvariableslabel->setText( tr( "algorithm specific variables" ) );
140 threshold = new QLineEdit( this, "threshold" );
141 threshold->setGeometry( QRect( 30, 442, 80, 28 ) );
142 threshold->setEnabled(FALSE);
144 thresholdlabel = new QLabel( this, "thresholdlabel" );
145 thresholdlabel->setGeometry( QRect( 35, 422, 70, 20 ) );
146 thresholdlabel->setText( tr( "threshold" ) );
147 thresholdlabel->setEnabled(FALSE);
149 weight1 = new QLineEdit( this, "weight1" );
150 weight1->setGeometry( QRect( 120, 442, 80, 28 ) );
151 weight1->setEnabled(FALSE);
153 weight1label = new QLabel( this, "weight1label" );
154 weight1label->setGeometry( QRect( 130, 422, 60, 20 ) );
155 weight1label->setText( tr( "weight1" ) );
156 weight1label->setEnabled(FALSE);
158 weight2 = new QLineEdit( this, "weight2" );
159 weight2->setGeometry( QRect( 210, 442, 80, 28 ) );
160 weight2->setEnabled(FALSE);
162 weight2label = new QLabel( this, "weight2label" );
163 weight2label->setGeometry( QRect( 220, 422, 60, 20 ) );
164 weight2label->setText( tr( "weight2" ) );
165 weight2label->setEnabled(FALSE);
167 weight3 = new QLineEdit( this, "weight3" );
168 weight3->setGeometry( QRect( 300, 442, 80, 28 ) );
169 weight3->setEnabled(FALSE);
171 weight3label = new QLabel( this, "weight3label" );
172 weight3label->setGeometry( QRect( 310, 422, 60, 20 ) );
173 weight3label->setText( tr( "weight3" ) );
174 weight3label->setEnabled(FALSE);
176 iterationflaglabel = new QLabel( this, "iterationflaglinelabel" );
177 iterationflaglabel->setGeometry( QRect( 140, 482, 150, 20 ) );
178 iterationflaglabel->setText( tr( "iteration_flag_line" ) );
179 iterationflaglabel->setEnabled(FALSE);
181 iterationflagline = new QLineEdit( this, "iterationflagline" );
182 iterationflagline->setGeometry( QRect( 30, 502, 350, 28 ) );
183 iterationflagline->setEnabled(FALSE);
185 Line5 = new QFrame( this, "Line5" );
186 Line5->setGeometry( QRect( -15, 625, 450, 16 ) );
187 Line5->setFrameStyle( QFrame::HLine | QFrame::Sunken );
189 okbutton = new QPushButton( this, "okbutton" );
190 okbutton->setGeometry( QRect( 50, 645, 100, 40 ) );
191 okbutton->setText( tr( "OK" ) );
192 QObject::connect(okbutton,SIGNAL(clicked()),this,SLOT(checkValues()));
194 cancelbutton = new QPushButton( this, "cancelbutton" );
195 cancelbutton->setGeometry( QRect( 250, 645, 100, 40 ) );
196 cancelbutton->setText( tr( "Cancel" ) );
197 QObject::connect(cancelbutton,SIGNAL(clicked()),this,SLOT(reject()));
201 * Destroys the object and frees any allocated resources
203 executewindow::~executewindow()
205 // no need to delete child widgets, Qt does it all for us
209 /** Activates type, algname and other fields
211 @author Bruno M. Carvalho
213 /* void executewindow::activateFields()
215 if(executebutton->isChecked()) {
216 executebuttongroup->setEnabled(TRUE);
217 zerobutton->setEnabled(TRUE);
218 averagebutton->setEnabled(TRUE);
219 continuebutton->setEnabled(TRUE);
220 nonebutton->setEnabled(TRUE);
221 algname->setEnabled(TRUE);
222 algnamelabel->setEnabled(TRUE);
223 executebuttongroup2->setEnabled(TRUE);
224 contourbutton->setEnabled(TRUE);
225 smoothbutton->setEnabled(TRUE);
226 nonebutton2->setEnabled(TRUE);
227 nameoftheexecution->setEnabled(TRUE);
228 nameoftheexecutionlabel->setEnabled(TRUE);
229 algvariables->setEnabled(TRUE);
230 algvariableslabel->setEnabled(TRUE);
233 executebuttongroup->setEnabled(FALSE);
234 zerobutton->setEnabled(FALSE);
235 averagebutton->setEnabled(FALSE);
236 continuebutton->setEnabled(FALSE);
237 nonebutton->setEnabled(FALSE);
238 algname->setEnabled(FALSE);
239 algnamelabel->setEnabled(FALSE);
240 executebuttongroup2->setEnabled(FALSE);
241 contourbutton->setEnabled(FALSE);
242 smoothbutton->setEnabled(FALSE);
243 nonebutton2->setEnabled(FALSE);
244 nameoftheexecution->setEnabled(FALSE);
245 nameoftheexecutionlabel->setEnabled(FALSE);
246 algvariables->setEnabled(FALSE);
247 algvariableslabel->setEnabled(FALSE);
248 threshold->setEnabled(FALSE);
249 thresholdlabel->setEnabled(FALSE);
250 weight1->setEnabled(FALSE);
251 weight1label->setEnabled(FALSE);
252 weight2->setEnabled(FALSE);
253 weight2label->setEnabled(FALSE);
254 weight3->setEnabled(FALSE);
255 weight3label->setEnabled(FALSE);
256 iterationflagline->setEnabled(FALSE);
257 iterationflaglabel->setEnabled(FALSE);
261 /** Activates contour and smooth fields fields
263 @author Bruno M. Carvalho
265 void executewindow::activateContourSmoothFields()
267 if(contourbutton->isChecked() || smoothbutton->isChecked()) {
268 threshold->setEnabled(TRUE);
269 thresholdlabel->setEnabled(TRUE);
270 weight1->setEnabled(TRUE);
271 weight1label->setEnabled(TRUE);
272 weight2->setEnabled(TRUE);
273 weight2label->setEnabled(TRUE);
274 weight3->setEnabled(TRUE);
275 weight3label->setEnabled(TRUE);
276 iterationflagline->setEnabled(TRUE);
277 iterationflaglabel->setEnabled(TRUE);
280 threshold->setEnabled(FALSE);
281 thresholdlabel->setEnabled(FALSE);
282 weight1->setEnabled(FALSE);
283 weight1label->setEnabled(FALSE);
284 weight2->setEnabled(FALSE);
285 weight2label->setEnabled(FALSE);
286 weight3->setEnabled(FALSE);
287 weight3label->setEnabled(FALSE);
288 iterationflagline->setEnabled(FALSE);
289 iterationflaglabel->setEnabled(FALSE);
293 /** Deactivates contour and smooth fields fields
295 @author Bruno M. Carvalho
297 void executewindow::deactivateContourSmoothFields()
299 if(nonebutton2->isChecked()) {
300 threshold->setEnabled(FALSE);
301 thresholdlabel->setEnabled(FALSE);
302 weight1->setEnabled(FALSE);
303 weight1label->setEnabled(FALSE);
304 weight2->setEnabled(FALSE);
305 weight2label->setEnabled(FALSE);
306 weight3->setEnabled(FALSE);
307 weight3label->setEnabled(FALSE);
308 iterationflagline->setEnabled(FALSE);
309 iterationflaglabel->setEnabled(FALSE);
312 threshold->setEnabled(TRUE);
313 thresholdlabel->setEnabled(TRUE);
314 weight1->setEnabled(TRUE);
315 weight1label->setEnabled(TRUE);
316 weight2->setEnabled(TRUE);
317 weight2label->setEnabled(TRUE);
318 weight3->setEnabled(TRUE);
319 weight3label->setEnabled(TRUE);
320 iterationflagline->setEnabled(TRUE);
321 iterationflaglabel->setEnabled(TRUE);
325 /** Returns a string for EXECUTE input sequence
328 @author Bruno M. Carvalho
330 QString executewindow::getOutput()
334 output.sprintf("EXECUTE ");
335 if(zerobutton->isChecked()) {
336 output.append("ZERO ");
339 if(averagebutton->isChecked()) {
340 output.append("AVERAGE ");
343 if(continuebutton->isChecked()) {
344 output.append("CONTINUE ");
347 if(phantombutton->isChecked()) {
348 output.append("PHANTOM ");
350 output+=algname->text();
352 if(contourbutton->isChecked()) {
353 output.append("CONTOUR ");
356 if(smoothbutton->isChecked()) {
357 output.append("SMOOTH ");
360 output+=nameoftheexecution->text();
361 // if(strcmp(algvariables->text(),"")) {
362 // output.append("\n");
363 // output+=algvariables->text();
365 //output.append("\n");
366 if(contourbutton->isChecked() || smoothbutton->isChecked()) {
368 output+=threshold->text();
370 output+=weight1->text();
372 output+=weight2->text();
374 output+=weight3->text();
376 output+=iterationflagline->text();
377 //output.append("\n");
380 if(strcmp(algvariables->text(),"")) {
382 output+=algvariables->text();
387 void executewindow::checkValues()
394 str=(const char *)algname->text();
395 str1[0]=stolower(str[0]);
396 str1[1]=stolower(str[1]);
397 str1[2]=stolower(str[2]);
398 str1[3]=stolower(str[3]);
400 // cmp=strcmp(str1,"alg1");
401 //cmp=strcmp(str1,"algp"); // SI bug 113 fix
402 cmp=strcmp(str1,"alp1"); // bug 267, Ran
405 // cmp=strcmp(str1,"alg2");
406 //cmp=strcmp(str1,"algb"); // SI bug 113 fix
407 cmp=strcmp(str1,"alb1"); // bug 267, Ran
410 cmp=strcmp(str1,"alts");
413 cmp=strcmp(str1,"art");
416 cmp=strcmp(str1,"back");
419 cmp=strcmp(str1,"conv");
422 cmp=strcmp(str1,"dcon");
425 cmp=strcmp(str1,"emap");
428 cmp=strcmp(str1,"four");
431 cmp=strcmp(str1,"lino");
434 cmp=strcmp(str1,"mart");
437 cmp=strcmp(str1,"mspb");
440 cmp=strcmp(str1,"quad");
443 cmp=strcmp(str1,"rfl");
446 cmp=strcmp(str1,"sirt");
449 cmp=strcmp(str1,"alp2");
452 cmp=strcmp(str1,"alp3");
455 cmp=strcmp(str1,"alp4");
458 cmp=strcmp(str1,"alp5");
461 cmp=strcmp(str1,"alb2");
464 cmp=strcmp(str1,"alb3");
467 cmp=strcmp(str1,"alb4");
470 cmp=strcmp(str1,"alb5");
473 cmp=strcmp(str1,"sart");
499 if(contourbutton->isChecked() || smoothbutton->isChecked()) {
500 t=strtof((const char *)threshold->text());
503 w1=strtof((const char *)weight1->text());
506 w2=strtof((const char *)weight2->text());
509 w3=strtof((const char *)weight3->text());
512 if(!isintspace(iterationflagline->text()))
519 case 1: QMessageBox::information(this,"SnarkInput","Error!\n"
520 "Invalid algorithm name.Algorithm name must be one of:\n"
521 // SI bug 113 fix alg1 -> algp ; alg2 -> algb
522 // "ALG1, ALG2, ALTSCHULER, ART, BACKPROJECTION,\n"
523 // Ran, bug 267 added ALP1 - ALP5 and ALB1 - ALB5
524 //"ALGP, ALGB, ALTSCHULER, ART, BACKPROJECTION,\n"
525 "ALP1, ALP2, ALP3, ALP4, ALP5, ALB1, ALB2, \n"
526 "ALB3, ALB4, ALB5, ALTSCHULER, ART, \n"
527 "BACKPROJECTION,CONVOLUTION, DCONV, EMAP,\n"
528 "FOURIER, LINO, MART, MSPB, QUAD, RFL, SART or SIRT"); break;
529 case 2: QMessageBox::information(this,"SnarkInput","Error!\n"
530 "Invalid threshold format.");
531 threshold->setFocus();
533 case 3: QMessageBox::information(this,"SnarkInput","Error!\n"
534 "Invalid weight1 format.");
537 case 4: QMessageBox::information(this,"SnarkInput","Error!\n"
538 "Invalid weight2 format.");
541 case 5: QMessageBox::information(this,"SnarkInput","Error!\n"
542 "Invalid weight3 format.");
545 case 6: QMessageBox::information(this,"SnarkInput","Error!\n"
546 "iteration_flag_line must contain\n"
547 "only 0-9 and spaces and must\n"
549 iterationflagline->setFocus();