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
9 This file is part of the snark14Input package
10 Written by Bruno M. Carvalho and Deniz Sarioz
11 licensed under QPLv1.0 which should accompany this distribution in the file 'QPL'
16 #include "variables.h"
21 #include <qcheckbox.h>
22 #include <qradiobutton.h>
25 #include <qlineedit.h>
26 #include <qpushbutton.h>
27 #include <qbuttongroup.h>
28 #include <qradiobutton.h>
32 #include <qwhatsthis.h>
33 #include <qmessagebox.h>
36 * Constructs a basiswindow which is a child of 'parent', with the
37 * name 'name' and widget flags set to 'f'
39 * The dialog will by default be modeless, unless you set 'modal' to
40 * TRUE to construct a modal dialog.
42 @author Bruno M. Carvalho
44 basiswindow::basiswindow( QWidget* parent, const char* name, bool modal, WFlags fl )
45 : QDialog( parent, name, modal, fl )
48 setName( "basiswindow" );
50 setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)0, (QSizePolicy::SizeType)0, sizePolicy().hasHeightForWidth() ) );
51 setMinimumSize( QSize( 400, 300 ) );
52 setMaximumSize( QSize( 400, 300 ) );
53 setCaption( tr( "Basis Window" ) );
55 basislabel = new QLabel( this, "basislabel" );
56 basislabel->setGeometry( QRect( 10, 10, 120, 30 ) );
57 basislabel->setText( tr( "BASIS" ) );
59 basisbuttongroup = new QButtonGroup( this, "basisbuttongroup" );
60 basisbuttongroup->setGeometry( QRect( 20, 40, 360, 170 ) );
61 basisbuttongroup->setTitle( tr( "basis function" ) );
62 basisbuttongroup->setAlignment( int( QButtonGroup::AlignHCenter ) );
64 pixelbutton = new QRadioButton( basisbuttongroup, "pixelbutton" );
65 pixelbutton->setGeometry( QRect( 10, 20, 120, 30 ) );
66 pixelbutton->setText( tr( "PIXEL" ) );
67 pixelbutton->setChecked(true);
68 QObject::connect(pixelbutton,SIGNAL(clicked()),this,SLOT(deactivateBlobFields()));
70 blobbutton = new QRadioButton( basisbuttongroup, "blobbutton" );
71 blobbutton->setGeometry( QRect( 10, 70, 80, 30 ) );
72 blobbutton->setText( tr( "BLOB" ) );
73 QObject::connect(blobbutton,SIGNAL(clicked()),this,SLOT(activateBlobFields()));
75 // "paragraph" ++ by deniz
76 useblobdefaultsbox = new QCheckBox( basisbuttongroup, "useblobdefaultsbox" );
77 useblobdefaultsbox->setGeometry( QRect( 10, 115, 135, 30 ) );
78 useblobdefaultsbox->setText( tr( "use blob defaults" ) );
79 useblobdefaultsbox->setEnabled(FALSE);
80 // useblobdefaultsbox->setChecked(false);
81 QObject::connect(useblobdefaultsbox,SIGNAL(clicked()),this,SLOT(deactivateBlobFields()));
83 supportlabel = new QLabel( basisbuttongroup, "supportlabel" );
84 supportlabel->setGeometry( QRect( 105, 50, 60, 20 ) );
85 supportlabel->setText( tr( "support" ) );
86 supportlabel->setEnabled(FALSE);
88 support = new QLineEdit( basisbuttongroup, "support" );
89 support->setGeometry( QRect( 90, 70, 70, 30 ) );
90 support->setEnabled(FALSE);
92 shapelabel = new QLabel( basisbuttongroup, "shapelabel" );
93 shapelabel->setEnabled( FALSE );
94 shapelabel->setGeometry( QRect( 185, 50, 60, 20 ) );
95 shapelabel->setText( tr( "shape" ) );
97 shape = new QLineEdit( basisbuttongroup, "shape" );
98 shape->setGeometry( QRect(170, 70, 70, 30 ) );
99 shape->setEnabled(FALSE);
101 deltalabel = new QLabel( basisbuttongroup, "deltalabel" );
102 deltalabel->setEnabled( FALSE );
103 deltalabel->setGeometry( QRect( 265, 50, 60, 20 ) );
104 deltalabel->setText( tr( "delta" ) );
106 delta = new QLineEdit( basisbuttongroup, "delta" );
107 delta->setGeometry( QRect( 250, 70, 70, 30 ) );
108 delta->setEnabled(FALSE);
110 Line9 = new QFrame( this, "Line9" );
111 Line9->setGeometry( QRect( -10, 215, 420, 16 ) );
112 Line9->setFrameStyle( QFrame::HLine | QFrame::Sunken );
114 okbutton = new QPushButton( this, "okbutton" );
115 okbutton->setGeometry( QRect( 50, 230, 100, 40 ) );
116 okbutton->setText( tr( "OK" ) );
117 QObject::connect(okbutton,SIGNAL(clicked()),this,SLOT(checkValues()));
119 cancelbutton = new QPushButton( this, "cancelbutton" );
120 cancelbutton->setGeometry( QRect( 250, 230, 100, 40 ) );
121 cancelbutton->setText( tr( "Cancel" ) );
122 QObject::connect(cancelbutton,SIGNAL(clicked()),this,SLOT(reject()));
126 * Destroys the object and frees any allocated resources
128 basiswindow::~basiswindow()
130 // no need to delete child widgets, Qt does it all for us
133 /** Activates blob subfields
135 @author Bruno M. Carvalho
137 void basiswindow::activateBlobFields()
139 if(blobbutton->isChecked()) {
140 useblobdefaultsbox->setEnabled(TRUE);
141 useblobdefaultsbox->setChecked(false);
142 support->setEnabled(TRUE);
143 supportlabel->setEnabled(TRUE);
144 shape->setEnabled(TRUE);
145 shapelabel->setEnabled(TRUE);
146 delta->setEnabled(TRUE);
147 deltalabel->setEnabled(TRUE);
150 useblobdefaultsbox->setEnabled(FALSE);
151 support->setEnabled(FALSE);
152 supportlabel->setEnabled(FALSE);
153 shape->setEnabled(FALSE);
154 shapelabel->setEnabled(FALSE);
155 delta->setEnabled(FALSE);
156 deltalabel->setEnabled(FALSE);
160 /** Dectivates blob subfields
162 @author Bruno M. Carvalho
164 void basiswindow::deactivateBlobFields()
166 // played with by deniz
167 if(pixelbutton->isChecked()) {
168 useblobdefaultsbox->setEnabled(FALSE);
169 support->setEnabled(FALSE);
170 supportlabel->setEnabled(FALSE);
171 shape->setEnabled(FALSE);
172 shapelabel->setEnabled(FALSE);
173 delta->setEnabled(FALSE);
174 deltalabel->setEnabled(FALSE);
175 } else if(useblobdefaultsbox->isChecked()) {
176 support->setEnabled(FALSE);
177 supportlabel->setEnabled(FALSE);
178 shape->setEnabled(FALSE);
179 shapelabel->setEnabled(FALSE);
180 delta->setEnabled(FALSE);
181 deltalabel->setEnabled(FALSE);
182 } else activateBlobFields();
185 /** Returns a string for BASIS input sequence
188 @author Bruno M. Carvalho
190 QString basiswindow::getOutput()
194 output.sprintf("BASIS ");
195 if(blobbutton->isChecked()) {
197 if(useblobdefaultsbox->isChecked()) {
198 output.append("BLOBS ");
200 output.append("BLOB ");
201 output+=support->text();
203 output+=shape->text();
205 output+=delta->text();
210 if(pixelbutton->isChecked()) {
211 output.append("PIXEL ");
213 //output.append("\n");
218 void basiswindow::checkValues()
223 if((blobbutton->isChecked()) && (!(useblobdefaultsbox->isChecked()))) {
224 su=strtof((const char *) (support->text().lower()) ); // lower: bug#148
229 sh=strtof((const char *) (shape->text().lower()) );
234 d=strtof((const char *) (delta->text().lower()) );
246 case 1: QMessageBox::information(this,"SnarkInput","Error!\n"
247 "Invalid support format.");
249 case 2: QMessageBox::information(this,"SnarkInput","Error!\n"
250 "Invalid shape format.");
252 case 3: QMessageBox::information(this,"SnarkInput","Error!\n"
253 "Invalid delta format.");
255 case 4: QMessageBox::information(this,"SnarkInput","Error!\n"
256 "support must be positive.");
258 case 5: QMessageBox::information(this,"SnarkInput","Error!\n"
259 "shape must be nonnegative.");
261 case 6: QMessageBox::information(this,"SnarkInput","Error!\n"
262 "delta must be positive.");