1 | #include "BasicGlCamera.h"
|
---|
2 | #include <math.h>
|
---|
3 | #include <fstream>
|
---|
4 | #include <iostream>
|
---|
5 | #include <string>
|
---|
6 | #include <sstream>
|
---|
7 | #include "src/tools.h"
|
---|
8 |
|
---|
9 | //Coordinates of an hexagon of radius 1 and center 0
|
---|
10 | GLfloat hexcoords[6][2] = {{-1./sqrt(3.), 1},
|
---|
11 | { 1./sqrt(3.), 1},
|
---|
12 | { 2./sqrt(3.), 0},
|
---|
13 | { 1./sqrt(3.), -1},
|
---|
14 | {-1./sqrt(3.), -1},
|
---|
15 | {-2./sqrt(3.), 0}};
|
---|
16 |
|
---|
17 |
|
---|
18 |
|
---|
19 | BasicGlCamera::BasicGlCamera(QWidget* cParent) : QGLWidget(cParent)
|
---|
20 | {
|
---|
21 | setFormat(QGLFormat(QGL::DoubleBuffer));// | QGL::DepthBuffer));
|
---|
22 | fWhite = -1;
|
---|
23 | fWhitePatch = -1;
|
---|
24 | fMin = -1;
|
---|
25 | fMax = -1;
|
---|
26 | logScale = false;
|
---|
27 | cameraRotation = 0;
|
---|
28 | unitsText = "";
|
---|
29 | titleText = "";
|
---|
30 | dataText = "";
|
---|
31 | pixelContourColour[0] = 0.1f;
|
---|
32 | pixelContourColour[1] = 0.1f;
|
---|
33 | pixelContourColour[2] = 0.1f;
|
---|
34 | patchesCoulour[0] = 0.1f;
|
---|
35 | patchesCoulour[1] = 0.1f;
|
---|
36 | patchesCoulour[2] = 0.1f;
|
---|
37 | highlightedPatchesCoulour[0] = 0.6f;
|
---|
38 | highlightedPatchesCoulour[1] = 0.6f;
|
---|
39 | highlightedPatchesCoulour[2] = 0.6f;
|
---|
40 | highlightedPixelsCoulour[0] = 0.8f;
|
---|
41 | highlightedPixelsCoulour[1] = 0.8f;
|
---|
42 | highlightedPixelsCoulour[2] = 0.8f;
|
---|
43 |
|
---|
44 | regularPalettePlease(true);
|
---|
45 |
|
---|
46 |
|
---|
47 | hexRadius = 0.015f;
|
---|
48 | hexTolerance = hexRadius/100.0f;
|
---|
49 | viewSize = 1.0f;
|
---|
50 | calculatePixelsCoords();
|
---|
51 |
|
---|
52 | ifstream fin2("MasterList-v3.txt");
|
---|
53 | if (!fin2.is_open())
|
---|
54 | {
|
---|
55 | cout << "Error: file \"MasterList-v3\" missing. aborting." << endl;
|
---|
56 | exit(-1);
|
---|
57 | }
|
---|
58 | int l = 0;
|
---|
59 | string buf;
|
---|
60 | while (getline(fin2, buf, '\n'))
|
---|
61 | {
|
---|
62 | buf = Tools::Trim(buf);
|
---|
63 | if (buf[0]=='#')
|
---|
64 | continue;
|
---|
65 |
|
---|
66 | unsigned int softid, hardid, dummy;
|
---|
67 |
|
---|
68 | stringstream str(buf);
|
---|
69 |
|
---|
70 | str >> softid;
|
---|
71 | str >> dummy;
|
---|
72 | str >> hardid;
|
---|
73 |
|
---|
74 | if (softid>=1440)
|
---|
75 | continue;
|
---|
76 |
|
---|
77 | hardwareMapping[softid] = hardid;
|
---|
78 | softwareMapping[hardid] = softid;
|
---|
79 |
|
---|
80 | l++;
|
---|
81 | }
|
---|
82 | // GLfloat tempPixelsCoords[MAX_NUM_PIXELS][3];
|
---|
83 | // for (int i=0;i<1440;i++)
|
---|
84 | // for (int j=0;j<3;j++)
|
---|
85 | // tempPixelsCoords[hardwareMapping[i]][j] = pixelsCoords[i][j];
|
---|
86 | // for (int i=0;i<1440;i++)
|
---|
87 | // for (int j=0;j<3;j++)
|
---|
88 | // pixelsCoords[i][j] = tempPixelsCoords[i][j];
|
---|
89 | buildVerticesList();
|
---|
90 | ifstream fin1("Trigger-Patches.txt");
|
---|
91 | if (!fin1.is_open())
|
---|
92 | {
|
---|
93 | cout << "Error: file \"Trigger-Patches.txt\" missing. Aborting." << endl;
|
---|
94 | exit(-1);
|
---|
95 | }
|
---|
96 | l=0;
|
---|
97 | while (getline(fin1, buf, '\n'))
|
---|
98 | {
|
---|
99 | buf = Tools::Trim(buf);
|
---|
100 | if (buf[0]=='#')
|
---|
101 | continue;
|
---|
102 |
|
---|
103 | stringstream str(buf);
|
---|
104 | for (int i=0; i<9; i++)
|
---|
105 | {
|
---|
106 | unsigned int n;
|
---|
107 | str >> n;
|
---|
108 |
|
---|
109 | if (n>=1440)
|
---|
110 | continue;
|
---|
111 |
|
---|
112 | patches[l][i] = hardwareMapping[n];
|
---|
113 | }
|
---|
114 | l++;
|
---|
115 | }
|
---|
116 |
|
---|
117 | //now construct the correspondance between pixels and patches
|
---|
118 | for (int i=0;i<NTMARK;i++)
|
---|
119 | for (int j=0;j<9;j++)
|
---|
120 | pixelsPatch[softwareMapping[patches[i][j]]] = i;
|
---|
121 |
|
---|
122 | for (int i=0;i<1440;i++)
|
---|
123 | updateNeighbors(i);
|
---|
124 |
|
---|
125 | buildPatchesIndices();
|
---|
126 |
|
---|
127 | ss[0] = 0; ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f;
|
---|
128 | rr[0] = 0.15; rr[1] = 0; rr[2] = 0; rr[3] = 1.0f; rr[4] = 0.85f;
|
---|
129 | gg[0] = 0.15; gg[1] = 0; gg[2] = 1; gg[3] = 0; gg[4] = 0.85f;
|
---|
130 | bb[0] = 0.15; bb[1] = 1; bb[2] = 0; bb[3] = 0; bb[4] = 0.85f;
|
---|
131 |
|
---|
132 | fPixelStride = 1;
|
---|
133 | fcSlice = 0;
|
---|
134 | fData.resize(1440);
|
---|
135 | for (int i=0;i<NPIX;i++)
|
---|
136 | fData[i] = (double)i;///1.44;//(double)(i)/(double)(ACTUAL_NUM_PIXELS);
|
---|
137 |
|
---|
138 |
|
---|
139 | setFont(QFont("Arial", 8));
|
---|
140 | int buttonShift=0;
|
---|
141 | scaleLabel = new QLabel("Scale", this);
|
---|
142 | // buttonShift += scaleLabel->height();
|
---|
143 |
|
---|
144 | linearButton = new QRadioButton("Linear", this);
|
---|
145 | linearButton->move(scaleLabel->width(), buttonShift);
|
---|
146 | buttonShift += linearButton->height();
|
---|
147 |
|
---|
148 | logButton = new QRadioButton("Log", this);
|
---|
149 | logButton->move(scaleLabel->width(), buttonShift);
|
---|
150 | buttonShift += logButton->height()*1.1f;
|
---|
151 |
|
---|
152 | colorPaletteLabel = new QLabel("Colour\nPalette", this);
|
---|
153 | colorPaletteLabel->move(0, buttonShift);
|
---|
154 | // buttonShift += colorPaletteLabel->height();
|
---|
155 |
|
---|
156 | regularPaletteButton = new QRadioButton("Regular", this);
|
---|
157 | regularPaletteButton->move(colorPaletteLabel->width(), buttonShift);
|
---|
158 | buttonShift += regularPaletteButton->height();
|
---|
159 |
|
---|
160 | prettyPaletteButton = new QRadioButton("Pretty", this);
|
---|
161 | prettyPaletteButton->move(colorPaletteLabel->width(), buttonShift);
|
---|
162 | buttonShift += prettyPaletteButton->height();
|
---|
163 |
|
---|
164 | greyScalePaletteButton = new QRadioButton("Grey Scale", this);
|
---|
165 | greyScalePaletteButton->move(colorPaletteLabel->width(), buttonShift);
|
---|
166 | buttonShift += greyScalePaletteButton->height();
|
---|
167 |
|
---|
168 | glowingPaletteButton = new QRadioButton("Glowing", this);
|
---|
169 | glowingPaletteButton->move(colorPaletteLabel->width(), buttonShift);
|
---|
170 | buttonShift += glowingPaletteButton->height()*1.1f;
|
---|
171 |
|
---|
172 | rotationLabel = new QLabel("Camera\nRotation", this);
|
---|
173 | rotationLabel->move(0, buttonShift);
|
---|
174 | // buttonShift += rotationLabel->height();
|
---|
175 |
|
---|
176 | unsigned short utf16Array;
|
---|
177 | utf16Array = 0x00b0;
|
---|
178 | QString degreeSymbol(QString::fromUtf16(&utf16Array, 1));
|
---|
179 | QString zerostr("0" + degreeSymbol);
|
---|
180 | zeroRotationButton = new QRadioButton(zerostr, this);
|
---|
181 | zeroRotationButton->move(rotationLabel->width(), buttonShift);
|
---|
182 | buttonShift += zeroRotationButton->height();
|
---|
183 | QString minus90str("-90" + degreeSymbol);
|
---|
184 | minus90RotationButton = new QRadioButton(minus90str, this);
|
---|
185 | minus90RotationButton->move(rotationLabel->width(), buttonShift);
|
---|
186 | buttonShift += minus90RotationButton->height();
|
---|
187 | QString plus90str("+90"+degreeSymbol);
|
---|
188 | plus90Rotationbutton = new QRadioButton(plus90str, this);
|
---|
189 | plus90Rotationbutton->move(rotationLabel->width(), buttonShift);
|
---|
190 |
|
---|
191 |
|
---|
192 | scaleGroup = new QButtonGroup(this);
|
---|
193 | colorGroup = new QButtonGroup(this);
|
---|
194 | rotationGroup = new QButtonGroup(this);
|
---|
195 | scaleGroup->addButton(linearButton);
|
---|
196 | scaleGroup->addButton(logButton);
|
---|
197 | colorGroup->addButton(regularPaletteButton);
|
---|
198 | colorGroup->addButton(prettyPaletteButton);
|
---|
199 | colorGroup->addButton(greyScalePaletteButton);
|
---|
200 | colorGroup->addButton(glowingPaletteButton);
|
---|
201 | rotationGroup->addButton(zeroRotationButton);
|
---|
202 | rotationGroup->addButton(minus90RotationButton);
|
---|
203 | rotationGroup->addButton(plus90Rotationbutton);
|
---|
204 |
|
---|
205 | linearButton->setChecked(true);
|
---|
206 | regularPaletteButton->setChecked(true);
|
---|
207 | zeroRotationButton->setChecked(true);
|
---|
208 |
|
---|
209 | // linearButton->palette.setColor();
|
---|
210 |
|
---|
211 | linearButton->setAutoFillBackground(true);
|
---|
212 | logButton->setAutoFillBackground(true);
|
---|
213 | regularPaletteButton->setAutoFillBackground(true);
|
---|
214 | prettyPaletteButton->setAutoFillBackground(true);
|
---|
215 | greyScalePaletteButton->setAutoFillBackground(true);
|
---|
216 | glowingPaletteButton->setAutoFillBackground(true);
|
---|
217 | zeroRotationButton->setAutoFillBackground(true);
|
---|
218 | minus90RotationButton->setAutoFillBackground(true);
|
---|
219 | plus90Rotationbutton->setAutoFillBackground(true);
|
---|
220 | scaleLabel->setAutoFillBackground(true);
|
---|
221 | colorPaletteLabel->setAutoFillBackground(true);
|
---|
222 | rotationLabel->setAutoFillBackground(true);
|
---|
223 |
|
---|
224 | linearButton->hide();
|
---|
225 | logButton->hide();
|
---|
226 | regularPaletteButton->hide();
|
---|
227 | prettyPaletteButton->hide();
|
---|
228 | greyScalePaletteButton->hide();
|
---|
229 | glowingPaletteButton->hide();
|
---|
230 | zeroRotationButton->hide();
|
---|
231 | minus90RotationButton->hide();
|
---|
232 | plus90Rotationbutton->hide();
|
---|
233 | scaleLabel->hide();
|
---|
234 | colorPaletteLabel->hide();
|
---|
235 | rotationLabel->hide();
|
---|
236 |
|
---|
237 | connect(linearButton, SIGNAL(toggled(bool)),
|
---|
238 | this, SLOT(linearScalePlease(bool)));
|
---|
239 | connect(logButton, SIGNAL(toggled(bool)),
|
---|
240 | this, SLOT(logScalePlease(bool)));
|
---|
241 | connect(regularPaletteButton, SIGNAL(toggled(bool)),
|
---|
242 | this, SLOT(regularPalettePlease(bool)));
|
---|
243 | connect(prettyPaletteButton, SIGNAL(toggled(bool)),
|
---|
244 | this, SLOT(prettyPalettePlease(bool)));
|
---|
245 | connect(greyScalePaletteButton, SIGNAL(toggled(bool)),
|
---|
246 | this, SLOT(greyScalePalettePlease(bool)));
|
---|
247 | connect(glowingPaletteButton, SIGNAL(toggled(bool)),
|
---|
248 | this, SLOT(glowingPalettePlease(bool)));
|
---|
249 | connect(zeroRotationButton, SIGNAL(toggled(bool)),
|
---|
250 | this, SLOT(zeroRotationPlease(bool)));
|
---|
251 | connect(minus90RotationButton, SIGNAL(toggled(bool)),
|
---|
252 | this, SLOT(plus90RotationPlease(bool)));
|
---|
253 | connect(plus90Rotationbutton, SIGNAL(toggled(bool)),
|
---|
254 | this, SLOT(minus90RotationPlease(bool)));
|
---|
255 |
|
---|
256 |
|
---|
257 |
|
---|
258 | }
|
---|
259 | BasicGlCamera::~BasicGlCamera()
|
---|
260 | {
|
---|
261 | }
|
---|
262 | void BasicGlCamera::setUnits(const string& units)
|
---|
263 | {
|
---|
264 | unitsText = units;
|
---|
265 | pixelColorUpToDate = false;
|
---|
266 | if (isVisible())
|
---|
267 | updateGL();
|
---|
268 | }
|
---|
269 | void BasicGlCamera::setTitle(const string& title)
|
---|
270 | {
|
---|
271 | titleText = title;
|
---|
272 | pixelColorUpToDate = false;
|
---|
273 | if (isVisible())
|
---|
274 | updateGL();
|
---|
275 | }
|
---|
276 | void BasicGlCamera::SetWhite(int idx)
|
---|
277 | {
|
---|
278 | fWhite = idx;
|
---|
279 | fWhitePatch = pixelsPatch[fWhite];
|
---|
280 | if (isVisible())
|
---|
281 | updateGL();
|
---|
282 | // CalculatePatchColor();
|
---|
283 | }
|
---|
284 | void BasicGlCamera::SetMin(int64_t min)
|
---|
285 | {
|
---|
286 | // cout << "min: " << min << endl;
|
---|
287 | fMin = min;
|
---|
288 | pixelColorUpToDate = false;
|
---|
289 | if (isVisible())
|
---|
290 | updateGL();
|
---|
291 | }
|
---|
292 | void BasicGlCamera::SetMax(int64_t max)
|
---|
293 | {
|
---|
294 | // cout << "max: " << max << endl;
|
---|
295 | fMax = max;
|
---|
296 | pixelColorUpToDate = false;
|
---|
297 | if (isVisible())
|
---|
298 | updateGL();
|
---|
299 | }
|
---|
300 | void BasicGlCamera::linearScalePlease(bool checked)
|
---|
301 | {
|
---|
302 | if (!checked) return;
|
---|
303 | logScale = false;
|
---|
304 | pixelColorUpToDate = false;
|
---|
305 | emit colorPaletteHasChanged();
|
---|
306 | if (isVisible())
|
---|
307 | updateGL();
|
---|
308 | }
|
---|
309 | void BasicGlCamera::UpdateText()
|
---|
310 | {
|
---|
311 | ostringstream str;
|
---|
312 | float min, max, mean, rms, median;
|
---|
313 | min = max = fData[0];
|
---|
314 | mean = 0;
|
---|
315 | rms = 0;
|
---|
316 | median = 0;
|
---|
317 | multiset<double> medianSet;
|
---|
318 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
319 | {
|
---|
320 | if (fData[i] < min)
|
---|
321 | min = fData[i];
|
---|
322 | if (fData[i] > max)
|
---|
323 | max = fData[i];
|
---|
324 | mean += fData[i];
|
---|
325 | rms += fData[i]*fData[i];
|
---|
326 | medianSet.insert(fData[i]);
|
---|
327 | }
|
---|
328 | mean /= ACTUAL_NUM_PIXELS;
|
---|
329 | rms /= ACTUAL_NUM_PIXELS;
|
---|
330 | rms = sqrt(rms);
|
---|
331 | // cout << "Size of the set: " << medianSet.size() << endl;
|
---|
332 | multiset<double>::iterator it = medianSet.begin();
|
---|
333 | for (int i=0;i<(ACTUAL_NUM_PIXELS/2)-1;i++)
|
---|
334 | it++;
|
---|
335 | median = *it;
|
---|
336 | it++;
|
---|
337 | median += *it;
|
---|
338 | median /= 2;
|
---|
339 |
|
---|
340 | str << "Min: " << min << " Max: " << max << " Mean: " << mean << " RMS: " << rms << " Median: " << median;
|
---|
341 | str << " Units: " << unitsText;
|
---|
342 | dataText = str.str();
|
---|
343 | }
|
---|
344 | void BasicGlCamera::DrawCameraText()
|
---|
345 | {
|
---|
346 | glPushMatrix();
|
---|
347 | glLoadIdentity();
|
---|
348 | // cout << width() << " " << height() << endl;
|
---|
349 | int textSize = (int)(height()*14/600);
|
---|
350 | setFont(QFont("Times", textSize));
|
---|
351 | qglColor(QColor(255,223,127));
|
---|
352 | float shiftx = 0.01f;//0.55f;
|
---|
353 | float shifty = 0.01f;//0.65f;
|
---|
354 | renderText(-shownSizex/2.f + shiftx, -shownSizey/2.f + shifty, 0.f, QString(dataText.c_str()));
|
---|
355 |
|
---|
356 |
|
---|
357 | int textLength = titleText.size();
|
---|
358 | renderText(-shownSizex/2.f + shiftx, shownSizey/2.f - textSize*pixelSize - shifty, 0.f, QString(titleText.c_str()));
|
---|
359 |
|
---|
360 | glPopMatrix();
|
---|
361 | }
|
---|
362 | void BasicGlCamera::DrawScale()
|
---|
363 | {
|
---|
364 | glPushMatrix();
|
---|
365 | glLoadIdentity();
|
---|
366 | glPushAttrib(GL_POLYGON_BIT);
|
---|
367 | glShadeModel(GL_SMOOTH);
|
---|
368 | glBegin(GL_QUADS);
|
---|
369 | float oneX = shownSizex/2.f - shownSizex/50.f;
|
---|
370 | float twoX = shownSizex/2.f;
|
---|
371 | float oneY = -shownSizey/2.f;
|
---|
372 | float twoY = -shownSizey/4.f;
|
---|
373 | float threeY = 0;
|
---|
374 | float fourY = shownSizey/4.f;
|
---|
375 | float fiveY = shownSizey/2.f;
|
---|
376 | glColor3f(rr[0], gg[0], bb[0]);
|
---|
377 | glVertex2f(oneX, oneY);
|
---|
378 | glVertex2f(twoX, oneY);
|
---|
379 | glColor3f(rr[1], gg[1], bb[1]);
|
---|
380 | glVertex2f(twoX, twoY);
|
---|
381 | glVertex2f(oneX, twoY);
|
---|
382 |
|
---|
383 | glVertex2f(oneX, twoY);
|
---|
384 | glVertex2f(twoX, twoY);
|
---|
385 | glColor3f(rr[2], gg[2], bb[2]);
|
---|
386 | glVertex2f(twoX, threeY);
|
---|
387 | glVertex2f(oneX, threeY);
|
---|
388 |
|
---|
389 | glVertex2f(oneX, threeY);
|
---|
390 | glVertex2f(twoX, threeY);
|
---|
391 | glColor3f(rr[3], gg[3], bb[3]);
|
---|
392 | glVertex2f(twoX, fourY);
|
---|
393 | glVertex2f(oneX, fourY);
|
---|
394 |
|
---|
395 | glVertex2f(oneX, fourY);
|
---|
396 | glVertex2f(twoX, fourY);
|
---|
397 | glColor3f(rr[4], gg[4], bb[4]);
|
---|
398 | glVertex2f(twoX, fiveY);
|
---|
399 | glVertex2f(oneX, fiveY);
|
---|
400 | float zeroX = oneX - shownSizex/50.f;
|
---|
401 | float zeroY = fiveY - shownSizey/50.f;
|
---|
402 | glColor3fv(tooHighValueCoulour);
|
---|
403 | glVertex2f(zeroX, fiveY);
|
---|
404 | glVertex2f(oneX, fiveY);
|
---|
405 | glVertex2f(oneX, zeroY);
|
---|
406 | glVertex2f(zeroX, zeroY);
|
---|
407 | glColor3fv(tooLowValueCoulour);
|
---|
408 | glVertex2f(zeroX, -fiveY);
|
---|
409 | glVertex2f(oneX, -fiveY);
|
---|
410 | glVertex2f(oneX, -zeroY);
|
---|
411 | glVertex2f(zeroX, -zeroY);
|
---|
412 | glEnd();
|
---|
413 | //draw linear/log tick marks
|
---|
414 | glColor3f(0.f,0.f,0.f);
|
---|
415 | glBegin(GL_LINES);
|
---|
416 | float value;
|
---|
417 | for (int i=1;i<10;i++)
|
---|
418 | {
|
---|
419 | if (logScale)
|
---|
420 | value = log10(i);
|
---|
421 | else
|
---|
422 | value = (float)(i)/10.f;
|
---|
423 | float y = -shownSizey/2.f + value*shownSizey;
|
---|
424 | glVertex2f(oneX, y);
|
---|
425 | glVertex2f(twoX, y);
|
---|
426 | }
|
---|
427 | glEnd();
|
---|
428 | glPopAttrib();
|
---|
429 | glPopMatrix();
|
---|
430 | }
|
---|
431 | void BasicGlCamera::logScalePlease(bool checked)
|
---|
432 | {
|
---|
433 | if (!checked) return;
|
---|
434 | logScale = true;
|
---|
435 | pixelColorUpToDate = false;
|
---|
436 | emit colorPaletteHasChanged();
|
---|
437 | if (isVisible())
|
---|
438 | updateGL();
|
---|
439 | }
|
---|
440 | void BasicGlCamera::regularPalettePlease(bool checked)
|
---|
441 | {
|
---|
442 | if (!checked) return;
|
---|
443 | ss[0] = 0; ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f;
|
---|
444 | rr[0] = 0.15; rr[1] = 0; rr[2] = 0; rr[3] = 1.0f; rr[4] = 0.85f;
|
---|
445 | gg[0] = 0.15; gg[1] = 0; gg[2] = 1; gg[3] = 0; gg[4] = 0.85f;
|
---|
446 | bb[0] = 0.15; bb[1] = 1; bb[2] = 0; bb[3] = 0; bb[4] = 0.85f;
|
---|
447 | tooHighValueCoulour[0] = 1.f;
|
---|
448 | tooHighValueCoulour[1] = 1.f;
|
---|
449 | tooHighValueCoulour[2] = 0.f;
|
---|
450 | tooLowValueCoulour[0] = 0.f;
|
---|
451 | tooLowValueCoulour[1] = 1.f;
|
---|
452 | tooLowValueCoulour[2] = 1.f;
|
---|
453 | pixelColorUpToDate = false;
|
---|
454 |
|
---|
455 | emit colorPaletteHasChanged();
|
---|
456 |
|
---|
457 | if (isVisible())
|
---|
458 | updateGL();
|
---|
459 | }
|
---|
460 | void BasicGlCamera::prettyPalettePlease(bool checked)
|
---|
461 | {
|
---|
462 | if (!checked) return;
|
---|
463 | ss[0] = 0.f; ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f;
|
---|
464 | rr[0] = 0.f; rr[1] = 0.35f; rr[2] = 0.85f; rr[3] = 1.0f; rr[4] = 1.f;
|
---|
465 | gg[0] = 0.f; gg[1] = 0.10f; gg[2] = 0.20f; gg[3] = 0.73f; gg[4] = 1.f;
|
---|
466 | bb[0] = 0.f; bb[1] = 0.03f; bb[2] = 0.06f; bb[3] = 0.00f; bb[4] = 1.f;
|
---|
467 | tooHighValueCoulour[0] = 0.f;
|
---|
468 | tooHighValueCoulour[1] = 1.f;
|
---|
469 | tooHighValueCoulour[2] = 0.f;
|
---|
470 | tooLowValueCoulour[0] = 0.f;
|
---|
471 | tooLowValueCoulour[1] = 0.f;
|
---|
472 | tooLowValueCoulour[2] = 1.f;
|
---|
473 | pixelColorUpToDate = false;
|
---|
474 |
|
---|
475 | emit colorPaletteHasChanged();
|
---|
476 |
|
---|
477 | if (isVisible())
|
---|
478 | updateGL();
|
---|
479 | }
|
---|
480 | void BasicGlCamera::greyScalePalettePlease(bool checked)
|
---|
481 | {
|
---|
482 | if (!checked) return;
|
---|
483 | ss[0] = 0; ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f;
|
---|
484 | rr[0] = 0; rr[1] = 0.25f; rr[2] = 0.5f; rr[3] = 0.75f; rr[4] = 1.0f;
|
---|
485 | gg[0] = 0; gg[1] = 0.25f; gg[2] = 0.5f; gg[3] = 0.75f; gg[4] = 1.0f;
|
---|
486 | bb[0] = 0; bb[1] = 0.25f; bb[2] = 0.5f; bb[3] = 0.75f; bb[4] = 1.0f;
|
---|
487 | tooHighValueCoulour[0] = 0.f;
|
---|
488 | tooHighValueCoulour[1] = 1.f;
|
---|
489 | tooHighValueCoulour[2] = 0.f;
|
---|
490 | tooLowValueCoulour[0] = 0.f;
|
---|
491 | tooLowValueCoulour[1] = 0.f;
|
---|
492 | tooLowValueCoulour[2] = 1.f;
|
---|
493 | pixelColorUpToDate = false;
|
---|
494 |
|
---|
495 | emit colorPaletteHasChanged();
|
---|
496 |
|
---|
497 | if (isVisible())
|
---|
498 | updateGL();
|
---|
499 | }
|
---|
500 | void BasicGlCamera::glowingPalettePlease(bool checked)
|
---|
501 | {
|
---|
502 | if (!checked) return;
|
---|
503 | ss[0] = 0; ss[1] = 0.25f; ss[2] = 0.5f; ss[3] = 0.75f; ss[4] = 1.0f;
|
---|
504 | rr[0] = 0.15; rr[1] = 0.5; rr[2] = 1.f; rr[3] = 0.0f; rr[4] = 1.f;
|
---|
505 | gg[0] = 0.15; gg[1] = 0.5; gg[2] = 1.f; gg[3] = 0.5f; gg[4] = 0.5f;
|
---|
506 | bb[0] = 0.15; bb[1] = 0.5; bb[2] = 1; bb[3] = 1.f; bb[4] = 0.f;
|
---|
507 | tooHighValueCoulour[0] = 1.f;
|
---|
508 | tooHighValueCoulour[1] = 0.f;
|
---|
509 | tooHighValueCoulour[2] = 0.f;
|
---|
510 | tooLowValueCoulour[0] = 0.f;
|
---|
511 | tooLowValueCoulour[1] = 1.f;
|
---|
512 | tooLowValueCoulour[2] = 0.f;
|
---|
513 | pixelColorUpToDate = false;
|
---|
514 |
|
---|
515 | emit colorPaletteHasChanged();
|
---|
516 |
|
---|
517 | if (isVisible())
|
---|
518 | updateGL();
|
---|
519 | }
|
---|
520 | void BasicGlCamera::zeroRotationPlease(bool checked)
|
---|
521 | {
|
---|
522 | if (!checked) return;
|
---|
523 | cameraRotation = 0;
|
---|
524 | pixelColorUpToDate = false;
|
---|
525 | if (isVisible())
|
---|
526 | updateGL();
|
---|
527 | }
|
---|
528 | void BasicGlCamera::plus90RotationPlease(bool checked)
|
---|
529 | {
|
---|
530 | if (!checked) return;
|
---|
531 | cameraRotation = 90;
|
---|
532 | pixelColorUpToDate = false;
|
---|
533 | if (isVisible())
|
---|
534 | updateGL();
|
---|
535 | }
|
---|
536 | void BasicGlCamera::minus90RotationPlease(bool checked)
|
---|
537 | {
|
---|
538 | if (!checked) return;
|
---|
539 | cameraRotation = -90;
|
---|
540 | pixelColorUpToDate = false;
|
---|
541 | if (isVisible())
|
---|
542 | updateGL();
|
---|
543 | }
|
---|
544 |
|
---|
545 | void BasicGlCamera::initializeGL()
|
---|
546 | {
|
---|
547 | qglClearColor(QColor(25,25,38));
|
---|
548 | glShadeModel(GL_FLAT);
|
---|
549 | glDisable(GL_DEPTH_TEST);
|
---|
550 | glDisable(GL_CULL_FACE);
|
---|
551 |
|
---|
552 | glEnable (GL_LINE_SMOOTH);
|
---|
553 | glEnable (GL_BLEND);
|
---|
554 | glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
---|
555 | glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
|
---|
556 |
|
---|
557 | }
|
---|
558 | void BasicGlCamera::resizeGL(int cWidth, int cHeight)
|
---|
559 | {
|
---|
560 | glViewport(0, 0, cWidth, cHeight);
|
---|
561 | glMatrixMode(GL_PROJECTION);
|
---|
562 | glLoadIdentity();
|
---|
563 | GLfloat windowRatio = (float)cWidth/(float)cHeight;
|
---|
564 | if (windowRatio < 1)
|
---|
565 | {
|
---|
566 | windowRatio = 1.0f/windowRatio;
|
---|
567 | gluOrtho2D(-viewSize, viewSize, -viewSize*windowRatio, viewSize*windowRatio);
|
---|
568 | pixelSize = 2*viewSize/(float)cWidth;
|
---|
569 | shownSizex = 2*viewSize;
|
---|
570 | shownSizey = 2*viewSize*windowRatio;
|
---|
571 | }
|
---|
572 | else
|
---|
573 | {
|
---|
574 | gluOrtho2D(-viewSize*windowRatio, viewSize*windowRatio, -viewSize, viewSize);
|
---|
575 | pixelSize = 2*viewSize/(float)cHeight;
|
---|
576 | shownSizex = 2*viewSize*windowRatio;
|
---|
577 | shownSizey = 2*viewSize;
|
---|
578 | }
|
---|
579 | glMatrixMode(GL_MODELVIEW);
|
---|
580 | }
|
---|
581 | void BasicGlCamera::paintGL()
|
---|
582 | {
|
---|
583 | glClear(GL_COLOR_BUFFER_BIT);
|
---|
584 | glLoadIdentity();
|
---|
585 |
|
---|
586 | glTranslatef(0,-0.44,0);
|
---|
587 | glScalef(1.5, 1.5, 1.5);
|
---|
588 |
|
---|
589 | drawCamera(true);
|
---|
590 |
|
---|
591 | drawPatches();
|
---|
592 | }
|
---|
593 | void BasicGlCamera::toggleInterfaceDisplay()
|
---|
594 | {
|
---|
595 | if (linearButton->isVisible())
|
---|
596 | {
|
---|
597 | linearButton->hide();
|
---|
598 | logButton->hide();
|
---|
599 | regularPaletteButton->hide();
|
---|
600 | prettyPaletteButton->hide();
|
---|
601 | greyScalePaletteButton->hide();
|
---|
602 | glowingPaletteButton->hide();
|
---|
603 | zeroRotationButton->hide();
|
---|
604 | minus90RotationButton->hide();
|
---|
605 | plus90Rotationbutton->hide();
|
---|
606 | scaleLabel->hide();
|
---|
607 | colorPaletteLabel->hide();
|
---|
608 | rotationLabel->hide();
|
---|
609 | }
|
---|
610 | else
|
---|
611 | {
|
---|
612 | linearButton->show();
|
---|
613 | logButton->show();
|
---|
614 | regularPaletteButton->show();
|
---|
615 | prettyPaletteButton->show();
|
---|
616 | greyScalePaletteButton->show();
|
---|
617 | glowingPaletteButton->show();
|
---|
618 | zeroRotationButton->show();
|
---|
619 | minus90RotationButton->show();
|
---|
620 | plus90Rotationbutton->show();
|
---|
621 | scaleLabel->show();
|
---|
622 | colorPaletteLabel->show();
|
---|
623 | rotationLabel->show();
|
---|
624 | }
|
---|
625 | }
|
---|
626 |
|
---|
627 | void BasicGlCamera::mousePressEvent(QMouseEvent *cEvent)
|
---|
628 | {
|
---|
629 |
|
---|
630 | }
|
---|
631 | void BasicGlCamera::mouseMoveEvent(QMouseEvent *cEvent)
|
---|
632 | {
|
---|
633 |
|
---|
634 | }
|
---|
635 | void BasicGlCamera::mouseDoubleClickEvent(QMouseEvent *cEvent)
|
---|
636 | {
|
---|
637 |
|
---|
638 | }
|
---|
639 | void BasicGlCamera::drawCamera(bool alsoWire)
|
---|
640 | {
|
---|
641 | // cout << "Super PaintGL" << endl;
|
---|
642 | glColor3f(0.5,0.5,0.5);
|
---|
643 | glLineWidth(1.0);
|
---|
644 | float color;
|
---|
645 |
|
---|
646 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
647 | {
|
---|
648 | color = float(fData[i*fPixelStride+fcSlice]);// + ]eventData[nRoi*i + whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1);
|
---|
649 | int index = 0;
|
---|
650 | while (ss[index] < color)
|
---|
651 | index++;
|
---|
652 | index--;
|
---|
653 | float weight0 = (color-ss[index]) / (ss[index+1]-ss[index]);
|
---|
654 | float weight1 = 1.0f-weight0;
|
---|
655 | pixelsColor[i][0] = weight1*rr[index] + weight0*rr[index+1];
|
---|
656 | pixelsColor[i][1] = weight1*gg[index] + weight0*gg[index+1];
|
---|
657 | pixelsColor[i][2] = weight1*bb[index] + weight0*bb[index+1];
|
---|
658 | }
|
---|
659 |
|
---|
660 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
661 | {
|
---|
662 | // if (i == 690 ||
|
---|
663 | // i == 70)
|
---|
664 | // continue;
|
---|
665 | glColor3fv(pixelsColor[i]);
|
---|
666 | glLoadName(i);
|
---|
667 |
|
---|
668 | drawHexagon(i,true);
|
---|
669 |
|
---|
670 | }
|
---|
671 | if (!alsoWire)
|
---|
672 | return;
|
---|
673 | glColor3f(0.0f,0.0f,0.0f);
|
---|
674 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
675 | {
|
---|
676 | // if (i == 690 ||
|
---|
677 | // i == 70)
|
---|
678 | // continue;
|
---|
679 | drawHexagon(i, false);
|
---|
680 | }
|
---|
681 | }
|
---|
682 | void BasicGlCamera::drawPatches()
|
---|
683 | {
|
---|
684 | glLineWidth(2.0f);
|
---|
685 | float backupRadius = hexRadius;
|
---|
686 | hexRadius *= 0.95;
|
---|
687 | glColor3f(0.5f, 0.5f, 0.3f);
|
---|
688 | glBegin(GL_LINES);
|
---|
689 | for (int i=0;i<NTMARK;i++)
|
---|
690 | {
|
---|
691 | for (unsigned int j=0;j<patchesIndices[i].size();j++)
|
---|
692 | {
|
---|
693 | glVertex2fv(verticesList[patchesIndices[i][j].first]);
|
---|
694 | glVertex2fv(verticesList[patchesIndices[i][j].second]);
|
---|
695 | }
|
---|
696 | }
|
---|
697 | glEnd();
|
---|
698 | hexRadius = backupRadius;
|
---|
699 | }
|
---|
700 | int BasicGlCamera::PixelAtPosition(const QPoint &cPos)
|
---|
701 | {
|
---|
702 | const int MaxSize = 512;
|
---|
703 | GLuint buffer[MaxSize];
|
---|
704 | GLint viewport[4];
|
---|
705 |
|
---|
706 | makeCurrent();
|
---|
707 |
|
---|
708 | glGetIntegerv(GL_VIEWPORT, viewport);
|
---|
709 | glSelectBuffer(MaxSize, buffer);
|
---|
710 | glRenderMode(GL_SELECT);
|
---|
711 |
|
---|
712 | glInitNames();
|
---|
713 | glPushName(0);
|
---|
714 |
|
---|
715 | glMatrixMode(GL_PROJECTION);
|
---|
716 | glPushMatrix();
|
---|
717 | glLoadIdentity();
|
---|
718 | GLfloat windowRatio = GLfloat(width()) / GLfloat(height());
|
---|
719 | gluPickMatrix(GLdouble(cPos.x()), GLdouble(viewport[3] - cPos.y()),
|
---|
720 | 1.0, 1.0, viewport);
|
---|
721 |
|
---|
722 | if (windowRatio < 1)
|
---|
723 | {
|
---|
724 | windowRatio = 1.0f/windowRatio;
|
---|
725 | gluOrtho2D(-viewSize, viewSize, -viewSize*windowRatio, viewSize*windowRatio);
|
---|
726 | }
|
---|
727 | else
|
---|
728 | {
|
---|
729 | gluOrtho2D(-viewSize*windowRatio, viewSize*windowRatio, -viewSize, viewSize);
|
---|
730 | }
|
---|
731 |
|
---|
732 | glMatrixMode(GL_MODELVIEW);
|
---|
733 | drawCamera(false);
|
---|
734 | glMatrixMode(GL_PROJECTION);
|
---|
735 | glPopMatrix();
|
---|
736 |
|
---|
737 | //for some reason that I cannot understand, the push/pop matrix doesn't do the trick here... bizarre
|
---|
738 | //ok, so re-do the resizeGL thing.
|
---|
739 | resizeGL(width(), height());
|
---|
740 |
|
---|
741 | if (!glRenderMode(GL_RENDER))
|
---|
742 | return -1;
|
---|
743 |
|
---|
744 | return buffer[3];
|
---|
745 | }
|
---|
746 | void BasicGlCamera::drawHexagon(int index, bool solid)
|
---|
747 | {
|
---|
748 | /* float minX, maxX, minY, maxY;
|
---|
749 | minX = minY = 1e10;
|
---|
750 | maxX = maxY = -1e10;
|
---|
751 | for (int i=0;i<1438;i++)
|
---|
752 | {
|
---|
753 | for (int j=0;j<6;j++)
|
---|
754 | {
|
---|
755 | if (verticesList[verticesIndices[i][j]][0] > maxX)
|
---|
756 | maxX = verticesList[verticesIndices[i][j]][0];
|
---|
757 | if (verticesList[verticesIndices[i][j]][0] < minX)
|
---|
758 | minX = verticesList[verticesIndices[i][j]][0];
|
---|
759 | if (verticesList[verticesIndices[i][j]][1] > maxY)
|
---|
760 | maxY = verticesList[verticesIndices[i][j]][1];
|
---|
761 | if (verticesList[verticesIndices[i][j]][1] < minY)
|
---|
762 | minY = verticesList[verticesIndices[i][j]][1];
|
---|
763 | }
|
---|
764 | }
|
---|
765 | cout << "Min, Max X: " << minX << " " << maxX << endl;
|
---|
766 | cout << "Min, Max Y: " << minY << " " << maxY << endl;
|
---|
767 | exit(0);*/
|
---|
768 | if (solid)
|
---|
769 | glBegin(GL_POLYGON);
|
---|
770 | else
|
---|
771 | glBegin(GL_LINE_LOOP);
|
---|
772 |
|
---|
773 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
774 | glVertex2fv(verticesList[verticesIndices[index][1]]);
|
---|
775 | glVertex2fv(verticesList[verticesIndices[index][2]]);
|
---|
776 | glVertex2fv(verticesList[verticesIndices[index][3]]);
|
---|
777 | glVertex2fv(verticesList[verticesIndices[index][4]]);
|
---|
778 | glVertex2fv(verticesList[verticesIndices[index][5]]);
|
---|
779 | if (solid)
|
---|
780 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
781 |
|
---|
782 | glEnd();
|
---|
783 | }
|
---|
784 |
|
---|
785 | void BasicGlCamera::updateNeighbors(int currentPixel)
|
---|
786 | {
|
---|
787 | float squaredDistance = 0;
|
---|
788 | for (int i=0;i<currentPixel;i++)
|
---|
789 | {
|
---|
790 | squaredDistance = (pixelsCoords[i][0] - pixelsCoords[currentPixel][0])*
|
---|
791 | (pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) +
|
---|
792 | (pixelsCoords[i][1] - pixelsCoords[currentPixel][1])*
|
---|
793 | (pixelsCoords[i][1] - pixelsCoords[currentPixel][1]);
|
---|
794 | if (squaredDistance < 4*hexRadius*hexRadius*(1.0f+hexTolerance))//neighbor !
|
---|
795 | {//ok, but which one ?
|
---|
796 | if (fabs(pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) < hexTolerance &&
|
---|
797 | pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//top
|
---|
798 | neighbors[i][0] = currentPixel;
|
---|
799 | neighbors[currentPixel][3] = i;
|
---|
800 | continue;}
|
---|
801 | if (fabs(pixelsCoords[i][0] - pixelsCoords[currentPixel][0]) < hexTolerance &&
|
---|
802 | pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//bottom
|
---|
803 | neighbors[i][3] = currentPixel;
|
---|
804 | neighbors[currentPixel][0] = i;
|
---|
805 | continue;}
|
---|
806 | if (pixelsCoords[i][0] > pixelsCoords[currentPixel][0] &&
|
---|
807 | pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//top right
|
---|
808 | neighbors[i][4] = currentPixel;
|
---|
809 | neighbors[currentPixel][1] = i;
|
---|
810 | continue;}
|
---|
811 | if (pixelsCoords[i][0] > pixelsCoords[currentPixel][0] &&
|
---|
812 | pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//bottom right
|
---|
813 | neighbors[i][5] = currentPixel;
|
---|
814 | neighbors[currentPixel][2] = i;
|
---|
815 | continue;}
|
---|
816 | if (pixelsCoords[i][0] < pixelsCoords[currentPixel][0] &&
|
---|
817 | pixelsCoords[i][1] > pixelsCoords[currentPixel][1]){//top left
|
---|
818 | neighbors[i][2] = currentPixel;
|
---|
819 | neighbors[currentPixel][5] = i;
|
---|
820 | continue;}
|
---|
821 | if (pixelsCoords[i][0] < pixelsCoords[currentPixel][0] &&
|
---|
822 | pixelsCoords[i][1] < pixelsCoords[currentPixel][1]){//bottom left
|
---|
823 | neighbors[i][1] = currentPixel;
|
---|
824 | neighbors[currentPixel][4] = i;
|
---|
825 | continue;}
|
---|
826 | }
|
---|
827 | }
|
---|
828 | }
|
---|
829 | void BasicGlCamera::skipPixels(int start, int howMany)
|
---|
830 | {
|
---|
831 | for (int i=start;i<MAX_NUM_PIXELS-howMany;i++)
|
---|
832 | {
|
---|
833 | pixelsCoords[i][0] = pixelsCoords[i+howMany][0];
|
---|
834 | pixelsCoords[i][1] = pixelsCoords[i+howMany][1];
|
---|
835 | }
|
---|
836 | }
|
---|
837 | void BasicGlCamera::calculatePixelsCoords()
|
---|
838 | {
|
---|
839 | pixelsCoords[0][0] = 0;
|
---|
840 | pixelsCoords[0][1] = 0.3;
|
---|
841 | pixelsCoords[0][2] = 0;
|
---|
842 | pixelsCoords[1][0] = 0;
|
---|
843 | pixelsCoords[1][1] = 0.3+2*hexRadius;
|
---|
844 | pixelsCoords[1][2] = 0;
|
---|
845 | neighbors[0][0] = 1;
|
---|
846 | neighbors[1][3] = 0;
|
---|
847 | //from which side of the previous hexagon are we coming from ?
|
---|
848 | int fromSide = 3;
|
---|
849 | //to which side are we heading to ?
|
---|
850 | int toSide = 0;
|
---|
851 | for (int i=2;i<MAX_NUM_PIXELS;i++)
|
---|
852 | {
|
---|
853 | // cout << "i " << i << endl;
|
---|
854 | toSide = fromSide-1;
|
---|
855 | if (toSide < 0)
|
---|
856 | toSide =5;
|
---|
857 | while (neighbors[i-1][toSide] >= 0)
|
---|
858 | {
|
---|
859 | toSide--;
|
---|
860 | if (toSide < 0)
|
---|
861 | toSide = 5;
|
---|
862 | }
|
---|
863 | fromSide = toSide + 3;
|
---|
864 | if (fromSide > 5)
|
---|
865 | fromSide -= 6;
|
---|
866 | //ok. now we now in which direction we're heading
|
---|
867 | pixelsCoords[i][0] = pixelsCoords[i-1][0];
|
---|
868 | pixelsCoords[i][1] = pixelsCoords[i-1][1];
|
---|
869 | pixelsCoords[i][2] = pixelsCoords[i-1][2];
|
---|
870 | switch (toSide)
|
---|
871 | {
|
---|
872 | case 0:
|
---|
873 | pixelsCoords[i][1] += 2*hexRadius;
|
---|
874 | break;
|
---|
875 | case 1:
|
---|
876 | pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0);
|
---|
877 | pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0);
|
---|
878 | break;
|
---|
879 | case 2:
|
---|
880 | pixelsCoords[i][0] += (2*hexRadius)*sin(M_PI/3.0);
|
---|
881 | pixelsCoords[i][1] -= (2*hexRadius)*cos(M_PI/3.0);
|
---|
882 | break;
|
---|
883 | case 3:
|
---|
884 | pixelsCoords[i][1] -= 2*hexRadius;
|
---|
885 | break;
|
---|
886 | case 4:
|
---|
887 | pixelsCoords[i][0] -= (2*hexRadius)*sin(M_PI/3.0);
|
---|
888 | pixelsCoords[i][1] -= (2*hexRadius)*cos(M_PI/3.0);
|
---|
889 | break;
|
---|
890 | case 5:
|
---|
891 | pixelsCoords[i][0] -= (2*hexRadius)*sin(M_PI/3.0);
|
---|
892 | pixelsCoords[i][1] += (2*hexRadius)*cos(M_PI/3.0);
|
---|
893 | break;
|
---|
894 | };
|
---|
895 |
|
---|
896 | updateNeighbors(i);
|
---|
897 | }
|
---|
898 | //Ok. So now we've circled around all the way to MAX_NUM_PIXELS
|
---|
899 | //do the required shifts so that it matches the fact camera up to ACTUAL_NUM_PIXELS pixels
|
---|
900 | //remember the location pixels 1438 and 1439, and re-assign them later on
|
---|
901 | GLfloat backupCoords[4];
|
---|
902 | skipPixels(1200, 1);
|
---|
903 | skipPixels(1218, 3);
|
---|
904 | skipPixels(1236, 1);
|
---|
905 | skipPixels(1256, 1);
|
---|
906 | skipPixels(1274, 3);
|
---|
907 | skipPixels(1292, 3);
|
---|
908 | skipPixels(1309, 6);
|
---|
909 | skipPixels(1323, 7);
|
---|
910 | skipPixels(1337, 6);
|
---|
911 | skipPixels(1354, 6);
|
---|
912 | skipPixels(1368, 7);
|
---|
913 | //la c'est dans 1390 qu'il y a 1439
|
---|
914 | backupCoords[0] = pixelsCoords[1390][0];
|
---|
915 | backupCoords[1] = pixelsCoords[1390][1];
|
---|
916 | skipPixels(1382, 9);
|
---|
917 | skipPixels(1394, 12);
|
---|
918 | skipPixels(1402, 15);
|
---|
919 | skipPixels(1410, 12);
|
---|
920 | //la c'est dans 1422 qu'il y a 1438
|
---|
921 | backupCoords[2] = pixelsCoords[1422][0];
|
---|
922 | backupCoords[3] = pixelsCoords[1422][1];
|
---|
923 | skipPixels(1422, 12);
|
---|
924 | skipPixels(1430, 15);
|
---|
925 |
|
---|
926 | pixelsCoords[1438][0] = backupCoords[2];
|
---|
927 | pixelsCoords[1438][1] = backupCoords[3];
|
---|
928 | pixelsCoords[1439][0] = backupCoords[0];
|
---|
929 | pixelsCoords[1439][1] = backupCoords[1];
|
---|
930 | }
|
---|
931 | void BasicGlCamera::buildVerticesList()
|
---|
932 | {
|
---|
933 | numVertices = 0;
|
---|
934 | GLfloat cVertex[2];
|
---|
935 | for (int i=0;i<NPIX;i++)
|
---|
936 | {
|
---|
937 | for (int j=0;j<6;j++)
|
---|
938 | {
|
---|
939 | for (int k=0;k<2;k++)
|
---|
940 | cVertex[k] = hexcoords[j][k]*hexRadius + pixelsCoords[i][k];
|
---|
941 | bool found = false;
|
---|
942 | for (int k=0;k<numVertices;k++)
|
---|
943 | {
|
---|
944 | if ((cVertex[0] - verticesList[k][0])*
|
---|
945 | (cVertex[0] - verticesList[k][0]) +
|
---|
946 | (cVertex[1] - verticesList[k][1])*
|
---|
947 | (cVertex[1] - verticesList[k][1]) < hexTolerance*hexTolerance)
|
---|
948 | {
|
---|
949 | found = true;
|
---|
950 | break;
|
---|
951 | }
|
---|
952 | }
|
---|
953 | if (!found)
|
---|
954 | {
|
---|
955 | for (int k=0;k<2;k++)
|
---|
956 | verticesList[numVertices][k] = cVertex[k];
|
---|
957 | numVertices++;
|
---|
958 | }
|
---|
959 | }
|
---|
960 | }
|
---|
961 | //cout << "numVertices: " << numVertices << endl;
|
---|
962 | for (int i=0;i<NPIX;i++)
|
---|
963 | {
|
---|
964 | for (int j=0;j<6;j++)
|
---|
965 | {
|
---|
966 | for (int k=0;k<2;k++)
|
---|
967 | cVertex[k] = hexcoords[j][k]*hexRadius + pixelsCoords[i][k];
|
---|
968 | for (int k=0;k<numVertices;k++)
|
---|
969 | {
|
---|
970 | if ((cVertex[0] - verticesList[k][0])*
|
---|
971 | (cVertex[0] - verticesList[k][0]) +
|
---|
972 | (cVertex[1] - verticesList[k][1])*
|
---|
973 | (cVertex[1] - verticesList[k][1]) < hexTolerance*hexTolerance)
|
---|
974 | {
|
---|
975 | verticesIndices[i][j] = k;
|
---|
976 | break;
|
---|
977 | }
|
---|
978 | }
|
---|
979 | }
|
---|
980 | }
|
---|
981 | }
|
---|
982 | void BasicGlCamera::buildPatchesIndices()
|
---|
983 | {
|
---|
984 | vector<edge>::iterator it;
|
---|
985 | bool erased = false;
|
---|
986 | // patchesIndices.resize(NTMARK);
|
---|
987 | for (int i=0;i<NTMARK;i++)//for all patches
|
---|
988 | {
|
---|
989 | patchesIndices[i].clear();
|
---|
990 | for (int j=0;j<9;j++)//for all cells of the current patch
|
---|
991 | {
|
---|
992 | if (softwareMapping[patches[i][j]] >= ACTUAL_NUM_PIXELS)
|
---|
993 | continue;
|
---|
994 | for (int k=0;k<6;k++)//for all sides of the current cell
|
---|
995 | {
|
---|
996 | int first = k-1;
|
---|
997 | int second = k;
|
---|
998 | if (first < 0)
|
---|
999 | first = 5;
|
---|
1000 | erased = false;
|
---|
1001 | for (it=(patchesIndices[i]).begin(); it != (patchesIndices[i]).end(); it++)//check if this side is here already or not
|
---|
1002 | {
|
---|
1003 | if (((*it).first == verticesIndices[softwareMapping[patches[i][j]]][first] &&
|
---|
1004 | (*it).second == verticesIndices[softwareMapping[patches[i][j]]][second]) ||
|
---|
1005 | ((*it).first == verticesIndices[softwareMapping[patches[i][j]]][second] &&
|
---|
1006 | (*it).second == verticesIndices[softwareMapping[patches[i][j]]][first]))
|
---|
1007 | {
|
---|
1008 | patchesIndices[i].erase(it);
|
---|
1009 | erased = true;
|
---|
1010 | break;
|
---|
1011 | }
|
---|
1012 | }
|
---|
1013 | if (!erased)
|
---|
1014 | {
|
---|
1015 | edge temp;
|
---|
1016 | temp.first = verticesIndices[softwareMapping[patches[i][j]]][first];
|
---|
1017 | temp.second = verticesIndices[softwareMapping[patches[i][j]]][second];
|
---|
1018 | patchesIndices[i].push_back(temp);
|
---|
1019 | }
|
---|
1020 | }
|
---|
1021 | }
|
---|
1022 | }
|
---|
1023 | // for (int i=0;i<NTMARK;i++)
|
---|
1024 | // {
|
---|
1025 | // cout << ".....................patch " << i << " size: " << patchesIndices[i].size() << endl;
|
---|
1026 | // for (unsigned int j=0;j<patchesIndices[i].size();j++)
|
---|
1027 | // {
|
---|
1028 | // if (patchesIndices[i][j].first < 0 || patchesIndices[i][j].first > 3013)
|
---|
1029 | // cout << patchesIndices[i][j].first << " and " << patchesIndices[i][j].second << " and " << j << endl;
|
---|
1030 | // }
|
---|
1031 | // }
|
---|
1032 | }
|
---|
1033 |
|
---|