| 283 | } |
| 284 | |
| 285 | void chart2d_impl::generateChartData() |
| 286 | { |
| 287 | CheckGL("Begin chart2d_impl::generateChartData"); |
| 288 | static const float border[8] = { -1, -1, 1, -1, 1, 1, -1, 1 }; |
| 289 | static const int nValues = sizeof(border)/sizeof(float); |
| 290 | |
| 291 | std::vector<float> decorData; |
| 292 | std::copy(border, border+nValues, std::back_inserter(decorData)); |
| 293 | |
| 294 | float step = getTickStepSize(-1, 1); |
| 295 | int ticksLeft = getNumTicksC2E(); |
| 296 | |
| 297 | /* push tick points for y axis: |
| 298 | * push (0) first followed by |
| 299 | * [-1, 0) ticks and then |
| 300 | * (0, 1] ticks */ |
| 301 | pushPoint(decorData, -1.0f, 0.0f); |
| 302 | pushTicktextCoords(-1.0f, 0.0f); |
| 303 | mYText.push_back(toString(0, mYLabelFormat)); |
| 304 | |
| 305 | for(int i=1; i<=ticksLeft; ++i) { |
| 306 | /* [-1, 0) to [-1, -1] */ |
| 307 | float neg = i*-step; |
| 308 | pushPoint(decorData, -1.0f, neg); |
| 309 | /* puch tick marks */ |
| 310 | pushTicktextCoords(-1.0f, neg); |
| 311 | /* push tick text label */ |
| 312 | mYText.push_back(toString(neg, mYLabelFormat)); |
| 313 | |
| 314 | /* [-1, 0) to [-1, 1] */ |
| 315 | float pos = i*step; |
| 316 | pushPoint(decorData, -1.0f, pos); |
| 317 | /* puch tick marks */ |
| 318 | pushTicktextCoords(-1.0f, pos); |
| 319 | /* push tick text label */ |
| 320 | mYText.push_back(toString(pos, mYLabelFormat)); |
| 321 | } |
| 322 | |
| 323 | /* push tick points for x axis: |
| 324 | * push (0,0) first followed by |
| 325 | * [-1, 0) ticks and then |
| 326 | * (0, 1] ticks */ |
| 327 | pushPoint(decorData, 0.0f, -1.0f); |
| 328 | pushTicktextCoords(0.0f, -1.0f); |
| 329 | mXText.push_back(toString(0, mXLabelFormat)); |
| 330 | |
| 331 | for(int i=1; i<=ticksLeft; ++i) { |
| 332 | /* (0, -1] to [-1, -1] */ |
| 333 | float neg = i*-step; |
| 334 | pushPoint(decorData, neg, -1.0f); |
| 335 | pushTicktextCoords(neg, -1.0f); |
| 336 | mXText.push_back(toString(neg, mXLabelFormat)); |
| 337 | |
| 338 | /* (0, -1] to [1, -1] */ |
| 339 | float pos = i*step; |
| 340 | pushPoint(decorData, pos, -1.0f); |
| 341 | pushTicktextCoords(pos, -1.0f); |
| 342 | mXText.push_back(toString(pos, mXLabelFormat)); |