Changeset 11985 for trunk/FACT++/gui/QCameraWidget.cc
- Timestamp:
- 09/06/11 17:13:56 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/gui/QCameraWidget.cc
r11944 r11985 21 21 22 22 glTranslatef(0,-0.44,0); 23 glTranslatef(-0.1,0,0); 23 24 glRotatef(cameraRotation, 0,0,-1); 24 25 if (cameraRotation == 90) … … 33 34 glScalef(1.5, 1.5, 1.5); 34 35 drawCamera(true); 36 37 drawPatches(); 35 38 36 39 glLineWidth(1.0f); … … 40 43 drawHexagon(*it, false); 41 44 } 42 drawPatches();43 45 44 46 glLineWidth(1.0f); … … 59 61 void QCameraWidget::drawCamera(bool alsoWire) 60 62 { 63 61 64 if (!pixelColorUpToDate) 62 65 CalculatePixelsColor(); … … 76 79 } 77 80 } 81 void QCameraWidget::DrawCameraText() 82 { 83 glPushMatrix(); 84 glLoadIdentity(); 85 86 87 88 int textSize = (int)(height()*14/600); 89 setFont(QFont("Monospace", textSize)); 90 qglColor(QColor(255, 223, 127)); 91 92 //first let's draw the usual data 93 //title 94 renderText(-shownSizex/2.f + 0.01f, shownSizey/2.f - textSize*pixelSize - 0.01f, 0.f, QString(titleText.c_str())); 95 //stats 96 ostringstream str; 97 str.precision(2); 98 str.setf(ios::fixed,ios::floatfield); 99 str << "Med. " << fmedian << unitsText; 100 renderText(1, height()-4*textSize-10, QString(str.str().c_str())); 101 str.str(""); 102 str << "Mea. " << fmean << unitsText; 103 renderText(1, height()-3*textSize-8, QString(str.str().c_str())); 104 str.str(""); 105 str << "Rms " << frms << unitsText; 106 renderText(1, height()-2*textSize-6, QString(str.str().c_str())); 107 str.str(""); 108 str << "Min. " << fmin << unitsText; 109 renderText(1, height()-1*textSize-4, QString(str.str().c_str())); 110 str.str(""); 111 str << "Max. " << fmax << unitsText; 112 renderText(1, height()-2, QString(str.str().c_str())); 113 //then draw the values beside the scale 114 //the difficulty here is to write the correct min/max besides the scale 115 //it depends whether the actual mean of the data is given by the user 116 //or not. the values given by user are fMin and fMax, while the data 117 //real min/max are fmin and fmax (I know, quite confusing... sorry about that) 118 //so. first let's see what is the span of one pixel 119 float min = (fMin < 0) ? fmin : fMin; 120 float max = (fMax < 0) ? fmax : fMax; 121 textSize = (int)(height()*12/600); 122 setFont(QFont("Monospace", textSize)); 123 float pixelSpan = (height() - textSize - 1)/(max - min); 124 125 //draw the scale values 126 float value = min; 127 int fontWidth = textSize; 128 if (textSize > 12) fontWidth-=3; else fontWidth -=2; 129 if (textSize < 7) fontWidth++; 130 for (int i=0;i<6;i++) 131 { 132 str.str(""); 133 str << value << unitsText; 134 int h = (value - min)*pixelSpan; 135 if (logScale && h != 0) 136 { 137 float fh = h; 138 float mult = (max - min)*pixelSpan; 139 fh = log10(h*10.f/mult); 140 fh *= mult; 141 h = (int)fh; 142 } 143 h = height()-h; 144 int w = width() - (width()/50) - fontWidth*str.str().size(); 145 if (i==0 || i==5) w -= width()/50; 146 if (i!=0 && i!=5) h -= textSize/2; 147 renderText(w, h, QString(str.str().c_str())); 148 value += (max - min)/5; 149 } 150 151 /* 152 str.str(""); 153 str << min << unitsText; 154 int fontWidth = textSize; 155 if (textSize > 12) fontWidth-=3; else fontWidth -= 2; 156 //height of min ? 157 int hmin = (min - min)*pixelSpan; 158 hmin = height() - hmin; 159 renderText(width() - (width()/25) - fontWidth*str.str().size(), hmin, QString(str.str().c_str())); 160 str.str(""); 161 str << max << unitsText; 162 int hmax = (max - min)*pixelSpan; 163 hmax = height() - hmax; 164 renderText(width() - (width()/25) - fontWidth*str.str().size(), hmax, QString(str.str().c_str())); 165 */ 166 glPopMatrix(); 167 168 textSize = (int)(600*14/600); 169 setFont(QFont("Times", textSize)); 170 } 78 171 void QCameraWidget::drawPatches() 79 172 { 80 glLineWidth( 2.0f);173 glLineWidth(3.0f); 81 174 glColor3fv(patchesCoulour); 82 175 glBegin(GL_LINES);
Note:
See TracChangeset
for help on using the changeset viewer.