Changeset 11901 for trunk/FACT++/gui/QCameraWidget.cc
- Timestamp:
- 08/12/11 16:23:54 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/gui/QCameraWidget.cc
r11894 r11901 5 5 QCameraWidget::QCameraWidget(QWidget *pparent) : BasicGlCamera(pparent) 6 6 { 7 fWhite = -1;8 fWhitePatch = -1;9 7 fBold.resize(1440); 10 8 fEnable.resize(1440); 11 9 fBold.assign(1440, false); 12 10 fEnable.assign(1440, true); 13 fMin = -1;14 fMax = -1;15 11 lastFace = -1; 16 unitsText = "";17 titleText = "This is a title";18 dataText = "";19 logScale = false;20 cameraRotation = 0;21 22 pixelContourColour[0] = 0.1f;23 pixelContourColour[1] = 0.1f;24 pixelContourColour[2] = 0.1f;25 patchesCoulour[0] = 0.1f;26 patchesCoulour[1] = 0.1f;27 patchesCoulour[2] = 0.1f;28 highlightedPatchesCoulour[0] = 0.6f;29 highlightedPatchesCoulour[1] = 0.6f;30 highlightedPatchesCoulour[2] = 0.6f;31 highlightedPixelsCoulour[0] = 0.8f;32 highlightedPixelsCoulour[1] = 0.8f;33 highlightedPixelsCoulour[2] = 0.8f;34 35 regularPalettePlease(true);36 12 37 13 CalculatePixelsColor(); 38 39 setFont(QFont("Arial", 8));40 int buttonShift=0;41 scaleLabel = new QLabel("Scale", this);42 // buttonShift += scaleLabel->height();43 44 linearButton = new QRadioButton("Linear", this);45 linearButton->move(scaleLabel->width(), buttonShift);46 buttonShift += linearButton->height();47 48 logButton = new QRadioButton("Log", this);49 logButton->move(scaleLabel->width(), buttonShift);50 buttonShift += logButton->height()*1.1f;51 52 colorPaletteLabel = new QLabel("Colour\nPalette", this);53 colorPaletteLabel->move(0, buttonShift);54 // buttonShift += colorPaletteLabel->height();55 56 regularPaletteButton = new QRadioButton("Regular", this);57 regularPaletteButton->move(colorPaletteLabel->width(), buttonShift);58 buttonShift += regularPaletteButton->height();59 60 prettyPaletteButton = new QRadioButton("Pretty", this);61 prettyPaletteButton->move(colorPaletteLabel->width(), buttonShift);62 buttonShift += prettyPaletteButton->height();63 64 greyScalePaletteButton = new QRadioButton("Grey Scale", this);65 greyScalePaletteButton->move(colorPaletteLabel->width(), buttonShift);66 buttonShift += greyScalePaletteButton->height();67 68 glowingPaletteButton = new QRadioButton("Glowing", this);69 glowingPaletteButton->move(colorPaletteLabel->width(), buttonShift);70 buttonShift += glowingPaletteButton->height()*1.1f;71 72 rotationLabel = new QLabel("Camera\nRotation", this);73 rotationLabel->move(0, buttonShift);74 // buttonShift += rotationLabel->height();75 76 unsigned short utf16Array;77 utf16Array = 0x00b0;78 QString degreeSymbol(QString::fromUtf16(&utf16Array, 1));79 QString zerostr("0" + degreeSymbol);80 zeroRotationButton = new QRadioButton(zerostr, this);81 zeroRotationButton->move(rotationLabel->width(), buttonShift);82 buttonShift += zeroRotationButton->height();83 QString minus90str("-90" + degreeSymbol);84 minus90RotationButton = new QRadioButton(minus90str, this);85 minus90RotationButton->move(rotationLabel->width(), buttonShift);86 buttonShift += minus90RotationButton->height();87 QString plus90str("+90"+degreeSymbol);88 plus90Rotationbutton = new QRadioButton(plus90str, this);89 plus90Rotationbutton->move(rotationLabel->width(), buttonShift);90 91 92 scaleGroup = new QButtonGroup(pparent);93 colorGroup = new QButtonGroup(pparent);94 rotationGroup = new QButtonGroup(pparent);95 scaleGroup->addButton(linearButton);96 scaleGroup->addButton(logButton);97 colorGroup->addButton(regularPaletteButton);98 colorGroup->addButton(prettyPaletteButton);99 colorGroup->addButton(greyScalePaletteButton);100 colorGroup->addButton(glowingPaletteButton);101 rotationGroup->addButton(zeroRotationButton);102 rotationGroup->addButton(minus90RotationButton);103 rotationGroup->addButton(plus90Rotationbutton);104 105 linearButton->setChecked(true);106 regularPaletteButton->setChecked(true);107 zeroRotationButton->setChecked(true);108 109 // linearButton->palette.setColor();110 111 linearButton->setAutoFillBackground(true);112 logButton->setAutoFillBackground(true);113 regularPaletteButton->setAutoFillBackground(true);114 prettyPaletteButton->setAutoFillBackground(true);115 greyScalePaletteButton->setAutoFillBackground(true);116 glowingPaletteButton->setAutoFillBackground(true);117 zeroRotationButton->setAutoFillBackground(true);118 minus90RotationButton->setAutoFillBackground(true);119 plus90Rotationbutton->setAutoFillBackground(true);120 scaleLabel->setAutoFillBackground(true);121 colorPaletteLabel->setAutoFillBackground(true);122 rotationLabel->setAutoFillBackground(true);123 124 linearButton->hide();125 logButton->hide();126 regularPaletteButton->hide();127 prettyPaletteButton->hide();128 greyScalePaletteButton->hide();129 glowingPaletteButton->hide();130 zeroRotationButton->hide();131 minus90RotationButton->hide();132 plus90Rotationbutton->hide();133 scaleLabel->hide();134 colorPaletteLabel->hide();135 rotationLabel->hide();136 137 connect(linearButton, SIGNAL(toggled(bool)),138 this, SLOT(linearScalePlease(bool)));139 connect(logButton, SIGNAL(toggled(bool)),140 this, SLOT(logScalePlease(bool)));141 connect(regularPaletteButton, SIGNAL(toggled(bool)),142 this, SLOT(regularPalettePlease(bool)));143 connect(prettyPaletteButton, SIGNAL(toggled(bool)),144 this, SLOT(prettyPalettePlease(bool)));145 connect(greyScalePaletteButton, SIGNAL(toggled(bool)),146 this, SLOT(greyScalePalettePlease(bool)));147 connect(glowingPaletteButton, SIGNAL(toggled(bool)),148 this, SLOT(glowingPalettePlease(bool)));149 connect(zeroRotationButton, SIGNAL(toggled(bool)),150 this, SLOT(zeroRotationPlease(bool)));151 connect(minus90RotationButton, SIGNAL(toggled(bool)),152 this, SLOT(plus90RotationPlease(bool)));153 connect(plus90Rotationbutton, SIGNAL(toggled(bool)),154 this, SLOT(minus90RotationPlease(bool)));155 156 157 14 158 15 } … … 262 119 fBold.assign(1440, false); 263 120 } 264 void QCameraWidget::toggleInterfaceDisplay() 265 { 266 if (linearButton->isVisible()) 267 { 268 linearButton->hide(); 269 logButton->hide(); 270 regularPaletteButton->hide(); 271 prettyPaletteButton->hide(); 272 greyScalePaletteButton->hide(); 273 glowingPaletteButton->hide(); 274 zeroRotationButton->hide(); 275 minus90RotationButton->hide(); 276 plus90Rotationbutton->hide(); 277 scaleLabel->hide(); 278 colorPaletteLabel->hide(); 279 rotationLabel->hide(); 280 } 281 else 282 { 283 linearButton->show(); 284 logButton->show(); 285 regularPaletteButton->show(); 286 prettyPaletteButton->show(); 287 greyScalePaletteButton->show(); 288 glowingPaletteButton->show(); 289 zeroRotationButton->show(); 290 minus90RotationButton->show(); 291 plus90Rotationbutton->show(); 292 scaleLabel->show(); 293 colorPaletteLabel->show(); 294 rotationLabel->show(); 295 } 296 } 297 void QCameraWidget::repaintInterface() 298 { 299 return; 300 setFont(QFont("Arial", 10)); 301 // glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 302 linearButton->render(this); 303 logButton->render(this); 304 regularPaletteButton->render(this); 305 prettyPaletteButton->render(this); 306 greyScalePaletteButton->render(this); 307 glowingPaletteButton->render(this); 308 zeroRotationButton->render(this); 309 minus90RotationButton->render(this); 310 plus90Rotationbutton->render(this); 311 // scaleLabel->repaint(); 312 colorPaletteLabel->render(this); 313 rotationLabel->render(this); 314 315 scaleLabel->render(this); 316 // cout << scaleLabel->autoFillBackground() << endl; 317 } 121 318 122 void QCameraWidget::mousePressEvent(QMouseEvent *cEvent) 319 123 { … … 368 172 } 369 173 370 void QCameraWidget::SetWhite(int idx) 371 { 372 fWhite = idx; 373 fWhitePatch = pixelsPatch[fWhite]; 374 if (isVisible()) 375 updateGL(); 376 // CalculatePatchColor(); 377 } 378 void QCameraWidget::SetEnable(int idx, bool b) 174 void QCameraWidget::SetEnable(int idx, bool b) 379 175 { 380 176 fEnable[idx] = b; … … 384 180 { 385 181 return fData[idx]; 386 }387 void QCameraWidget::SetMin(int64_t min)388 {389 // cout << "min: " << min << endl;390 fMin = min;391 pixelColorUpToDate = false;392 if (isVisible())393 updateGL();394 }395 void QCameraWidget::SetMax(int64_t max)396 {397 // cout << "max: " << max << endl;398 fMax = max;399 pixelColorUpToDate = false;400 if (isVisible())401 updateGL();402 182 } 403 183 const char* QCameraWidget::GetName() … … 506 286 updateGL(); 507 287 } 508 void QCameraWidget::UpdateText() 509 { 510 ostringstream str; 511 float min, max, mean, rms, median; 512 min = max = fData[0]; 513 mean = 0; 514 rms = 0; 515 median = 0; 516 multiset<double> medianSet; 517 for (int i=0;i<ACTUAL_NUM_PIXELS;i++) 518 { 519 if (fData[i] < min) 520 min = fData[i]; 521 if (fData[i] > max) 522 max = fData[i]; 523 mean += fData[i]; 524 rms += fData[i]*fData[i]; 525 medianSet.insert(fData[i]); 526 } 527 mean /= ACTUAL_NUM_PIXELS; 528 rms /= ACTUAL_NUM_PIXELS; 529 rms = sqrt(rms); 530 // cout << "Size of the set: " << medianSet.size() << endl; 531 multiset<double>::iterator it = medianSet.begin(); 532 for (int i=0;i<(ACTUAL_NUM_PIXELS/2)-1;i++) 533 it++; 534 median = *it; 535 it++; 536 median += *it; 537 median /= 2; 538 539 str << "Min: " << min << " Max: " << max << " Mean: " << mean << " RMS: " << rms << " Median: " << median; 540 str << " Units: " << unitsText; 541 dataText = str.str(); 542 } 543 void QCameraWidget::DrawCameraText() 544 { 545 glPushMatrix(); 546 glLoadIdentity(); 547 // cout << width() << " " << height() << endl; 548 int textSize = (int)(height()*14/600); 549 setFont(QFont("Times", textSize)); 550 qglColor(QColor(255,223,127)); 551 float shiftx = 0.01f;//0.55f; 552 float shifty = 0.01f;//0.65f; 553 renderText(-shownSizex/2.f + shiftx, -shownSizey/2.f + shifty, 0.f, QString(dataText.c_str())); 554 555 556 int textLength = titleText.size(); 557 renderText(-shownSizex/2.f + shiftx, shownSizey/2.f - textSize*pixelSize - shifty, 0.f, QString(titleText.c_str())); 558 559 glPopMatrix(); 560 } 561 void QCameraWidget::DrawScale() 562 { 563 glPushMatrix(); 564 glLoadIdentity(); 565 glPushAttrib(GL_POLYGON_BIT); 566 glShadeModel(GL_SMOOTH); 567 glBegin(GL_QUADS); 568 float oneX = shownSizex/2.f - shownSizex/50.f; 569 float twoX = shownSizex/2.f; 570 float oneY = -shownSizey/2.f; 571 float twoY = -shownSizey/4.f; 572 float threeY = 0; 573 float fourY = shownSizey/4.f; 574 float fiveY = shownSizey/2.f; 575 glColor3f(rr[0], gg[0], bb[0]); 576 glVertex2f(oneX, oneY); 577 glVertex2f(twoX, oneY); 578 glColor3f(rr[1], gg[1], bb[1]); 579 glVertex2f(twoX, twoY); 580 glVertex2f(oneX, twoY); 581 582 glVertex2f(oneX, twoY); 583 glVertex2f(twoX, twoY); 584 glColor3f(rr[2], gg[2], bb[2]); 585 glVertex2f(twoX, threeY); 586 glVertex2f(oneX, threeY); 587 588 glVertex2f(oneX, threeY); 589 glVertex2f(twoX, threeY); 590 glColor3f(rr[3], gg[3], bb[3]); 591 glVertex2f(twoX, fourY); 592 glVertex2f(oneX, fourY); 593 594 glVertex2f(oneX, fourY); 595 glVertex2f(twoX, fourY); 596 glColor3f(rr[4], gg[4], bb[4]); 597 glVertex2f(twoX, fiveY); 598 glVertex2f(oneX, fiveY); 599 float zeroX = oneX - shownSizex/50.f; 600 float zeroY = fiveY - shownSizey/50.f; 601 glColor3fv(tooHighValueCoulour); 602 glVertex2f(zeroX, fiveY); 603 glVertex2f(oneX, fiveY); 604 glVertex2f(oneX, zeroY); 605 glVertex2f(zeroX, zeroY); 606 glColor3fv(tooLowValueCoulour); 607 glVertex2f(zeroX, -fiveY); 608 glVertex2f(oneX, -fiveY); 609 glVertex2f(oneX, -zeroY); 610 glVertex2f(zeroX, -zeroY); 611 glEnd(); 612 //draw linear/log tick marks 613 glColor3f(0.f,0.f,0.f); 614 glBegin(GL_LINES); 615 float value; 616 for (int i=1;i<10;i++) 617 { 618 if (logScale) 619 value = log10(i); 620 else 621 value = (float)(i)/10.f; 622 float y = -shownSizey/2.f + value*shownSizey; 623 glVertex2f(oneX, y); 624 glVertex2f(twoX, y); 625 } 626 glEnd(); 627 glPopAttrib(); 628 glPopMatrix(); 629 } 630 void QCameraWidget::setUnits(const string& units) 631 { 632 unitsText = units; 633 pixelColorUpToDate = false; 634 if (isVisible()) 635 updateGL(); 636 } 637 void QCameraWidget::setTitle(const string& title) 638 { 639 titleText = title; 640 pixelColorUpToDate = false; 641 if (isVisible()) 642 updateGL(); 643 } 644 void QCameraWidget::linearScalePlease(bool checked) 645 { 646 if (!checked) return; 647 logScale = false; 648 pixelColorUpToDate = false; 649 if (isVisible()) 650 updateGL(); 651 } 652 void QCameraWidget::logScalePlease(bool checked) 653 { 654 if (!checked) return; 655 logScale = true; 656 pixelColorUpToDate = false; 657 if (isVisible()) 658 updateGL(); 659 } 660 void QCameraWidget::regularPalettePlease(bool checked) 661 { 662 if (!checked) return; 663 ss[0] = 0; ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f; 664 rr[0] = 0.15; rr[1] = 0; rr[2] = 0; rr[3] = 1.0f; rr[4] = 0.85f; 665 gg[0] = 0.15; gg[1] = 0; gg[2] = 1; gg[3] = 0; gg[4] = 0.85f; 666 bb[0] = 0.15; bb[1] = 1; bb[2] = 0; bb[3] = 0; bb[4] = 0.85f; 667 tooHighValueCoulour[0] = 1.f; 668 tooHighValueCoulour[1] = 1.f; 669 tooHighValueCoulour[2] = 0.f; 670 tooLowValueCoulour[0] = 0.f; 671 tooLowValueCoulour[1] = 1.f; 672 tooLowValueCoulour[2] = 1.f; 673 pixelColorUpToDate = false; 674 if (isVisible()) 675 updateGL(); 676 } 677 void QCameraWidget::prettyPalettePlease(bool checked) 678 { 679 if (!checked) return; 680 ss[0] = 0.f; ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f; 681 rr[0] = 0.f; rr[1] = 0.35f; rr[2] = 0.85f; rr[3] = 1.0f; rr[4] = 1.f; 682 gg[0] = 0.f; gg[1] = 0.10f; gg[2] = 0.20f; gg[3] = 0.73f; gg[4] = 1.f; 683 bb[0] = 0.f; bb[1] = 0.03f; bb[2] = 0.06f; bb[3] = 0.00f; bb[4] = 1.f; 684 tooHighValueCoulour[0] = 0.f; 685 tooHighValueCoulour[1] = 1.f; 686 tooHighValueCoulour[2] = 0.f; 687 tooLowValueCoulour[0] = 0.f; 688 tooLowValueCoulour[1] = 0.f; 689 tooLowValueCoulour[2] = 1.f; 690 pixelColorUpToDate = false; 691 if (isVisible()) 692 updateGL(); 693 } 694 void QCameraWidget::greyScalePalettePlease(bool checked) 695 { 696 if (!checked) return; 697 ss[0] = 0; ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f; 698 rr[0] = 0; rr[1] = 0.25f; rr[2] = 0.5f; rr[3] = 0.75f; rr[4] = 1.0f; 699 gg[0] = 0; gg[1] = 0.25f; gg[2] = 0.5f; gg[3] = 0.75f; gg[4] = 1.0f; 700 bb[0] = 0; bb[1] = 0.25f; bb[2] = 0.5f; bb[3] = 0.75f; bb[4] = 1.0f; 701 tooHighValueCoulour[0] = 0.f; 702 tooHighValueCoulour[1] = 1.f; 703 tooHighValueCoulour[2] = 0.f; 704 tooLowValueCoulour[0] = 0.f; 705 tooLowValueCoulour[1] = 0.f; 706 tooLowValueCoulour[2] = 1.f; 707 pixelColorUpToDate = false; 708 if (isVisible()) 709 updateGL(); 710 } 711 void QCameraWidget::glowingPalettePlease(bool checked) 712 { 713 if (!checked) return; 714 ss[0] = 0; ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f; 715 rr[0] = 0.15; rr[1] = 0.5; rr[2] = 1.f; rr[3] = 0.0f; rr[4] = 1.f; 716 gg[0] = 0.15; gg[1] = 0.5; gg[2] = 1.f; gg[3] = 0.5f; gg[4] = 0.5f; 717 bb[0] = 0.15; bb[1] = 0.5; bb[2] = 1; bb[3] = 1.f; bb[4] = 0.f; 718 tooHighValueCoulour[0] = 1.f; 719 tooHighValueCoulour[1] = 0.f; 720 tooHighValueCoulour[2] = 0.f; 721 tooLowValueCoulour[0] = 0.f; 722 tooLowValueCoulour[1] = 1.f; 723 tooLowValueCoulour[2] = 0.f; 724 pixelColorUpToDate = false; 725 if (isVisible()) 726 updateGL(); 727 } 728 void QCameraWidget::zeroRotationPlease(bool checked) 729 { 730 if (!checked) return; 731 cameraRotation = 0; 732 pixelColorUpToDate = false; 733 if (isVisible()) 734 updateGL(); 735 } 736 void QCameraWidget::plus90RotationPlease(bool checked) 737 { 738 if (!checked) return; 739 cameraRotation = 90; 740 pixelColorUpToDate = false; 741 if (isVisible()) 742 updateGL(); 743 } 744 void QCameraWidget::minus90RotationPlease(bool checked) 745 { 746 if (!checked) return; 747 cameraRotation = -90; 748 pixelColorUpToDate = false; 749 if (isVisible()) 750 updateGL(); 751 } 288 289 752 290 void QCameraWidget::highlightPixel(int idx) 753 291 {
Note:
See TracChangeset
for help on using the changeset viewer.