FACT++  1.0
void QCameraWidget::DrawCameraText ( )
virtual

Reimplemented from BasicGlCamera.

Definition at line 93 of file QCameraWidget.cc.

References BasicGlCamera::fMax, BasicGlCamera::fmax, BasicGlCamera::fmean, BasicGlCamera::fmedian, BasicGlCamera::fMin, BasicGlCamera::fmin, BasicGlCamera::frms, BasicGlCamera::fScaleLimit, BasicGlCamera::fTextEnabled, BasicGlCamera::fTextSize, height, i, BasicGlCamera::logScale, BasicGlCamera::pixelSize, BasicGlCamera::shownSizex, BasicGlCamera::shownSizey, str, BasicGlCamera::titleText, and BasicGlCamera::unitsText.

Referenced by paintGL().

94  {
95  if (!fTextEnabled) return;
96 
97  glPushMatrix();
98  glLoadIdentity();
99 
100 
101 
102 // int textSize = (int)(width()*14/600);
103 // setFont(QFont("Monospace", textSize));
104  qglColor(QColor(25, 22, 12));
105 
106  //first let's draw the usual data
107  //title
108  renderText(-shownSizex/2.f + 0.01f, shownSizey/2.f - fTextSize*pixelSize - 0.01f, 0.f, QString(titleText.c_str()));
109  //stats
110  ostringstream str;
111  str.precision(2);
112  str.setf(ios::fixed,ios::floatfield);
113  str << "Med " << fmedian;// << unitsText;
114  renderText(3, height()-3-4*fTextSize-35, QString(str.str().c_str()));
115  str.str("");
116  str << "Avg " << fmean;// << unitsText;
117  renderText(3, height()-3-3*fTextSize-27, QString(str.str().c_str()));
118  str.str("");
119  str << "RMS " << frms;// << unitsText;
120  renderText(3, height()-3-2*fTextSize-21, QString(str.str().c_str()));
121  str.str("");
122  str << "Min " << fmin;// << unitsText;
123  renderText(3, height()-3-3, QString(str.str().c_str()));
124  str.str("");
125  str << "Max " << fmax;// << unitsText;
126  renderText(3, height()-3-1*fTextSize-8, QString(str.str().c_str()));
127  //then draw the values beside the scale
128  //the difficulty here is to write the correct min/max besides the scale
129  //it depends whether the actual mean of the data is given by the user
130  //or not. the values given by user are fMin and fMax, while the data
131  //real min/max are fmin and fmax (I know, quite confusing... sorry about that)
132  //so. first let's see what is the span of one pixel
133  float min = (fMin < fScaleLimit || fMax < fScaleLimit) ? fmin : fMin;
134  float max = (fMin < fScaleLimit || fMax < fScaleLimit) ? fmax : fMax;
135 // textSize = (int)(height()*12/600);
136  // setFont(QFont("Monospace", textSize));
137  float pixelSpan = (height() - fTextSize - 1)/(max - min);
138 
139  //draw the scale values
140  float value = min;
141  int fontWidth = fTextSize;
142  if (fTextSize > 12) fontWidth--;
143  if (fTextSize > 10) fontWidth--;
144  if (fTextSize > 7) fontWidth--;//else fontWidth -=1;
145 // if (fTextSize < 7) fontWidth++;
146  for (int i=0;i<11;i++)
147  {
148  str.str("");
149  str << value;
150  if (i==0 || i==10)
151  str << ' ' << unitsText;
152  str << ' ';
153  int h = (value - min)*pixelSpan;
154  if (logScale && h != 0)
155  {
156  float fh = h;
157  float mult = (max - min)*pixelSpan;
158  fh = log10(h*10.f/mult);
159  fh *= mult;
160  h = (int)fh;
161  }
162  h = height()-h;
163  int w = width() - (width()/50) - fontWidth*str.str().size();
164  if (i==0 || i==10) w -= width()/50;
165  if (i!=0 && i!=10) h -= fTextSize/2;
166  renderText(w, h, QString(str.str().c_str()));
167  value += (max - min)/10;
168  }
169 
170 /*
171  str.str("");
172  str << min << unitsText;
173  int fontWidth = textSize;
174  if (textSize > 12) fontWidth-=3; else fontWidth -= 2;
175  //height of min ?
176  int hmin = (min - min)*pixelSpan;
177  hmin = height() - hmin;
178  renderText(width() - (width()/25) - fontWidth*str.str().size(), hmin, QString(str.str().c_str()));
179  str.str("");
180  str << max << unitsText;
181  int hmax = (max - min)*pixelSpan;
182  hmax = height() - hmax;
183  renderText(width() - (width()/25) - fontWidth*str.str().size(), hmax, QString(str.str().c_str()));
184 */
185  glPopMatrix();
186 
187 // textSize = (int)(600*14/600);
188 // setFont(QFont("Times", textSize));
189  }
int i
Definition: db_dim_client.c:21
char str[80]
Definition: test_client.c:7
std::string titleText
Definition: BasicGlCamera.h:75
float height
Definition: HeadersGPS.h:26
std::string unitsText
Definition: BasicGlCamera.h:74

+ Here is the caller graph for this function: