2 @package snark14Display
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
7 modification: Joanna Klukowska 1/13/2009
8 added choice of grayScale display for plot
9 in addition to color display
13 #include "displaylines.hpp"
14 #include "variables.hpp"
17 #include <qcombobox.h>
20 #include <qlineedit.h>
22 #include <qpushbutton.h>
23 #include <qradiobutton.h>
27 #include <qwhatsthis.h>
29 /* "Lines" (plotting of pixel values in a row or column) dialog for a single image (and maybe phantom)
30 * Constructs a lineswindow which is a child of 'parent', with the
31 * name 'name' and widget flags set to 'f'
33 * The dialog will by default be modeless, unless you set 'modal' to
34 * TRUE to construct a modal dialog.
36 lineswindow::lineswindow(QWidget* parent, const char* name, double min, double max, bool modal, bool projrec, WFlags fl)
37 : QDialog(parent, name, modal, fl) {
40 setName("lineswindow");
42 setMinimumSize(QSize(340, 550));
43 setMaximumSize(QSize(340, 550));
44 QString s = name; // dummy (multipurpose) string
53 rowcolbox = new QListBox(this, "rowcolbox");
54 rowcolbox->insertItem("rows"); // rows first. => 0 => false [ x-axis == columns ] [sic]
55 rowcolbox->insertItem("columns"); // columns later => 1 => true [ x-axis == rows ] [sic]
56 rowcolbox->setGeometry(QRect(20, 10, 80, 50));
57 rowcolbox->setSelectionMode(QListBox::Single);
58 rowcolbox->setSelected(0, true);
59 QObject::connect(rowcolbox, SIGNAL(highlighted(int)), this, SLOT(updateXAxis(int)));
61 phantombutton = new QRadioButton(this, "phantombutton");
62 phantombutton->setGeometry(QRect(150, 20, 120, 30));
63 phantombutton->setMinimumSize(QSize(120, 30));
64 phantombutton->setMaximumSize(QSize(120, 30));
65 phantombutton->setText("PHANTOM");
67 phantombutton->setChecked(true);
69 phantombutton->setChecked(false);
70 phantombutton->setEnabled(false);
73 line1 = new QLineEdit(this, "line1");
74 line1->setGeometry(QRect(20, 90, 60, 30));
76 line2 = new QLineEdit(this, "line2");
77 line2->setGeometry(QRect(100, 90, 60, 30));
79 line3 = new QLineEdit(this, "line3");
80 line3->setGeometry(QRect(180, 90, 60, 30));
82 line4 = new QLineEdit(this, "line4");
83 line4->setGeometry(QRect(260, 90, 60, 30));
85 label1 = new QLabel(this, "label1");
86 label1->setGeometry(QRect(33, 70, 35, 20));
87 label1->setText("row1");
89 label2 = new QLabel(this, "label2");
90 label2->setGeometry(QRect(113, 70, 35, 20));
91 label2->setText("row ");
93 label3 = new QLabel(this, "label3");
94 label3->setGeometry(QRect(193, 70, 35, 20));
95 label3->setText("row3");
97 label4 = new QLabel(this, "label4");
98 label4->setGeometry(QRect(273, 70, 35, 20));
99 label4->setText("row4");
101 title = new QLineEdit(this, "title");
102 title->setGeometry(QRect(20, 150, 300, 30));
103 title->setText(name);
105 titlelabel = new QLabel(this, "titlelabel");
106 titlelabel->setGeometry(QRect(160, 130, 60, 20));
107 titlelabel->setText("Title");
109 // subtitle = new QComboBox( this, "subtitle" );
110 // subtitle->setGeometry( QRect( 20, 210, 140, 30 ) );
111 // subtitle->insertItem("Column/Line #",-1);
112 // subtitle->insertItem("Empty",-1);
114 // subtitlelabel = new QLabel( this, "subtitlelabel" );
115 // subtitlelabel->setGeometry( QRect( 60, 190, 100, 20 ) );
116 // subtitlelabel->setText( "Subtitle" );
118 // gridstyle = new QComboBox(this,"gridstyle");
119 // gridstyle->setGeometry( QRect( 180, 210, 140, 30 ) );
120 // gridstyle->insertItem("Solid",-1);
121 // gridstyle->insertItem("None",-1);
122 // gridstyle->insertItem("Dash",-1);
123 // gridstyle->insertItem("Dot",-1);
124 // gridstyle->setEnabled(false);
125 // gridstyle->setSelected(1); // "None"
127 // gridstylelabel = new QLabel( this, "gridstylelabel" );
128 // gridstylelabel->setGeometry( QRect( 210, 190, 210, 20 ) );
129 // gridstylelabel->setText( "Grid Style" );
131 xaxis = new QLineEdit(this, "xaxis");
132 xaxis->setGeometry(QRect(20, 240, 140, 30));
133 xaxis->setText("Columns");
135 yaxis = new QLineEdit(this, "yaxis");
136 yaxis->setGeometry(QRect(180, 240, 140, 30));
137 yaxis->setText("Pixel Values");
139 xaxislabel = new QLabel(this, "xaxislabel");
140 xaxislabel->setGeometry(QRect(70, 220, 60, 20));
141 xaxislabel->setText("X Axis");
143 yaxislabel = new QLabel(this, "yaxislabel");
144 yaxislabel->setGeometry(QRect(230, 220, 60, 20));
145 yaxislabel->setText("Y Axis");
147 minx = new QLineEdit(this, "minx");
148 minx->setGeometry(QRect(20, 300, 140, 30));
151 s.setNum(isrec ? (Sizex - 1) : (usrays - 1)); // at the bottom, it's set to usrays... why?
152 maxx = new QLineEdit(this, "maxx");
153 maxx->setGeometry(QRect(180, 300, 140, 30));
157 miny = new QLineEdit(this, "miny");
158 miny->setGeometry(QRect(20, 360, 140, 30));
162 maxy = new QLineEdit(this, "maxy");
163 maxy->setGeometry(QRect(180, 360, 140, 30));
166 // these should be sort of exactly the same as in linesimages
167 minxlabel = new QLabel(this, "minxlabel");
168 minxlabel->setGeometry(QRect(60, 280, 60, 20));
169 minxlabel->setText("Min Col");
171 maxxlabel = new QLabel(this, "maxxlabel");
172 maxxlabel->setGeometry(QRect(220, 280, 60, 20));
173 maxxlabel->setText("Max Col");
175 minylabel = new QLabel(this, "minylabel");
176 minylabel->setGeometry(QRect(70, 340, 60, 20));
177 minylabel->setText("Min Y");
179 maxylabel = new QLabel(this, "maxylabel");
180 maxylabel->setGeometry(QRect(230, 340, 60, 20));
181 maxylabel->setText("Max Y");
185 // jk 1/13/2009 adding grayScale option for graphs
186 // jklukowska 6/7/2009 modified to be radio button with option of either
187 // color or grayscale
188 colorbuttongroup = new QButtonGroup(this, "colorbuttongroup");
189 colorbuttongroup->setTitle(tr("Draw graphs in "));
190 colorbuttongroup->setGeometry(QRect(0, 400, 340, 75));
191 colorbuttongroup->setAlignment(int( QButtonGroup::AlignHCenter));
192 grayScaleButton = new QRadioButton(colorbuttongroup, "grayScaleButton");
193 grayScaleButton->setGeometry(QRect(30, 25, 130, 20));
194 grayScaleButton->setText(tr(" grayscale"));
195 grayScaleButton->setEnabled(true);
196 grayScaleButton->setChecked(false);
197 colorButton = new QRadioButton(colorbuttongroup, "colorButton");
198 colorButton->setGeometry(QRect(190, 25, 130, 20));
199 colorButton->setText(tr(" color"));
200 colorButton->setEnabled(true);
201 colorButton->setChecked(true);
203 //Line3 = new QFrame(this, "Line3");
204 //Line3->setGeometry(QRect(0, 485, 340, 16));
205 //Line3->setFrameStyle(QFrame::HLine | QFrame::Sunken);
207 showbutton = new QPushButton(this, "showbutton");
208 showbutton->setGeometry(QRect(20, 490, 100, 40));
209 showbutton->setText("Show");
210 QObject::connect(showbutton, SIGNAL(clicked()), this, SLOT(accept()));
212 cancelbutton = new QPushButton(this, "cancelbutton");
213 cancelbutton->setGeometry(QRect(220, 490, 100, 40));
214 cancelbutton->setText("Cancel");
215 QObject::connect(cancelbutton, SIGNAL(clicked()), this, SLOT(reject()));
217 updateXAxis(0); // another HACKish workaround by deniz for bug 98
221 * Destroys the object and frees any allocated resources
223 lineswindow::~lineswindow() {
224 // no need to delete child widgets, Qt does it all for us
229 @author Bruno M. Carvalho, a bit cleanup and change by deniz
231 void lineswindow::updateXAxis(int i) {
233 if (i == 0) { // (i==0), selection is Row, X Axis is columns
234 label1->setText("row1");
235 label2->setText("row2");
236 label3->setText("row3");
237 label4->setText("row4");
238 xaxis->setText("Columns");
239 minxlabel->setText("Min Col");
240 maxxlabel->setText("Max Col");
241 maxx_str.setNum(isrec ? (Sizex - 1) : (prjnum - 1));
242 // i think "-1" for everything makes more sense--deniz
243 } else { // (i==1), selection is Column, X Axis is rows
244 label1->setText("col1");
245 label2->setText("col2");
246 label3->setText("col3");
247 label4->setText("col4");
248 xaxis->setText("Rows");
249 minxlabel->setText("Min Row");
250 maxxlabel->setText("Max Row");
251 maxx_str.setNum(isrec ? (Sizey - 1) : (usrays - 1));
253 maxx->setText(maxx_str);
254 } // --lineswindow::updateXAxis()
258 @author Bruno M. Carvalho
260 int lineswindow::getLinetype() {
261 return rowcolbox->currentItem();
266 @author Bruno M. Carvalho
268 int lineswindow::getLine1() {
271 l = line1->text().toInt(&ok, 10);
280 @author Bruno M. Carvalho
282 int lineswindow::getLine2() {
285 l = line2->text().toInt(&ok, 10);
294 @author Bruno M. Carvalho
296 int lineswindow::getLine3() {
299 l = line3->text().toInt(&ok, 10);
308 @author Bruno M. Carvalho
310 int lineswindow::getLine4() {
313 l = line4->text().toInt(&ok, 10);
322 @author Bruno M. Carvalho
324 QString lineswindow::getTitle() {
325 return title->text();
330 // @author Bruno M. Carvalho
332 // int lineswindow::getSubtitle()
334 // return subtitle->currentItem();
339 // @author Bruno M. Carvalho
341 // int lineswindow::getGridstyle()
343 // return gridstyle->currentItem();
348 @author Bruno M. Carvalho
350 QString lineswindow::getXAxis() {
351 return xaxis->text();
356 @author Bruno M. Carvalho
358 QString lineswindow::getYAxis() {
359 return yaxis->text();
364 @author Bruno M. Carvalho
366 int lineswindow::getMinX() {
369 t = minx->text().toInt(&ok, 10);
378 @author Bruno M. Carvalho
380 int lineswindow::getMaxX() {
383 t = maxx->text().toInt(&ok, 10);
392 @author Bruno M. Carvalho
394 double lineswindow::getMinY() {
397 t = miny->text().toDouble(&ok);
406 @author Bruno M. Carvalho
408 double lineswindow::getMaxY() {
411 t = maxy->text().toDouble(&ok);
420 @author Bruno M. Carvalho
422 bool lineswindow::isPhantomChecked() {
423 return (phantombutton->isChecked());
428 @author Joanna Klukowska (added 1/13/2009)
430 bool lineswindow::isGrayScaleChecked() {
431 return (grayScaleButton->isChecked());