| 1 | #include "QCameraWidget.h"
|
|---|
| 2 |
|
|---|
| 3 | #include <sstream>
|
|---|
| 4 | #include <iostream>
|
|---|
| 5 |
|
|---|
| 6 | #include <QMouseEvent>
|
|---|
| 7 |
|
|---|
| 8 | using namespace std;
|
|---|
| 9 |
|
|---|
| 10 | QCameraWidget::QCameraWidget(QWidget *pparent) : BasicGlCamera(pparent)
|
|---|
| 11 | {
|
|---|
| 12 | fBold.resize(1440, false);
|
|---|
| 13 | fEnable.resize(1440, true);
|
|---|
| 14 | lastFace = -1;
|
|---|
| 15 | fShowPixelMoveOver = false;
|
|---|
| 16 | fShowPatchMoveOver = false;
|
|---|
| 17 |
|
|---|
| 18 | CalculatePixelsColor();
|
|---|
| 19 |
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | void QCameraWidget::paintGL()
|
|---|
| 23 | {
|
|---|
| 24 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|---|
| 25 | glLoadIdentity();
|
|---|
| 26 |
|
|---|
| 27 | glTranslatef(0,-0.44,0);
|
|---|
| 28 | glTranslatef(-0.1,0,0);
|
|---|
| 29 | glRotatef(cameraRotation, 0,0,-1);
|
|---|
| 30 | if (cameraRotation == 90)
|
|---|
| 31 | {
|
|---|
| 32 | glTranslatef(-0.45,-0.45,0);
|
|---|
| 33 | // cout << "correction" << endl;
|
|---|
| 34 | }
|
|---|
| 35 | if (cameraRotation == -90)
|
|---|
| 36 | {
|
|---|
| 37 | glTranslatef(0.45,-0.45,0);
|
|---|
| 38 | }
|
|---|
| 39 | glScalef(1.5, 1.5, 1.0);
|
|---|
| 40 | glTranslatef(0,0,-0.5);
|
|---|
| 41 | drawCamera(true);
|
|---|
| 42 | glTranslatef(0,0,0.1f);
|
|---|
| 43 |
|
|---|
| 44 | drawPatches();
|
|---|
| 45 | glTranslatef(0,0,0.1f);
|
|---|
| 46 |
|
|---|
| 47 | glLineWidth(1.0f);
|
|---|
| 48 | glColor3fv(highlightedPixelsCoulour);
|
|---|
| 49 | for (vector<int>::iterator it = highlightedPixels.begin(); it!= highlightedPixels.end(); it++)
|
|---|
| 50 | {
|
|---|
| 51 | drawHexagon(*it, false);
|
|---|
| 52 | }
|
|---|
| 53 |
|
|---|
| 54 | glLineWidth(1.0f);
|
|---|
| 55 | glTranslatef(0,0,0.1f);
|
|---|
| 56 |
|
|---|
| 57 | //glColor3f(1.f - pixelsColor[fWhite][0],1.f - pixelsColor[fWhite][1],1.f - pixelsColor[fWhite][2]);
|
|---|
| 58 | if (fWhite != -1)
|
|---|
| 59 | {
|
|---|
| 60 | glColor3f(1.f, 0.f, 0.f);
|
|---|
| 61 | drawHexagon(fWhite, false);
|
|---|
| 62 | }
|
|---|
| 63 | DrawCameraText();
|
|---|
| 64 |
|
|---|
| 65 | DrawScale();
|
|---|
| 66 |
|
|---|
| 67 | // if (linearButton->isVisible())
|
|---|
| 68 | // repaintInterface();
|
|---|
| 69 | }
|
|---|
| 70 | void QCameraWidget::drawCamera(bool alsoWire)
|
|---|
| 71 | {
|
|---|
| 72 |
|
|---|
| 73 | if (!pixelColorUpToDate)
|
|---|
| 74 | CalculatePixelsColor();
|
|---|
| 75 | glLineWidth(1.0);
|
|---|
| 76 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
|---|
| 77 | {
|
|---|
| 78 | glColor3fv(pixelsColor[i]);
|
|---|
| 79 | glLoadName(i);
|
|---|
| 80 | drawHexagon(i,true);
|
|---|
| 81 | }
|
|---|
| 82 | if (!alsoWire)
|
|---|
| 83 | return;
|
|---|
| 84 | glTranslatef(0,0,0.1f);
|
|---|
| 85 | glColor3fv(pixelContourColour);//0.0f,0.0f,0.0f);
|
|---|
| 86 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
|---|
| 87 | {
|
|---|
| 88 | drawHexagon(i, false);
|
|---|
| 89 | }
|
|---|
| 90 | }
|
|---|
| 91 | void QCameraWidget::DrawCameraText()
|
|---|
| 92 | {
|
|---|
| 93 | if (!fTextEnabled) return;
|
|---|
| 94 |
|
|---|
| 95 | glPushMatrix();
|
|---|
| 96 | glLoadIdentity();
|
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 | // int textSize = (int)(width()*14/600);
|
|---|
| 101 | // setFont(QFont("Monospace", textSize));
|
|---|
| 102 | qglColor(QColor(25, 22, 12));
|
|---|
| 103 |
|
|---|
| 104 | //first let's draw the usual data
|
|---|
| 105 | //title
|
|---|
| 106 | renderText(-shownSizex/2.f + 0.01f, shownSizey/2.f - fTextSize*pixelSize - 0.01f, 0.f, QString(titleText.c_str()));
|
|---|
| 107 | //stats
|
|---|
| 108 | ostringstream str;
|
|---|
| 109 | str.precision(2);
|
|---|
| 110 | str.setf(ios::fixed,ios::floatfield);
|
|---|
| 111 | str << "Med " << fmedian;// << unitsText;
|
|---|
| 112 | renderText(3, height()-3-4*fTextSize-35, QString(str.str().c_str()));
|
|---|
| 113 | str.str("");
|
|---|
| 114 | str << "Avg " << fmean;// << unitsText;
|
|---|
| 115 | renderText(3, height()-3-3*fTextSize-27, QString(str.str().c_str()));
|
|---|
| 116 | str.str("");
|
|---|
| 117 | str << "RMS " << frms;// << unitsText;
|
|---|
| 118 | renderText(3, height()-3-2*fTextSize-21, QString(str.str().c_str()));
|
|---|
| 119 | str.str("");
|
|---|
| 120 | str << "Min " << fmin;// << unitsText;
|
|---|
| 121 | renderText(3, height()-3-3, QString(str.str().c_str()));
|
|---|
| 122 | str.str("");
|
|---|
| 123 | str << "Max " << fmax;// << unitsText;
|
|---|
| 124 | renderText(3, height()-3-1*fTextSize-8, QString(str.str().c_str()));
|
|---|
| 125 | //then draw the values beside the scale
|
|---|
| 126 | //the difficulty here is to write the correct min/max besides the scale
|
|---|
| 127 | //it depends whether the actual mean of the data is given by the user
|
|---|
| 128 | //or not. the values given by user are fMin and fMax, while the data
|
|---|
| 129 | //real min/max are fmin and fmax (I know, quite confusing... sorry about that)
|
|---|
| 130 | //so. first let's see what is the span of one pixel
|
|---|
| 131 | float min = (fMin < fScaleLimit || fMax < fScaleLimit) ? fmin : fMin;
|
|---|
| 132 | float max = (fMin < fScaleLimit || fMax < fScaleLimit) ? fmax : fMax;
|
|---|
| 133 | // textSize = (int)(height()*12/600);
|
|---|
| 134 | // setFont(QFont("Monospace", textSize));
|
|---|
| 135 | float pixelSpan = (height() - fTextSize - 1)/(max - min);
|
|---|
| 136 |
|
|---|
| 137 | //draw the scale values
|
|---|
| 138 | float value = min;
|
|---|
| 139 | int fontWidth = fTextSize;
|
|---|
| 140 | if (fTextSize > 12) fontWidth--;
|
|---|
| 141 | if (fTextSize > 10) fontWidth--;
|
|---|
| 142 | if (fTextSize > 7) fontWidth--;//else fontWidth -=1;
|
|---|
| 143 | // if (fTextSize < 7) fontWidth++;
|
|---|
| 144 | for (int i=0;i<11;i++)
|
|---|
| 145 | {
|
|---|
| 146 | str.str("");
|
|---|
| 147 | str << value;
|
|---|
| 148 | if (i==0 || i==10)
|
|---|
| 149 | str << ' ' << unitsText;
|
|---|
| 150 | str << ' ';
|
|---|
| 151 | int h = (value - min)*pixelSpan;
|
|---|
| 152 | if (logScale && h != 0)
|
|---|
| 153 | {
|
|---|
| 154 | float fh = h;
|
|---|
| 155 | float mult = (max - min)*pixelSpan;
|
|---|
| 156 | fh = log10(h*10.f/mult);
|
|---|
| 157 | fh *= mult;
|
|---|
| 158 | h = (int)fh;
|
|---|
| 159 | }
|
|---|
| 160 | h = height()-h;
|
|---|
| 161 | int w = width() - (width()/50) - fontWidth*str.str().size();
|
|---|
| 162 | if (i==0 || i==10) w -= width()/50;
|
|---|
| 163 | if (i!=0 && i!=10) h -= fTextSize/2;
|
|---|
| 164 | renderText(w, h, QString(str.str().c_str()));
|
|---|
| 165 | value += (max - min)/10;
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | /*
|
|---|
| 169 | str.str("");
|
|---|
| 170 | str << min << unitsText;
|
|---|
| 171 | int fontWidth = textSize;
|
|---|
| 172 | if (textSize > 12) fontWidth-=3; else fontWidth -= 2;
|
|---|
| 173 | //height of min ?
|
|---|
| 174 | int hmin = (min - min)*pixelSpan;
|
|---|
| 175 | hmin = height() - hmin;
|
|---|
| 176 | renderText(width() - (width()/25) - fontWidth*str.str().size(), hmin, QString(str.str().c_str()));
|
|---|
| 177 | str.str("");
|
|---|
| 178 | str << max << unitsText;
|
|---|
| 179 | int hmax = (max - min)*pixelSpan;
|
|---|
| 180 | hmax = height() - hmax;
|
|---|
| 181 | renderText(width() - (width()/25) - fontWidth*str.str().size(), hmax, QString(str.str().c_str()));
|
|---|
| 182 | */
|
|---|
| 183 | glPopMatrix();
|
|---|
| 184 |
|
|---|
| 185 | // textSize = (int)(600*14/600);
|
|---|
| 186 | // setFont(QFont("Times", textSize));
|
|---|
| 187 | }
|
|---|
| 188 | void QCameraWidget::drawPatches()
|
|---|
| 189 | {
|
|---|
| 190 | glLineWidth(3.0f);
|
|---|
| 191 | glColor3fv(patchesCoulour);
|
|---|
| 192 | glBegin(GL_LINES);
|
|---|
| 193 | for (int i=0;i<NTMARK;i++)
|
|---|
| 194 | {
|
|---|
| 195 | for (unsigned int j=0;j<patchesIndices[i].size();j++)
|
|---|
| 196 | {
|
|---|
| 197 | glVertex2fv(verticesList[patchesIndices[i][j].first]);
|
|---|
| 198 | glVertex2fv(verticesList[patchesIndices[i][j].second]);
|
|---|
| 199 | }
|
|---|
| 200 | }
|
|---|
| 201 | glEnd();
|
|---|
| 202 | glTranslatef(0,0,0.1f);
|
|---|
| 203 |
|
|---|
| 204 | glColor3fv(highlightedPatchesCoulour);
|
|---|
| 205 | glBegin(GL_LINES);
|
|---|
| 206 | for (vector<int>::iterator it=highlightedPatches.begin(); it!= highlightedPatches.end(); it++)
|
|---|
| 207 | {
|
|---|
| 208 | for (unsigned int j=0;j<patchesIndices[*it].size();j++)
|
|---|
| 209 | {
|
|---|
| 210 | glVertex2fv(verticesList[patchesIndices[*it][j].first]);
|
|---|
| 211 | glVertex2fv(verticesList[patchesIndices[*it][j].second]);
|
|---|
| 212 | }
|
|---|
| 213 | }
|
|---|
| 214 | glEnd();
|
|---|
| 215 | if (fWhitePatch != -1)
|
|---|
| 216 | {
|
|---|
| 217 | glTranslatef(0,0,0.01);
|
|---|
| 218 | glColor3f(1.f, 0.6f, 0.f);//patchColour);//[0],patchColour[1],patchColour[2]);//0.5f, 0.5f, 0.3f);
|
|---|
| 219 | glBegin(GL_LINES);
|
|---|
| 220 | for (unsigned int j=0;j<patchesIndices[fWhitePatch].size();j++)
|
|---|
| 221 | {
|
|---|
| 222 | glVertex2fv(verticesList[patchesIndices[fWhitePatch][j].first]);
|
|---|
| 223 | glVertex2fv(verticesList[patchesIndices[fWhitePatch][j].second]);
|
|---|
| 224 | }
|
|---|
| 225 | glEnd();
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | }
|
|---|
| 229 | void QCameraWidget::Reset()
|
|---|
| 230 | {
|
|---|
| 231 | fBold.assign(1440, false);
|
|---|
| 232 | }
|
|---|
| 233 |
|
|---|
| 234 | void QCameraWidget::mousePressEvent(QMouseEvent *cEvent)
|
|---|
| 235 | {
|
|---|
| 236 | if (cEvent->pos().x() > width()-(width()/50.f))
|
|---|
| 237 | {
|
|---|
| 238 | toggleInterfaceDisplay();
|
|---|
| 239 | return;
|
|---|
| 240 | }
|
|---|
| 241 | int face = PixelAtPosition(cEvent->pos());
|
|---|
| 242 | // cout << face << endl;
|
|---|
| 243 | if (face != -1) {
|
|---|
| 244 | fWhite = face;
|
|---|
| 245 | fWhitePatch = pixelsPatch[fWhite];
|
|---|
| 246 | // CalculatePatchColor();
|
|---|
| 247 | emit signalCurrentPixel(face);
|
|---|
| 248 | }
|
|---|
| 249 | else
|
|---|
| 250 | {
|
|---|
| 251 | fWhite = -1;
|
|---|
| 252 | fWhitePatch = -1;
|
|---|
| 253 | }
|
|---|
| 254 | updateGL();
|
|---|
| 255 | }
|
|---|
| 256 | void QCameraWidget::mouseMoveEvent(QMouseEvent* cEvent)
|
|---|
| 257 | {
|
|---|
| 258 | int face = PixelAtPosition(cEvent->pos());
|
|---|
| 259 | if (face != -1 && lastFace != face) {
|
|---|
| 260 | emit signalPixelMoveOver(face);
|
|---|
| 261 | }
|
|---|
| 262 | if (lastFace != face)
|
|---|
| 263 | {
|
|---|
| 264 | if (fShowPixelMoveOver)
|
|---|
| 265 | fWhite = face;
|
|---|
| 266 |
|
|---|
| 267 | if (fShowPatchMoveOver)
|
|---|
| 268 | fWhitePatch = face != -1 ? pixelsPatch[face] : -1;
|
|---|
| 269 | }
|
|---|
| 270 |
|
|---|
| 271 | if (fShowPixelMoveOver || fShowPatchMoveOver)
|
|---|
| 272 | if (lastFace != face && isVisible())
|
|---|
| 273 | updateGL();
|
|---|
| 274 |
|
|---|
| 275 | lastFace = face;
|
|---|
| 276 | }
|
|---|
| 277 | void QCameraWidget::mouseDoubleClickEvent(QMouseEvent* cEvent)
|
|---|
| 278 | {
|
|---|
| 279 | int face = PixelAtPosition(cEvent->pos());
|
|---|
| 280 | if (face != -1) {
|
|---|
| 281 | // cout << "Event !" << endl;
|
|---|
| 282 | fWhite = face;
|
|---|
| 283 | fWhitePatch = pixelsPatch[fWhite];
|
|---|
| 284 | // highlightPixel(face);
|
|---|
| 285 | // highlightPatch(fWhitePatch);
|
|---|
| 286 | // CalculatePatchColor();
|
|---|
| 287 | emit signalPixelDoubleClick(face);
|
|---|
| 288 | }
|
|---|
| 289 | else
|
|---|
| 290 | {
|
|---|
| 291 | fWhite = -1;
|
|---|
| 292 | fWhitePatch = -1;
|
|---|
| 293 | // clearHighlightedPixels();
|
|---|
| 294 | // clearHighlightedPatches();
|
|---|
| 295 | }
|
|---|
| 296 | updateGL();
|
|---|
| 297 |
|
|---|
| 298 | }
|
|---|
| 299 | void QCameraWidget::ShowPixelCursor(bool on)
|
|---|
| 300 | {
|
|---|
| 301 | fShowPixelMoveOver = on;
|
|---|
| 302 | if (isVisible() && autoRefresh)
|
|---|
| 303 | updateGL();
|
|---|
| 304 | }
|
|---|
| 305 | void QCameraWidget::ShowPatchCursor(bool on)
|
|---|
| 306 | {
|
|---|
| 307 | fShowPatchMoveOver = on;
|
|---|
| 308 | if (isVisible() && autoRefresh)
|
|---|
| 309 | updateGL();
|
|---|
| 310 | }
|
|---|
| 311 | void QCameraWidget::SetEnable(int idx, bool b)
|
|---|
| 312 | {
|
|---|
| 313 | fEnable[idx] = b;
|
|---|
| 314 | }
|
|---|
| 315 |
|
|---|
| 316 | double QCameraWidget::GetData(int idx)
|
|---|
| 317 | {
|
|---|
| 318 | return fData[idx];
|
|---|
| 319 | }
|
|---|
| 320 | const char* QCameraWidget::GetName()
|
|---|
| 321 | {
|
|---|
| 322 | return "QCameraWidget";
|
|---|
| 323 | }
|
|---|
| 324 | char *QCameraWidget::GetObjectInfo(int px, int py)
|
|---|
| 325 | {
|
|---|
| 326 |
|
|---|
| 327 | static stringstream stream;
|
|---|
| 328 | static string str;
|
|---|
| 329 | const int pixel = this->PixelAtPosition(QPoint(px, py));
|
|---|
| 330 | if (pixel >= 0)
|
|---|
| 331 | {
|
|---|
| 332 | stream << "Pixel=" << pixel << " Data=" << fData[pixel] << '\0';
|
|---|
| 333 | }
|
|---|
| 334 | str = stream.str();
|
|---|
| 335 | return const_cast<char*>(str.c_str());
|
|---|
| 336 | }
|
|---|
| 337 | void QCameraWidget::CalculatePixelsColor()
|
|---|
| 338 | {
|
|---|
| 339 | double dmin = fData[0];
|
|---|
| 340 | double dmax = fData[0];
|
|---|
| 341 | for (int ii=0;ii<ACTUAL_NUM_PIXELS;ii++)
|
|---|
| 342 | {
|
|---|
| 343 | if (finite(fData[ii]))
|
|---|
| 344 | {
|
|---|
| 345 | dmin = dmax = fData[ii];
|
|---|
| 346 | break;
|
|---|
| 347 | }
|
|---|
| 348 | }
|
|---|
| 349 | if (fMin < fScaleLimit || fMax < fScaleLimit)
|
|---|
| 350 | {
|
|---|
| 351 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
|---|
| 352 | {
|
|---|
| 353 | if (!finite(fData[i])) continue;
|
|---|
| 354 | if (!fEnable[i]) continue;
|
|---|
| 355 | if (fData[i] > dmax) dmax = fData[i];
|
|---|
| 356 | if (fData[i] < dmin) dmin = fData[i];
|
|---|
| 357 | }
|
|---|
| 358 | }
|
|---|
| 359 | if (fMin > fScaleLimit) dmin = fMin;
|
|---|
| 360 | if (fMax > fScaleLimit) dmax = fMax;
|
|---|
| 361 | // cout << "min: " << dmin << " max: " << dmax << " fMin: " << fMin << " fMax: " << fMax << endl;
|
|---|
| 362 | float color;
|
|---|
| 363 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
|---|
| 364 | {
|
|---|
| 365 | if (!fEnable[i])
|
|---|
| 366 | {
|
|---|
| 367 | // cout << "not enabled !" << i << endl;
|
|---|
| 368 | pixelsColor[i][0] = 0.1f;
|
|---|
| 369 | pixelsColor[i][1] = 0.1f;
|
|---|
| 370 | pixelsColor[i][2] = 0.15f;
|
|---|
| 371 | continue;
|
|---|
| 372 | }
|
|---|
| 373 | if (!finite(fData[i]))
|
|---|
| 374 | {
|
|---|
| 375 | // cout << "not enabled !" << i << endl;
|
|---|
| 376 | pixelsColor[i][0] = 0.9f;
|
|---|
| 377 | pixelsColor[i][1] = 0.0f;
|
|---|
| 378 | pixelsColor[i][2] = 0.9f;
|
|---|
| 379 | continue;
|
|---|
| 380 | }
|
|---|
| 381 | if (fData[i] < dmin)
|
|---|
| 382 | {
|
|---|
| 383 | pixelsColor[i][0] = tooLowValueCoulour[0];
|
|---|
| 384 | pixelsColor[i][1] = tooLowValueCoulour[1];
|
|---|
| 385 | pixelsColor[i][2] = tooLowValueCoulour[2];
|
|---|
| 386 | continue;
|
|---|
| 387 | }
|
|---|
| 388 | if (fData[i] > dmax)
|
|---|
| 389 | {
|
|---|
| 390 | pixelsColor[i][0] = tooHighValueCoulour[0];
|
|---|
| 391 | pixelsColor[i][1] = tooHighValueCoulour[1];
|
|---|
| 392 | pixelsColor[i][2] = tooHighValueCoulour[2];
|
|---|
| 393 | continue;
|
|---|
| 394 | }
|
|---|
| 395 | color = float((fData[i]-dmin)/(dmax-dmin));
|
|---|
| 396 | if (logScale)
|
|---|
| 397 | {
|
|---|
| 398 | color *= 9;
|
|---|
| 399 | color += 1;
|
|---|
| 400 | color = log10(color);
|
|---|
| 401 | }
|
|---|
| 402 |
|
|---|
| 403 | int index = 0;
|
|---|
| 404 | while (ss[index] < color && index < 4)
|
|---|
| 405 | index++;
|
|---|
| 406 | index--;
|
|---|
| 407 | if (index < 0) index = 0;
|
|---|
| 408 | float weight0 = (color-ss[index]) / (ss[index+1]-ss[index]);
|
|---|
| 409 | if (weight0 > 1.0f) weight0 = 1.0f;
|
|---|
| 410 | if (weight0 < 0.0f) weight0 = 0.0f;
|
|---|
| 411 | float weight1 = 1.0f-weight0;
|
|---|
| 412 | pixelsColor[i][0] = weight1*rr[index] + weight0*rr[index+1];
|
|---|
| 413 | pixelsColor[i][1] = weight1*gg[index] + weight0*gg[index+1];
|
|---|
| 414 | pixelsColor[i][2] = weight1*bb[index] + weight0*bb[index+1];
|
|---|
| 415 | }
|
|---|
| 416 | CalculatePatchColor();
|
|---|
| 417 | UpdateText();
|
|---|
| 418 | pixelColorUpToDate = true;
|
|---|
| 419 | }
|
|---|
| 420 | void QCameraWidget::CalculatePatchColor()
|
|---|
| 421 | {
|
|---|
| 422 | return;
|
|---|
| 423 | //calculate the patch contour color. let's use the anti-colour of the pixels
|
|---|
| 424 | GLfloat averagePatchColour[3] = {0.0f,0.0f,0.0f};
|
|---|
| 425 | for (int i=0;i<9;i++)
|
|---|
| 426 | for (int j=0;j<3;j++)
|
|---|
| 427 | averagePatchColour[j] += pixelsColor[softwareMapping[fWhitePatch*9+i]][j];
|
|---|
| 428 | for (int j=0;j<3;j++)
|
|---|
| 429 | averagePatchColour[j] /= 9;
|
|---|
| 430 | for (int j=0;j<3;j++)
|
|---|
| 431 | patchColour[j] = 1.0f - averagePatchColour[j];
|
|---|
| 432 | }
|
|---|
| 433 | void QCameraWidget::SetData(const valarray<double> &ddata)
|
|---|
| 434 | {
|
|---|
| 435 | // fData = ddata;
|
|---|
| 436 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
|---|
| 437 | fData[i] = ddata[i];
|
|---|
| 438 | pixelColorUpToDate = false;
|
|---|
| 439 | if (isVisible() && autoRefresh)
|
|---|
| 440 | updateGL();
|
|---|
| 441 | }
|
|---|
| 442 |
|
|---|
| 443 | void QCameraWidget::SetData(const valarray<float> &ddata)
|
|---|
| 444 | {
|
|---|
| 445 | // fData = ddata;
|
|---|
| 446 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
|---|
| 447 | fData[i] = ddata[i];
|
|---|
| 448 | pixelColorUpToDate = false;
|
|---|
| 449 | if (isVisible() && autoRefresh)
|
|---|
| 450 | updateGL();
|
|---|
| 451 | }
|
|---|
| 452 |
|
|---|
| 453 |
|
|---|
| 454 | void QCameraWidget::highlightPixel(int idx, bool highlight)
|
|---|
| 455 | {
|
|---|
| 456 | if (idx < 0 || idx >= ACTUAL_NUM_PIXELS)
|
|---|
| 457 | {
|
|---|
| 458 | cout << "Error: requested pixel highlight out of bounds" << endl;
|
|---|
| 459 | return;
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | const vector<int>::iterator v = ::find(highlightedPixels.begin(), highlightedPixels.end(), idx);
|
|---|
| 463 | if (highlight)
|
|---|
| 464 | {
|
|---|
| 465 | if (v==highlightedPixels.end())
|
|---|
| 466 | highlightedPixels.push_back(idx);
|
|---|
| 467 | }
|
|---|
| 468 | else
|
|---|
| 469 | {
|
|---|
| 470 | if (v!=highlightedPixels.end())
|
|---|
| 471 | highlightedPixels.erase(v);
|
|---|
| 472 | }
|
|---|
| 473 |
|
|---|
| 474 | if (isVisible() && autoRefresh)
|
|---|
| 475 | updateGL();
|
|---|
| 476 | }
|
|---|
| 477 | void QCameraWidget::highlightPatch(int idx, bool highlight)
|
|---|
| 478 | {
|
|---|
| 479 | if (idx < 0 || idx >= NTMARK)
|
|---|
| 480 | {
|
|---|
| 481 | cout << "Error: requested patch highlight out of bounds" << endl;
|
|---|
| 482 | return;
|
|---|
| 483 | }
|
|---|
| 484 |
|
|---|
| 485 | const vector<int>::iterator v = ::find(highlightedPatches.begin(), highlightedPatches.end(), idx);
|
|---|
| 486 | if (highlight)
|
|---|
| 487 | {
|
|---|
| 488 | if (v==highlightedPatches.end())
|
|---|
| 489 | highlightedPatches.push_back(idx);
|
|---|
| 490 | }
|
|---|
| 491 | else
|
|---|
| 492 | {
|
|---|
| 493 | if (v!=highlightedPatches.end())
|
|---|
| 494 | highlightedPatches.erase(v);
|
|---|
| 495 | }
|
|---|
| 496 |
|
|---|
| 497 | if (isVisible() && autoRefresh)
|
|---|
| 498 | updateGL();
|
|---|
| 499 |
|
|---|
| 500 | }
|
|---|
| 501 | void QCameraWidget::clearHighlightedPatches()
|
|---|
| 502 | {
|
|---|
| 503 | highlightedPatches.clear();
|
|---|
| 504 | if (isVisible() && autoRefresh)
|
|---|
| 505 | updateGL();
|
|---|
| 506 | }
|
|---|
| 507 | void QCameraWidget::clearHighlightedPixels()
|
|---|
| 508 | {
|
|---|
| 509 | highlightedPixels.clear();
|
|---|
| 510 | if (isVisible() && autoRefresh)
|
|---|
| 511 | updateGL();
|
|---|
| 512 | }
|
|---|
| 513 |
|
|---|
| 514 |
|
|---|
| 515 |
|
|---|
| 516 |
|
|---|