1 /** @file linesimages.cpp
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
12 #include "linesimages.hpp"
13 #include "selectimages.hpp"
14 #include "variables.hpp"
18 #include <qcombobox.h>
21 #include <qlineedit.h>
22 #include <q3listbox.h>
23 #include <qpushbutton.h>
24 #include <qradiobutton.h>
28 #include <qwhatsthis.h>
29 #include <qmessagebox.h>
31 extern Snarkimage **imageset;
33 /* "Lines" (plotting of pixel values in a row or column) dialog for multiple images
34 * Constructs a linesimageswindow which is a child of 'parent', with the
35 * name 'name' and widget flags set to 'fl'
37 * The dialog will by default be modeless, unless you set 'modal' to
38 * TRUE to construct a modal dialog.
40 linesimageswindow::linesimageswindow( QWidget* parent, const char* name, bool modal, WFlags fl )
41 : QDialog( parent, name, modal, fl )
43 setName( "lineswindow" );
45 setMinimumSize( QSize( 340, 550 ) );
46 setMaximumSize( QSize( 340, 550 ) );
47 setCaption( tr( "Multiple Images Profile" ) );
51 rowcolbox = new QListBox( this, "rowcolbox" );
52 rowcolbox->insertItem( tr( "rows" ) ); // rows first. => 0 => false [ x-axis == columns ] [sic]
53 rowcolbox->insertItem( tr( "columns" ) ); // columns later => 1 => true [ x-axis == rows ] [sic]
54 rowcolbox->setGeometry( QRect( 20, 10, 80, 50 ) );
55 rowcolbox->setSelectionMode(QListBox::Single);
56 rowcolbox->setSelected(0,true);
57 QObject::connect(rowcolbox,SIGNAL(highlighted(int)),this,SLOT(updateXAxis(int)));
58 imagesbutton = new QPushButton( this, "imagesbutton" );
59 imagesbutton->setGeometry( QRect( 130, 20, 140, 40 ) );
60 imagesbutton->setText( tr( "Select Images" ) );
61 QObject::connect(imagesbutton,SIGNAL(clicked()),this,SLOT(callSelectImages()));
63 line1 = new QLineEdit( this, "line1" );
64 line1->setGeometry( QRect( 20, 90, 60, 30 ) );
65 line2 = new QLineEdit( this, "line2" );
66 line2->setGeometry( QRect( 100, 90, 60, 30 ) );
67 line3 = new QLineEdit( this, "line3" );
68 line3->setGeometry( QRect( 180, 90, 60, 30 ) );
69 line4 = new QLineEdit( this, "line4" );
70 line4->setGeometry( QRect( 260, 90, 60, 30 ) );
72 label1 = new QLabel( this, "label1" );
73 label1->setGeometry( QRect( 33, 70, 35, 20 ) );
74 label1->setText( tr( "row1" ) );
75 label2 = new QLabel( this, "label2" );
76 label2->setGeometry( QRect( 113, 70, 35, 20 ) );
77 label2->setText( tr( "row2" ) );
78 label3 = new QLabel( this, "label3" );
79 label3->setGeometry( QRect( 193, 70, 35, 20 ) );
80 label3->setText( tr( "row3" ) );
81 label4 = new QLabel( this, "label4" );
82 label4->setGeometry( QRect( 273, 70, 35, 20 ) );
83 label4->setText( tr( "row4" ) );
85 title = new QLineEdit( this, "title" );
86 title->setGeometry( QRect( 20, 150, 300, 30 ) );
87 QString nameprojQStr = nameproj;
88 title->setText(nameprojQStr.simplifyWhiteSpace());
89 titlelabel = new QLabel( this, "titlelabel" );
90 titlelabel->setGeometry( QRect( 160, 130, 60, 20 ) );
91 titlelabel->setText( tr( "Title" ) );
93 // subtitle = new QComboBox( this, "subtitle" );
94 // subtitle->setGeometry( QRect( 20, 210, 140, 30 ) );
95 // subtitle->insertItem("Column/Line #",-1);
96 // subtitle->insertItem("Empty",-1);
97 // subtitlelabel = new QLabel( this, "subtitlelabel" );
98 // subtitlelabel->setGeometry( QRect( 60, 190, 100, 20 ) );
99 // subtitlelabel->setText( tr( "Subtitle" ) );
101 // gridstyle = new QComboBox(this,"gridstyle");
102 // gridstyle->setGeometry( QRect( 180, 210, 140, 30 ) );
103 // gridstyle->insertItem("Solid",-1);
104 // gridstyle->insertItem("None",-1);
105 // gridstyle->insertItem("Dash",-1);
106 // gridstyle->insertItem("Dot",-1);
108 // gridstylelabel = new QLabel( this, "gridstylelabel" );
109 // gridstylelabel->setGeometry( QRect( 210, 190, 210, 20 ) );
110 // gridstylelabel->setText( tr( "Grid Style" ) );
112 xaxis = new QLineEdit( this, "xaxis" );
113 xaxis->setEnabled(false); // user doesn't change it
114 xaxis->setGeometry( QRect( 20, 240, 140, 30 ) );
115 xaxis->setText("Columns"); // default setting
117 yaxis = new QLineEdit( this, "yaxis" );
118 yaxis->setEnabled(false);
119 yaxis->setGeometry( QRect( 180, 240, 140, 30 ) );
120 yaxis->setText("Pixel Values");
122 xaxislabel = new QLabel( this, "xaxislabel" );
123 xaxislabel->setGeometry( QRect( 70, 220, 60, 20 ) );
124 xaxislabel->setText( tr( "X Axis" ) );
126 yaxislabel = new QLabel( this, "yaxislabel" );
127 yaxislabel->setGeometry( QRect( 230, 220, 60, 20 ) );
128 yaxislabel->setText( tr( "Y Axis" ) );
130 minx = new QLineEdit( this, "minx" );
131 minx->setGeometry( QRect( 20, 300, 140, 30 ) );
136 maxx = new QLineEdit( this, "maxx" );
137 maxx->setGeometry( QRect( 180, 300, 140, 30 ) );
141 miny = new QLineEdit( this, "miny" );
142 miny->setGeometry( QRect( 20, 360, 140, 30 ) );
146 maxy = new QLineEdit( this, "maxy" );
147 maxy->setGeometry( QRect( 180, 360, 140, 30 ) );
150 minxlabel = new QLabel( this, "minxlabel" );
151 minxlabel->setGeometry( QRect( 60, 280, 60, 20 ) );
152 minxlabel->setText( tr( "Min Col" ) ); // OK, so shoot me for hardcoding
154 maxxlabel = new QLabel( this, "maxxlabel" );
155 maxxlabel->setGeometry( QRect( 220, 280, 60, 20 ) );
156 maxxlabel->setText( tr( "Max Col" ) );
158 minylabel = new QLabel( this, "minylabel" );
159 minylabel->setGeometry( QRect( 70, 340, 60, 20 ) );
160 minylabel->setText( tr( "Min Y" ) );
162 maxylabel = new QLabel( this, "maxylabel" );
163 maxylabel->setGeometry( QRect( 230, 340, 60, 20 ) );
164 maxylabel->setText( tr( "Max Y" ) );
167 // jk 1/13/2009 adding grayScale option for graphs
168 // jklukowska 6/7/2009 modified to be radio button with option of either
169 // color or grayscale
170 colorbuttongroup = new QButtonGroup(this, "colorbuttongroup");
171 colorbuttongroup->setTitle(tr("Draw graphs in "));
172 colorbuttongroup->setGeometry(QRect(0, 400, 340, 75));
173 colorbuttongroup->setAlignment(int( QButtonGroup::AlignHCenter));
174 grayScaleButton = new QRadioButton(colorbuttongroup, "grayScaleButton");
175 grayScaleButton->setGeometry(QRect(30, 25, 130, 20));
176 grayScaleButton->setText(tr(" grayscale"));
177 grayScaleButton->setEnabled(true);
178 grayScaleButton->setChecked(false);
179 colorButton = new QRadioButton(colorbuttongroup, "colorButton");
180 colorButton->setGeometry(QRect(190, 25, 130, 20));
181 colorButton->setText(tr(" color"));
182 colorButton->setEnabled(true);
183 colorButton->setChecked(true);
185 //Line3 = new QFrame( this, "Line3" );
186 //Line3->setGeometry( QRect( 0, 485, 340, 16 ) );
187 //Line3->setFrameStyle( QFrame::HLine | QFrame::Sunken );
189 showbutton = new QPushButton( this, "showbutton" );
190 showbutton->setGeometry( QRect( 20, 490, 100, 40 ) );
191 showbutton->setText( tr( "Show" ) );
192 QObject::connect(showbutton,SIGNAL(clicked()),this,SLOT(checkAndAccept()));
194 cancelbutton = new QPushButton( this, "cancelbutton" );
195 cancelbutton->setGeometry( QRect( 220, 490, 100, 40 ) );
196 cancelbutton->setText( tr( "Cancel" ) );
197 QObject::connect(cancelbutton,SIGNAL(clicked()),this,SLOT(reject()));
198 } // --linesimageswindow ctor
201 * Destroys the object and frees any allocated resources
203 linesimageswindow::~linesimageswindow()
205 // no need to delete child widgets, Qt does it all for us
210 @author Bruno M. Carvalho
212 void linesimageswindow::updateXAxis(int i) // i is 1 for row, 0 for cols
214 if(i==0) { // so x axis is the other.
215 label1->setText("row1");
216 label2->setText("row2");
217 label3->setText("row3");
218 label4->setText("row4");
219 xaxis->setText("Columns");
220 minxlabel->setText("Min Col");
221 maxxlabel->setText("Max Col");
223 label1->setText("col1");
224 label2->setText("col2");
225 label3->setText("col3");
226 label4->setText("col4");
227 xaxis->setText("Rows");
228 minxlabel->setText("Min Row");
229 maxxlabel->setText("Max Row");
231 } // --linesimageswindow::updateXAxis()
233 /** Starts a window for selecting the images to be shownfor a lines command
235 @author Bruno M. Carvalho
237 void linesimageswindow::callSelectImages()
242 selectimageswindow* nw=new selectimageswindow(this,"Select Images for Line Displaying",true);
244 if(c==QDialog::Accepted) {
245 siarray=nw->getSelectedImages();
246 if(siarray[0]==0 && !phantombutton->isChecked())
247 QMessageBox::information(this,"SnarkDisplay","Warning!\n"
248 "No image was selected.\n");
251 selectedimages = (int*) malloc((unsigned) (siarray[0]+1)*sizeof(int));
252 if(!selectedimages) {
253 QMessageBox::information(this,"SnarkDisplay","Error!\n"
254 "Allocation failure in getSelectedImages()\n");
257 selectedimages[0]=siarray[0];
258 for(i=1;i<=siarray[0];i++) {
259 selectedimages[i]=siarray[i];
260 if(!imageset[siarray[i]]->isLoaded())
261 imageset[siarray[i]]->readImage(siarray[i],dataformat);
265 /* s.sprintf("%f",globalmin);
267 s.sprintf("%f",globalmax);
274 @author Bruno M. Carvalho
276 int* linesimageswindow::getSelectedImages()
278 return selectedimages;
283 @author Bruno M. Carvalho
285 int linesimageswindow::getLinetype()
287 return rowcolbox->currentItem();
292 @author Bruno M. Carvalho
294 int linesimageswindow::getLine1()
298 l=line1->text().toInt(&ok,10);
307 @author Bruno M. Carvalho
309 int linesimageswindow::getLine2()
313 l=line2->text().toInt(&ok,10);
322 @author Bruno M. Carvalho
324 int linesimageswindow::getLine3()
328 l=line3->text().toInt(&ok,10);
337 @author Bruno M. Carvalho
339 int linesimageswindow::getLine4()
343 l=line4->text().toInt(&ok,10);
353 @author Bruno M. Carvalho
355 bool linesimageswindow::isPhantomChecked()
357 if(phantombutton->isChecked())
365 @author Bruno M. Carvalho
367 QString linesimageswindow::getTitle()
369 return title->text();
374 // @author Bruno M. Carvalho
376 // int linesimageswindow::getSubtitle()
378 // return subtitle->currentItem();
383 // @author Bruno M. Carvalho
385 // int linesimageswindow::getGridstyle()
387 // return gridstyle->currentItem();
392 @author Bruno M. Carvalho
394 QString linesimageswindow::getXAxis()
396 return xaxis->text();
401 @author Bruno M. Carvalho
403 QString linesimageswindow::getYAxis()
405 return yaxis->text();
411 @author Bruno M. Carvalho
413 int linesimageswindow::getMinX()
417 t=minx->text().toInt(&ok,10);
426 @author Bruno M. Carvalho
428 int linesimageswindow::getMaxX()
432 t=maxx->text().toInt(&ok,10);
442 @author Bruno M. Carvalho
444 double linesimageswindow::getMinY()
448 t=miny->text().toDouble(&ok);
457 @author Bruno M. Carvalho
459 double linesimageswindow::getMaxY()
463 t=maxy->text().toDouble(&ok);
470 void linesimageswindow::checkAndAccept()
476 QMessageBox::information(this,"SnarkDisplay","Error!\n"
477 "No image was selected.\n");
483 @author Joanna Klukowska (added 1/13/2009)
485 bool linesimageswindow::isGrayScaleChecked() {
486 return (grayScaleButton->isChecked());