Legend:
- Unmodified
- Added
- Removed
-
tools/ddd/Functions.cpp
r50 r59 2 2 #include "GUI.h" 3 3 4 //--------------------------------------------------------------------- --5 //************************ ****All functions ****************************6 //------------------------------------------------------------------- ----4 //--------------------------------------------------------------------- 5 //************************ All functions **************************** 6 //------------------------------------------------------------------- 7 7 8 8 // +++ Open file dialog +++ 9 9 void ddd::FileDialog(void) { 10 11 10 QString Filename = QFileDialog::getOpenFileName(this, 11 "Open raw file", INITIAL_DIRECTORY, "Raw data files (*.raw);; All files (*)"); 12 12 if (Filename != NULL) { 13 13 FilenameBox->setText(Filename); … … 100 100 double* x = new double [RD->RHeader->Samples]; 101 101 double* y = new double [RD->RHeader->Samples]; 102 102 103 for (unsigned int i=0; i<RD->RHeader->Samples; i++) { 103 104 x[i] = (double) (i/RD->BStruct[BoardNo->value()].NomFreq); … … 108 109 Signal->show(); 109 110 Zoomer->setZoomBase(Signal->boundingRect()); 110 delete[] x; delete[] y; 111 112 double z[6][6]; 113 114 for(unsigned int i=0; i<RD->RHeader->NBoards; i++){ 115 for(unsigned int j=0; j<RD->RHeader->NChips; j++){ 116 for(unsigned int k=0; k<RD->RHeader->NChannels; k++) { 117 118 //only interested in M0 data 119 if( ( (i==0 || i==1) && (j<=1) && (k<=7) ) || ( (i==2) && (j==0) && (k<=3) ) ) { 120 121 std::string pixelname = PixMap->DRS_to_Pixel(i,j,k); 122 char pixelname_copy[256]; 123 memset(pixelname_copy,'\0',256); 124 pixelname.copy(pixelname_copy, 256); 125 126 //printf("\nboard %d, chip %d, channel %d, pixel %s:\t", i,j,k,pixelname_copy); 127 128 char delim[] = "-"; 129 char *buffer = NULL; 130 int module = -1; 131 int superpixel = -1; 132 int pixel = -1; 133 134 //buffer = strtok(const_cast<char*>(pixelname.c_str()), delim); 135 buffer = strtok(pixelname_copy, delim); 136 module = atoi(buffer); 137 buffer = strtok(NULL, delim); 138 superpixel = atoi(buffer); 139 buffer = strtok(NULL, delim); 140 pixel = atoi(buffer); 141 142 //printf("%d,%d,%d:\t", module, superpixel, pixel); 143 //printf("%d:\t", (int((superpixel-1)/3)*2)); 144 //printf("%d:\t", int((pixel%4)+1) ); 145 //printf("%d:\t", int((pixel%4)/2) ); 146 //printf("%d:\t", (superpixel-1)%3 ); 147 148 int binx = 5-(int((superpixel-1)/3)*2)-(int((pixel%4)/2)); 149 int biny = 5-(((superpixel-1)%3)*2)-(int((pixel-1)/2)); 150 151 //printf("%d, %d:\t",binx,biny); 152 153 int StartBin = 100; 154 int StopBin = 120; 155 156 for(int l=StartBin; l<(StopBin+1); l++){ 157 158 float sample = RD->Data[i*RD->RHeader->NChips*RD->RHeader->NChannels*RD->RHeader->Samples+ 159 j*RD->RHeader->NChannels*RD->RHeader->Samples+ 160 k*RD->RHeader->Samples+ 161 l]*RD->BStruct[i].ScaleFactor; 162 163 //printf("%.1f ",sample); 164 165 if (sample > z[binx][biny]) { 166 z[binx][biny]=sample; 167 } 168 169 }//sample loop 170 171 }//only M0 data 172 173 }//channel loop 174 }//chip loop 175 }//board loop 176 177 /* 178 for (int i=0; i<6; i++){ 179 for (int j=0; j<6; j++){ 180 z[i][j]=i; 181 } 182 } 183 */ 184 185 Signal2D->setData(SpectrogramDataM0(z)); 186 Graph2D->axisWidget(QwtPlot::yRight)->setColorMap(Signal2D->data().range(),Signal2D->colorMap()); 187 Graph2D->setAxisScale(QwtPlot::yRight,Signal2D->data().range().minValue(),Signal2D->data().range().maxValue() ); 188 Graph2D->replot(); 189 //Signal2D->show(); 190 191 delete[] x; delete[] y; 192 111 193 } 112 194 if(Tmpfile!=NULL) fclose(Tmpfile); … … 119 201 else SocketWindow->show(); 120 202 } 203 204 // +++ Open sub window for M0 Display +++ 205 void ddd::OpenM0Window() { 206 207 if(M0Window->isVisible()) M0Window->hide(); 208 else M0Window->show(); 209 } 210 121 211 122 212 // +++ Acquire data through socket (acquire botton only available if socket exists) +++ -
tools/ddd/GUI.cpp
r34 r59 74 74 connect(SocketButton, SIGNAL(clicked()), this, SLOT(OpenSocketWindow())); 75 75 SocketButton->setToolTip("Open window for socket communication"); 76 77 // M0 display button 78 M0Display = new QPushButton("M0 Display",Central); 79 M0Display->setFont(QFont("Times", 10, QFont::Bold)); 80 connect(M0Display, SIGNAL(clicked()), this, SLOT(OpenM0Window())); 81 M0Display->setToolTip("Open window for M0 display"); 76 82 77 83 // Acquire button and Continuous check box … … 101 107 Signal->attach(Graph); 102 108 Signal->setStyle(QwtPlotCurve::Steps); 103 109 104 110 // Text boxes for run and event header 105 111 RunHeaderDisplay = new QPlainTextEdit(Central); … … 133 139 MainLayout->addLayout(FormLayout, 2, 0); 134 140 MainLayout->addWidget(SocketButton, 6,0); 141 MainLayout->addWidget(M0Display, 3,0); 135 142 MainLayout->addWidget(GetButton, 4,0); 136 143 MainLayout->addWidget(ContinuousBox, 5,0); … … 162 169 SocketWindow = new QWidget(); 163 170 SocketWindow->setWindowTitle("ddd - Socket Interface"); 164 171 165 172 // Edit box for IP Address 166 173 IPAddress = new QLineEdit(SocketWindow); … … 197 204 SocketOutput->setMaximumBlockCount(MAX_OUTPUT_LINES); 198 205 SocketOutput->setToolTip("Output of socket server"); 199 206 200 207 // Layout of all widgets 201 208 SocketLayout = new QGridLayout(SocketWindow); … … 204 211 SocketLayout->addWidget(Connect, 0, 3); 205 212 SocketLayout->addLayout(CommandLayout, 1, 0, 1, 4); 206 SocketLayout->addWidget(SocketOutput, 2, 0, 4, 4); 213 SocketLayout->addWidget(SocketOutput, 2, 0, 4, 4); 214 215 //----------------------------------------------------------------------- 216 //**************************** M0 window **************************** 217 //----------------------------------------------------------------------- 218 219 M0Window = new QWidget(); 220 M0Window->setWindowTitle("ddd - M0 Display"); 221 222 Graph2D = new QwtPlot(M0Window); 223 Graph2D->setAutoReplot(true); 224 Graph2D->setCanvasBackground(QColor(Qt::white)); 225 226 M0Layout = new QGridLayout(M0Window); 227 M0Layout->addWidget(Graph2D, 1,1,3,3); 228 229 Signal2D = new QwtPlotSpectrogram; 230 Signal2D->attach(Graph2D); 231 232 //initialize raster 233 double z[6][6]; 234 for (int i=0; i<6; i++){ 235 for (int j=0; j<6; j++){ 236 z[i][j]=i+j; 237 } 238 } 239 Signal2D->setData(SpectrogramDataM0(z)); 240 241 colorMap = QwtLinearColorMap(Qt::yellow, Qt::red); 242 Signal2D->setColorMap(colorMap); 243 244 //Graph2D->axisWidget(QwtPlot::yRight)->setTitle("Yo!"); 245 Graph2D->axisWidget(QwtPlot::yRight)->setColorBarEnabled(true); 246 Graph2D->axisWidget(QwtPlot::yRight)->setColorMap(Signal2D->data().range(),Signal2D->colorMap()); 247 248 Graph2D->setAxisScale(QwtPlot::yRight,Signal2D->data().range().minValue(),Signal2D->data().range().maxValue()); 249 Graph2D->enableAxis(QwtPlot::yRight); 250 Graph2D->plotLayout()->setAlignCanvasToScales(true); 251 Graph2D->replot(); 252 207 253 } 208 254 … … 210 256 // Qwt items 211 257 delete Grid; delete Signal; 258 delete Signal2D; 212 259 // Layout items 213 260 delete PortLayout; delete CommandLayout; … … 216 263 // Other items 217 264 delete SocketWindow; 265 delete M0Window; 218 266 delete PixMap; delete RD; 219 267 } -
tools/ddd/GUI.h
r29 r59 10 10 #include <qwt_plot_zoomer.h> 11 11 #include <qwt_plot_panner.h> 12 #include <qwt_plot_spectrogram.h> 13 #include <qwt_raster_data.h> 14 #include <qwt_scale_widget.h> 15 #include <qwt_plot_layout.h> 16 #include <qwt_color_map.h> 12 17 13 18 #include "../../drsdaq/RawDataCTX.h" … … 22 27 class ddd : public QMainWindow { 23 28 Q_OBJECT 24 25 QPushButton *GetButton, *SocketButton, *Connect ;29 30 QPushButton *GetButton, *SocketButton, *Connect, *M0Display; 26 31 QCheckBox *ContinuousBox; 27 32 QToolButton *LoadButton; … … 31 36 QTabWidget *TabWidget; 32 37 QTcpSocket *Socket; 33 QWidget *SocketWindow, *Central ;38 QWidget *SocketWindow, *Central, *M0Window; 34 39 QAction *OpenAction, *ConnectAction; 35 QGridLayout *SocketLayout, *MainLayout ;40 QGridLayout *SocketLayout, *MainLayout, *M0Layout; 36 41 QFormLayout *CommandLayout, *PortLayout, *AddressLayout, *FormLayout, *SpinLayout; 37 42 38 QwtPlot *Graph ;43 QwtPlot *Graph, *Graph2D; 39 44 QwtPlotZoomer *Zoomer; 40 45 QwtPlotCurve *Signal; 41 46 QwtPlotPanner *Panner; 42 47 QwtPlotGrid *Grid; 43 48 QwtPlotSpectrogram *Signal2D; 49 QwtLinearColorMap colorMap; 50 44 51 void closeEvent(QCloseEvent *); 45 52 … … 58 65 void FileDialog(); 59 66 void OpenSocketWindow(); 67 void OpenM0Window(); 60 68 void GetSignalFromSocket(); 61 69 void MakeConnection(); … … 71 79 }; 72 80 81 //class for 2D spectrogram data 82 class SpectrogramDataM0: public QwtRasterData { 83 84 private: 85 86 double _z[6][6]; 87 double _zmin; 88 double _zmax; 89 90 public: 91 92 SpectrogramDataM0(const double z[6][6]): QwtRasterData(QwtDoubleRect(0, 0, 6, 6)) { 93 for (int i = 0; i<6; i++){ 94 for (int j = 0; j<6; j++){ 95 _z[i][j] = z[i][j]; 96 if (z[i][j] > _zmax) _zmax = z[i][j]; 97 if (z[i][j] < _zmin) _zmin = z[i][j]; 98 } 99 } 100 } 101 102 virtual QwtRasterData *copy() const { 103 return new SpectrogramDataM0(_z); 104 } 105 106 virtual QwtDoubleInterval range() const { 107 return QwtDoubleInterval(_zmin, _zmax); 108 } 109 110 virtual void initRaster(const QwtDoubleRect = QwtDoubleRect(0, 0, 6, 6), 111 const QSize =QSize(1,1)) {}; 112 113 virtual double value(double x, double y) const { 114 115 unsigned int first = (unsigned int)x; 116 unsigned int second = (unsigned int)y; 117 118 const double v = _z[first][second]; 119 return v; 120 121 } 122 123 };
Note:
See TracChangeset
for help on using the changeset viewer.