-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
737 lines (647 loc) · 24.5 KB
/
mainwindow.cpp
File metadata and controls
737 lines (647 loc) · 24.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
/* ------------------------------------------------------------------------------------
The definition of the main window class.
Written by Nicholas Phillips.
QT4 implementation. Michael R. Greason, ADNET, 23 August 2007.
------------------------------------------------------------------------------------ */
/*
Fetch header files.
*/
#include <stdio.h>
#include <QMessageBox>
#include <QFileDialog>
#include <QFileInfo>
#include <QWhatsThis>
#include <QSize>
#include "mainwindow.h"
#include "controldialog.h"
#include "rangecontrol.h"
#include "debug.h"
#include "outlog.h"
using namespace std;
/*
Constants.
*/
const double WhiteRiggingRadius = 0.99;
/* ====================================================================================
'mainWindow' defines the main window. It descends from QMainWindow and from the
Ui::MainWindow class that was created by QT Designer.
NOTE: The SkyViewer widget, which descends from QGLViewer, is NOT inserted into
the window through QT Designer; it is explicitly inserted in the constructor of
this class.
==================================================================================== */
/* ------------------------------------------------------------------------------------
The class constructor.
Arguments:
parent - The parent wiget/window.
Written by Nicholas Phillips.
QT4 implementation. Michael R. Greason, ADNET, 23 August 2007.
------------------------------------------------------------------------------------ */
mainWindow::mainWindow(QWidget *parent) : QMainWindow(parent)
{
/*
Initialize components.
*/
map = NULL;
texture = new SkyTexture;
rigging = new Rigging;
whiterig = new Rigging;
polarsphere = new PolarArgLineSet;
/*
Populate the window.
*/
setupUi(this);
viewer = new SkyViewer(centralwidget, this);
viewer->setObjectName(QString::fromUtf8("viewer"));
viewer->setGeometry(QRect(1, 0, 600, 591));
viewer->setTexture(texture);
viewer->setRigging(rigging);
viewer->setWhiteRigging(whiterig);
viewer->setPolarAngles(polarsphere);
viewer->setFPSIsDisplayed(false);
setWindowTitle(tr("Skyviewer"));
filelabel = new QLabel("");
filelabel->setMargin(2);
filelabel->setMinimumWidth(150);
filelabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
viewerStatus->addWidget(filelabel);
projlabel = new QLabel("Projection: 3D Sphere");
projlabel->setMargin(2);
projlabel->setMinimumWidth(150);
projlabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
viewerStatus->addWidget(projlabel);
maplabel = new QLabel("Map: Temperature");
maplabel->setMargin(2);
maplabel->setMinimumWidth(150);
maplabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
viewerStatus->addWidget(maplabel);
if (! showpolar)
{
actionPolarAnglesM->setDisabled(true);
actionPolarAnglesM->setVisible(false);
actionPolarAnglesTB->setDisabled(true);
actionPolarAnglesTB->setVisible(false);
}
/*
Create the progress and range control windows.
*/
ctl = new ControlDialog(this);
rngctl = ctl->getRangeControl();
/*
Define the connections.
*/
connect(actionOpen, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::fileLoad));
connect(actionReload, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::fileReload));
connect(actionNew, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::fileNew));
connect(actionSnapshot, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::fileSnapshot));
connect(actionClose, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::fileClose));
connect(actionExit, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::fileExit));
connect(action3D_Sphere_tb, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::proj3Dsphere));
connect(action3D_Sphere_m, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::proj3Dsphere));
connect(actionMollweide_tb, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::projMollweide));
connect(actionMollweide_m, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::projMollweide));
connect(actionTemperature, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::mapTemperature));
connect(actionQ_Polarization, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::mapQPolarization));
connect(actionU_Polarization, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::mapUPolarization));
connect(actionP_Polarization, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::mapPPolarization));
connect(actionNum_Obs, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::mapNumObs));
connect(actionPolarAnglesTB, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::mapPolVectTB));
connect(actionPolarAnglesM, static_cast<void(QAction::*)(bool)>(&QAction::triggered), this, static_cast<void(mainWindow::*)()>(&mainWindow::mapPolVectM));
connect(actionHelp, static_cast<void(QAction::*)(bool)>(&QAction::triggered), viewer, static_cast<void(SkyViewer::*)()>(&SkyViewer::help));
connect(rngctl, static_cast<void(RangeControl::*)()>(&RangeControl::reTextureNeeded), this, static_cast<void(mainWindow::*)()>(&mainWindow::reTexture));
connect(rngctl, static_cast<void(RangeControl::*)()>(&RangeControl::changeProjRigging), this, static_cast<void(mainWindow::*)()>(&mainWindow::newRigging));
connect(rngctl, static_cast<void(RangeControl::*)()>(&RangeControl::changeFieldInfo), this, static_cast<void(mainWindow::*)()>(&mainWindow::newField));
connect(rngctl, static_cast<void(RangeControl::*)()>(&RangeControl::changePolVect), this, static_cast<void(mainWindow::*)()>(&mainWindow::newPolVect));
connect(ctl, static_cast<void(ControlDialog::*)(std::vector<int>)>(&ControlDialog::resetPixels), this, static_cast<void(mainWindow::*)(std::vector<int>)>(&mainWindow::unselectPixels));
connect(ctl, static_cast<void(ControlDialog::*)(int)>(&ControlDialog::recenterOnPixel), this, static_cast<void(mainWindow::*)(int)>(&mainWindow::recenterOnPixel));
/*
Remaining initialization.
*/
QSize sz;
sz = viewer->size();
delta = size() - sz;
viewmoll = false;
action3D_Sphere_tb->setChecked(! viewmoll);
action3D_Sphere_m->setChecked(! viewmoll);
actionMollweide_tb->setChecked(viewmoll);
actionMollweide_m->setChecked(viewmoll);
rigging->generate (rngctl->getRigging(), viewmoll);
whiterig->generate(rngctl->getRigging(), viewmoll, WhiteRiggingRadius);
ctl->clearStatus();
ctl->show();
}
/* ------------------------------------------------------------------------------------
The class destructor.
Arguments:
None.
Written by Michael R. Greason, ADNET, 23 August 2007.
------------------------------------------------------------------------------------ */
mainWindow::~mainWindow(void)
{
if (map != NULL) delete map;
map = NULL;
if (texture != NULL) delete texture;
texture = NULL;
if (rigging != NULL) delete rigging;
rigging = NULL;
if (whiterig != NULL) delete whiterig;
whiterig = NULL;
if (polarsphere != NULL) delete polarsphere;
polarsphere = NULL;
}
/* ------------------------------------------------------------------------------------
'resizeEvent' responds to a resize event, telling the QGLviewer to change its
size accordingly.
Arguments:
event - The event to process.
Returned:
Nothing.
Written by Michael R. Greason, ADNET, 27 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::resizeEvent(QResizeEvent *event)
{
/*
Adjust the size of the viewer.
*/
viewer->resize(event->size() - delta);
/*
Give the parent class its shot at the event.
*/
QMainWindow::resizeEvent(event);
}
/* ------------------------------------------------------------------------------------
'readFile' reads a FITS file. The name of the file is specified as either a null-
terminated strinkg or as a QSTRING. The internal filename is set and the work is
passed off to the other version of this method that takes no arguments.
Arguments:
file - The name of the file.
Returned:
Nothing.
Written by Michael R. Greason, ADNET, 24 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::readFile (const char *file)
{
if (file == NULL) return;
QString tmp = file;
readFile(tmp);
}
void mainWindow::readFile (const QString file)
{
QString tmp;
QFileInfo fi;
if (file.length() <= 0) return;
filename = file;
fi.setFile(filename);
tmp = fi.completeSuffix();
tmp = (tmp.length() > 0) ? (fi.baseName() + tr(".") + tmp) : fi.baseName();
filelabel->setText(tmp);
ctl->startFile(tmp);
readFile();
//initMinMax();
}
/* ------------------------------------------------------------------------------------
'readFile' reads a FITS file. The name of the file is supplied through the internal
filename variable. This routine actually goes out and reads the file.
Arguments:
None.
Returned:
Nothing.
Written by Michael R. Greason, ADNET, 24 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::readFile ()
{
if (filename.length() <= 0) return;
/*
Allocate space for the map.
*/
if (map == NULL) map = new HealpixMap();
if (map == NULL)
{
QMessageBox::critical(this, tr("Skyviewer"),
tr("Unable to allocate memory for the map!"),
QMessageBox::Ok);
return;
}
/*
Read the map.
*/
try {
map->readFITS(filename, ctl);
}
catch (MapException &exc)
{
QString msg(tr("Unable to read map: "));
QMessageBox::critical(this, tr("Skyviewer Load Error"),
(msg + filename + "\nError: " + exc.Message()),
QMessageBox::Ok);
return;
}
ctl->init(map);
setFieldEnables();
/*
Create the texture and polarization angle vectors (if needed).
*/
if (showtex)
{
try {
texture->set(map, rngctl);
viewer->update();
}
catch (MapException &exc)
{
QString msg(tr("Unable to read map: "));
QMessageBox::critical(this, tr("Skyviewer"),
(exc.Comment() == NULL) ? (msg + filename) : tr(exc.Comment()),
QMessageBox::Ok);
return;
}
}
if (showpolar && map->has_Polarization())
{
if (polarsphere != NULL) polarsphere->set(map);
}
/*
Clear the list of selected pixels. The window is taken care of at a lower
level (as the file is being read).
*/
}
/* ------------------------------------------------------------------------------------
'undefined' is called when a response routine is currently not implemented.
Arguments:
None.
Returned:
Nothing.
Written by Nicholas Phillips.
QT4 implementation. Michael R. Greason, ADNET, 23 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::undefined()
{
QMessageBox::warning(this, tr("Skyviewer"),
tr("This feature has not yet been defined!"),
QMessageBox::Ok);
}
/* ------------------------------------------------------------------------------------
'fileNew' prompts the user to specify a new file to be displayed.
To be openned in a new viewer window.
Not implemented yet.
Arguments:
None.
Returned:
Nothing.
Written by Nicholas Phillips.
------------------------------------------------------------------------------------ */
void mainWindow::fileNew()
{
undefined();
}
/* ------------------------------------------------------------------------------------
'fileLoad' prompts the user to specify a new file to be displayed.
Arguments:
None.
Returned:
Nothing.
Written by Nicholas Phillips.
QT4 implementation. Michael R. Greason, ADNET, 23 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::fileLoad()
{
QString dir(".");
if (filename.length() > 0)
{
QFileInfo fi(filename);
dir = fi.absolutePath();
}
QString fil = QFileDialog::getOpenFileName(this, tr("Open FITS File"),
dir, tr("FITS (*.fits);;Any(*)"));
if (fil.length() <= 0) return;
readFile(fil);
}
/* ------------------------------------------------------------------------------------
'fileReload' causes the current file to be reloaded and redisplayed.
Arguments:
None.
Returned:
Nothing.
Written by Nicholas Phillips.
QT4 implementation. Michael R. Greason, ADNET, 23 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::fileReload()
{
readFile();
}
/* ------------------------------------------------------------------------------------
'fileSnapshot' takes a snapshot of the current view.
Arguments:
None.
Returned:
Nothing.
Written by Nicholas Phillips.
QT4 implementation. Michael R. Greason, ADNET, 23 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::fileSnapshot()
{
//undefined();
viewer->saveSnapshot(false);
}
/* ------------------------------------------------------------------------------------
'fileClose' closes the current main window; if others are still open the application
does not terminate.
Arguments:
None.
Returned:
Nothing.
Written by Nicholas Phillips.
QT4 implementation. Michael R. Greason, ADNET, 23 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::fileClose()
{
close();
}
/* ------------------------------------------------------------------------------------
'fileExit' shuts down the application.
Arguments:
None.
Returned:
Nothing.
Written by Nicholas Phillips.
QT4 implementation. Michael R. Greason, ADNET, 23 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::fileExit()
{
QApplication::exit(0);
}
//=====================================================================================
// Handle Changing the Projection/Rigging
//=====================================================================================
/* ------------------------------------------------------------------------------------
'proj3Dsphere'
'projMollweide'
responds to a change in choice of projection. rangeControl is told of the
change. If it decides, it will signal a need to change the rigging
Written by Nicholas Phillips.
QT4 implementation. Michael R. Greason, ADNET, 23 August 2007.
Modified by NGP, 8/12/08
------------------------------------------------------------------------------------ */
void mainWindow::proj3Dsphere()
{
if( rngctl->getProjection() == Spherical ) {
action3D_Sphere_tb->setChecked(true);
action3D_Sphere_m->setChecked(true);
return;
}
rngctl->setProjection(Spherical);
}
void mainWindow::projMollweide()
{
if( rngctl->getProjection() == Mollweide ) {
actionMollweide_tb->setChecked(true);
actionMollweide_m->setChecked(true);
return;
}
rngctl->setProjection(Mollweide);
}
/* ------------------------------------------------------------------------------------
'newRigging' updates the viewer when the user requests a change in the rigging size.
Arguments:
None.
Returned:
Nothing.
Written by Nicholas Phillips.
QT4 implementation. Michael R. Greason, ADNET, 23 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::newRigging(void)
{
try {
viewmoll = rngctl->getProjection() == Mollweide;
viewer->constrainMollweide(viewmoll);
rigging->generate (rngctl->getRigging(), viewmoll);
whiterig->generate(rngctl->getRigging(), viewmoll, WhiteRiggingRadius);
polarsphere->setMollweide(viewmoll);
viewer->update();
}
catch (MapException &exc)
{
const char *comm = exc.Comment();
QMessageBox::critical(this, tr("Skyviewer"),
tr((comm != NULL) ? comm : "newRigging error!"),
QMessageBox::Ok);
}
// Update GUI.
action3D_Sphere_tb->setChecked(! viewmoll);
action3D_Sphere_m->setChecked(! viewmoll);
actionMollweide_tb->setChecked(viewmoll);
actionMollweide_m->setChecked(viewmoll);
projlabel->setText(viewmoll ? "Projection: Mollweide" : "Projection: 3D Sphere");
}
//=====================================================================================
// Handle Changing the Display Map Field
//=====================================================================================
/* ------------------------------------------------------------------------------------
'setFieldEnables' Set the ToolBar's Field selections enabled according to new map
Arguments:
None.
Written by Nicholas Phillips.
QT4 implementation. Michael R. Greason, ADNET, 23 August 2007.
Updated by NGP, 8/13/08
------------------------------------------------------------------------------------ */
void mainWindow::setFieldEnables()
{
actionTemperature->setEnabled(map->has_Temperature());
actionQ_Polarization->setEnabled(map->has_Polarization());
actionU_Polarization->setEnabled(map->has_Polarization());
actionP_Polarization->setEnabled(map->has_Polarization());
actionNum_Obs->setEnabled(map->has_Nobs());
actionPolarAnglesTB->setEnabled(map->has_Polarization());
actionPolarAnglesM->setEnabled(map->has_Polarization());
return;
}
/* ------------------------------------------------------------------------------------
'mapTemperature'
'mapQPolarization()'
'mapUPolarization()'
'mapPPolarization()'
'mapNumObs()'
Responds to changing the displayed map field action.
rangeControl is told of the change and decides what to do.
Written by Nicholas Phillips.
QT4 implementation. Michael R. Greason, ADNET, 23 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::mapTemperature() { rngctl->setField(I); }
void mainWindow::mapQPolarization() { rngctl->setField(Q); }
void mainWindow::mapUPolarization() { rngctl->setField(U); }
void mainWindow::mapPPolarization() { rngctl->setField(P); }
void mainWindow::mapNumObs() { rngctl->setField(Nobs); }
/* ------------------------------------------------------------------------------------
'newField()'
Update the GUI to reflect the state of the displayed field based on the
state of rangeControl
Written by Nicholas Phillips, 8/13/08
------------------------------------------------------------------------------------ */
void mainWindow::newField()
{
actionTemperature->setChecked(false);
actionQ_Polarization->setChecked(false);
actionU_Polarization->setChecked(false);
actionP_Polarization->setChecked(false);
actionNum_Obs->setChecked(false);
switch( rngctl->getField() ) {
case I:
actionTemperature->setChecked(true);
maplabel->setText(tr("Map: Temperature"));
break;
case Q:
actionQ_Polarization->setChecked(true);
maplabel->setText(tr("Map: Q Polarization"));
break;
case U:
actionU_Polarization->setChecked(true);
maplabel->setText(tr("Map: U Polarization"));
break;
case P:
actionP_Polarization->setChecked(true);
maplabel->setText(tr("Map: P Polarization"));
break;
case Nobs:
actionNum_Obs->setChecked(true);
maplabel->setText(tr("Map: Num Obs"));
break;
}
return;
}
//=====================================================================================
/* ------------------------------------------------------------------------------------
'mapPolVectM' and 'mapPolVectTB' toggle the polarization vectors on and off.
Arguments:
None.
Returned:
Nothing.
Written by Nicholas Phillips.
QT4 implementation. Michael R. Greason, ADNET, 30 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::mapPolVectM()
{
rngctl->setPolarVect(actionPolarAnglesM->isChecked() ? On : Off );
}
void mainWindow::mapPolVectTB()
{
rngctl->setPolarVect(actionPolarAnglesTB->isChecked() ? On : Off );
}
/* ------------------------------------------------------------------------------------
'newPolVect' Responds to rangeDialog indicating a change in state of displaying
the polarization vectors.
Written by Nicholas Phillips, 8/13/08
------------------------------------------------------------------------------------ */
void mainWindow::newPolVect()
{
bool b = rngctl->getPolVect() == On;
actionPolarAnglesTB->setChecked(b);
actionPolarAnglesM->setChecked(b);
if (polarsphere != NULL) polarsphere->setOn(b);
}
//=====================================================================================
/* ------------------------------------------------------------------------------------
'reTexture' updates the map texture and instructs the viewer to repaint itself.
This routine should be called when something occurs to modify the texture.
Arguments:
None.
Returned:
Nothing.
Written Michael R. Greason, ADNET, 23 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::reTexture(void)
{
if (! showtex) return;
try {
texture->set(map, rngctl);
viewer->update();
}
catch (MapException &exc)
{
const char *comm = exc.Comment();
QMessageBox::critical(this, tr("Skyviewer"),
tr((comm != NULL) ? comm : "reTextureOld error!"),
QMessageBox::Ok);
}
}
//=====================================================================================
/* ------------------------------------------------------------------------------------
'selectPixel' responds to the selection of a pixel in the viewer. This version gets
the pixel to process from its arguments.
Arguments:
pix - The pixel to process
Returned:
pix - The pixel id.
Written by Michael R. Greason, ADNET, 29 August 2007.
------------------------------------------------------------------------------------ */
int mainWindow::selectPixel (int pix)
{
if( ! ctl->selectPixel(pix,&((*map)[pix])) ) {
texture->highlite(pix, 1.0);
}
if ( ctl->numselected() <= 0) {
if (viewer->animationIsStarted()) viewer->stopAnimation();
}
else {
if (! viewer->animationIsStarted()) viewer->startAnimation();
}
viewer->update();
return pix;
}
/* ------------------------------------------------------------------------------------
'selectPixel' responds to the selection of a pixel in the viewer. This version
converts the coordinates into a pixel id and passes execution to the other version.
Arguments:
theta - The colatitude of the selected pixel, in radians, measured from the
North Pole.
phi - The longitude of the selected pixel, in radians.
Returned:
pix - The pixel id.
Written by Michael R. Greason, ADNET, 29 August 2007.
------------------------------------------------------------------------------------ */
int mainWindow::selectPixel (double theta, double phi)
{
int pix;
long p;
//Convert the coordinate into a pixel number.
map->angles2pixel(theta, phi, p);
pix = int(p);
// Process the pixel.
return selectPixel(pix);
}
/* ------------------------------------------------------------------------------------
'highlightPixels' adjusts the opacity of the selected pixels.
Arguments:
hlite - The opacity level to assign to the selected pixels.
Returned:
Nothing.
Written by Michael R. Greason, ADNET, 29 August 2007.
------------------------------------------------------------------------------------ */
void mainWindow::highlightPixels (double hlite)
{
for(int i = 0; i < ctl->numselected(); i ++ )
texture->highlite(ctl->pixnum(i), float(hlite));
}
void mainWindow::unselectPixels(std::vector<int> pixs)
{
for(uint i = 0; i < pixs.size(); i ++ )
texture->highlite(pixs[i], 1.0);
return;
}
/* ----------------------------------------------------------------------------
'recenterOnPixel' recenters the current view to be centered on the passed
pixel number. Slot to receive signal from double-clicking on the list
of selected pixels.
Arguments:
int pixnum: Pixel number to center on, assumed to index into the
current set sky map.
Returned:
None.
Written by Nicholas Phillips, 10/14/08
---------------------------------------------------------------------------- */
void mainWindow::recenterOnPixel(int pixnum)
{
double theta,phi;
map->pixel2angles(pixnum, theta, phi);
//viewer->recenterAt(cos(phi)*sin(theta),sin(phi)*sin(theta),cos(theta));
viewer->recenterAt(theta,phi);
return;
}