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
12 #include <qbuttongroup.h>
15 #include <qlineedit.h>
16 #include <qpushbutton.h>
17 #include <qradiobutton.h>
21 #include <qwhatsthis.h>
22 #include <qmessagebox.h>
25 * Constructs a picturewindow which is a child of 'parent', with the
26 * name 'name' and widget flags set to 'f'
28 * The dialog will by default be modeless, unless you set 'modal' to
29 * TRUE to construct a modal dialog.
31 @author Bruno M. Carvalho
33 picturewindow::picturewindow( QWidget* parent, const char* name, bool modal, WFlags fl )
34 : QDialog( parent, name, modal, fl )
37 setName( "picturewindow" );
39 setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sizePolicy().hasHeightForWidth() ) );
40 setMinimumSize( QSize( 400, 250 ) );
41 setMaximumSize( QSize( 400, 250 ) );
42 setCaption( tr( "Picture Window" ) );
44 picturelabel = new QLabel( this, "picturelabel" );
45 picturelabel->setGeometry( QRect( 10, 10, 100, 30 ) );
46 picturelabel->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, picturelabel->sizePolicy().hasHeightForWidth() ) );
47 picturelabel->setMinimumSize( QSize( 100, 30 ) );
48 picturelabel->setMaximumSize( QSize( 100, 30 ) );
49 picturelabel->setText( tr( "PICTURE" ) );
51 picturebuttongroup = new QButtonGroup( this, "picturebuttongroup" );
52 picturebuttongroup->setGeometry( QRect( 5, 35, 385, 130 ) );
53 picturebuttongroup->setTitle( tr( "type" ) );
54 picturebuttongroup->setAlignment( int( QButtonGroup::AlignHCenter ) );
56 reconstructionbutton = new QRadioButton( picturebuttongroup, "reconstructionbutton" );
57 reconstructionbutton->setGeometry( QRect( 10, 40, 180, 24 ) );
58 reconstructionbutton->setText( tr( "RECONSTRUCTION" ) );
59 QObject::connect(reconstructionbutton,SIGNAL(clicked()),this,SLOT(activateReconstructionFields()));
61 testbutton = new QRadioButton( picturebuttongroup, "testbutton" );
62 testbutton->setGeometry( QRect( 10, 80, 65, 24 ) );
63 testbutton->setText( tr( "TEST" ) );
64 QObject::connect(testbutton,SIGNAL(clicked()),this,SLOT(deactivateReconstructionFields()));
66 nelem = new QLineEdit( picturebuttongroup, "nelem" );
67 nelem->setGeometry( QRect( 200, 35, 80, 30 ) );
68 nelem->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, nelem->sizePolicy().hasHeightForWidth() ) );
69 nelem->setEnabled(FALSE);
71 nelemlabel = new QLabel( picturebuttongroup, "nelemlabel" );
72 nelemlabel->setGeometry( QRect( 220, 15, 50, 20 ) );
73 nelemlabel->setText( tr( "nelem" ) );
74 nelemlabel->setEnabled(FALSE);
76 pixelsize = new QLineEdit( picturebuttongroup, "pixelsize" );
77 pixelsize->setGeometry( QRect( 295, 35, 80, 30 ) );
78 pixelsize->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, pixelsize->sizePolicy().hasHeightForWidth() ) );
79 pixelsize->setEnabled(FALSE);
81 pixelsizelabel = new QLabel( picturebuttongroup, "pixelsizelabel" );
82 pixelsizelabel->setGeometry( QRect( 305, 15, 70, 20 ) );
83 pixelsizelabel->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, pixelsizelabel->sizePolicy().hasHeightForWidth() ) );
84 pixelsizelabel->setMinimumSize( QSize( 70, 20 ) );
85 pixelsizelabel->setMaximumSize( QSize( 70, 20 ) );
86 pixelsizelabel->setText( tr( "pixel-size" ) );
87 pixelsizelabel->setEnabled(FALSE);
89 Line10 = new QFrame( this, "Line10" );
90 Line10->setGeometry( QRect( 0, 175, 420, 16 ) );
91 Line10->setFrameStyle( QFrame::HLine | QFrame::Sunken );
93 okbutton = new QPushButton( this, "okbutton" );
94 okbutton->setGeometry( QRect( 50, 195, 100, 40 ) );
95 okbutton->setText( tr( "OK" ) );
96 QObject::connect(okbutton,SIGNAL(clicked()),this,SLOT(checkValues()));
98 cancelbutton = new QPushButton( this, "cancelbutton" );
99 cancelbutton->setGeometry( QRect( 250, 195, 100, 40 ) );
100 cancelbutton->setText( tr( "Cancel" ) );
101 QObject::connect(cancelbutton,SIGNAL(clicked()),this,SLOT(reject()));
105 * Destroys the object and frees any allocated resources
107 picturewindow::~picturewindow()
109 // no need to delete child widgets, Qt does it all for us
112 /** Activates type fields
114 @author Bruno M. Carvalho
116 /* void picturewindow::activateFields()
118 if(picturebutton->isChecked()) {
119 reconstructionbutton->setEnabled(TRUE);
120 testbutton->setEnabled(TRUE);
121 picturebuttongroup->setEnabled(TRUE);
124 picturebuttongroup->setEnabled(FALSE);
125 reconstructionbutton->setEnabled(FALSE);
126 testbutton->setEnabled(FALSE);
127 nelem->setEnabled(FALSE);
128 pixelsize->setEnabled(FALSE);
129 nelemlabel->setEnabled(FALSE);
130 pixelsizelabel->setEnabled(FALSE);
134 /** Activates reconstruction fields
136 @author Bruno M. Carvalho
138 void picturewindow::activateReconstructionFields()
140 if(reconstructionbutton->isChecked()) {
141 nelem->setEnabled(TRUE);
142 pixelsize->setEnabled(TRUE);
143 nelemlabel->setEnabled(TRUE);
144 pixelsizelabel->setEnabled(TRUE);
147 nelem->setEnabled(FALSE);
148 pixelsize->setEnabled(FALSE);
149 nelemlabel->setEnabled(FALSE);
150 pixelsizelabel->setEnabled(FALSE);
154 /** Deactivates reconstruction fields
156 @author Bruno M. Carvalho
158 void picturewindow::deactivateReconstructionFields()
160 if(testbutton->isChecked()) {
161 nelem->setEnabled(FALSE);
162 pixelsize->setEnabled(FALSE);
163 nelemlabel->setEnabled(FALSE);
164 pixelsizelabel->setEnabled(FALSE);
168 /** Returns a string for PICTUE input sequence
171 @author Bruno M. Carvalho
173 QString picturewindow::getOutput()
177 output.sprintf("PICTURE ");
178 if(reconstructionbutton->isChecked()) {
179 output.append("RECONSTRUCTION ");
180 output+=nelem->text();
182 output+=pixelsize->text();
185 if(testbutton->isChecked())
186 output.append("TEST");
187 //output.append("\n");
193 void picturewindow::checkValues()
198 if(reconstructionbutton->isChecked()) {
199 n=strtoi((const char *)nelem->text());
204 p=strtof((const char *)pixelsize->text());
213 case 1: QMessageBox::information(this,"SnarkInput","Error!\n"
214 "Invalid nelem format.");
217 case 2: QMessageBox::information(this,"SnarkInput","Error!\n"
218 "nelem must be positive and odd.");
221 case 3: QMessageBox::information(this,"SnarkInput","Error!\n"
222 "Invalid pixel-size format.");
223 pixelsize->setFocus();
225 case 4: QMessageBox::information(this,"SnarkInput","Error!\n"
226 "pixel-size must be greater than 0.");
227 pixelsize->setFocus();