mainwindow.cpp

Go to the documentation of this file.
00001 /* ------------------------------------------------------------------------------------
00002 The definition of the main window class.
00003 
00004 Written by Nicholas Phillips.
00005 QT4 implementation.  Michael R. Greason, ADNET, 23 August 2007.
00006 ------------------------------------------------------------------------------------ */
00007 /*
00008                         Fetch header files.
00009 */
00010 #include <iostream>
00011 #include <stdio.h>
00012 #include <QMessageBox>
00013 #include <QFileDialog>
00014 #include <QFileInfo>
00015 #include <QWhatsThis>
00016 #include <QSize>
00017 #include "mainwindow.h"
00018 #include "controldialog.h"
00019 #include "rangecontrol.h"
00020 #include "debug.h"
00021 #include "outlog.h"
00022 
00023 using namespace std;
00024 /*
00025                         Constants.
00026 */
00027 const double WhiteRiggingRadius = 0.99;
00028 /* ====================================================================================
00029 'mainWindow' defines the main window.  It descends from QMainWindow and from the 
00030 Ui::MainWindow class that was created by QT Designer.
00031 
00032 NOTE:  The SkyViewer widget, which descends from QGLViewer, is NOT inserted into
00033 the window through QT Designer; it is explicitly inserted in the constructor of
00034 this class.
00035 ==================================================================================== */
00036 /* ------------------------------------------------------------------------------------
00037 The class constructor.
00038 
00039 Arguments:
00040         parent - The parent wiget/window.
00041 
00042 Written by Nicholas Phillips.
00043 QT4 implementation.  Michael R. Greason, ADNET, 23 August 2007.
00044 ------------------------------------------------------------------------------------ */
00045 mainWindow::mainWindow(QWidget *parent) : QMainWindow(parent)
00046 {
00047 /*
00048                         Initialize components.
00049 */
00050         map         = NULL;
00051         texture     = new SkyTexture;
00052         rigging     = new Rigging;
00053         whiterig    = new Rigging;
00054         polarsphere = new PolarArgLineSet;
00055 /*
00056                         Populate the window.
00057 */
00058         setupUi(this);
00059 
00060         viewer = new SkyViewer(centralwidget, this);
00061         viewer->setObjectName(QString::fromUtf8("viewer"));
00062         viewer->setGeometry(QRect(1, 0, 600, 591));
00063         viewer->setTexture(texture);
00064         viewer->setRigging(rigging);
00065         viewer->setWhiteRigging(whiterig);
00066         viewer->setPolarAngles(polarsphere);
00067         viewer->setFPSIsDisplayed(false);
00068 
00069         setWindowTitle(tr("Skyviewer"));
00070 
00071         filelabel = new QLabel("");
00072         filelabel->setMargin(2);
00073         filelabel->setMinimumWidth(150);
00074         filelabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
00075         viewerStatus->addWidget(filelabel);
00076 
00077         projlabel = new QLabel("Projection: 3D Sphere");
00078         projlabel->setMargin(2);
00079         projlabel->setMinimumWidth(150);
00080         projlabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
00081         viewerStatus->addWidget(projlabel);
00082 
00083         maplabel  = new QLabel("Map: Temperature");
00084         maplabel->setMargin(2);
00085         maplabel->setMinimumWidth(150);
00086         maplabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
00087         viewerStatus->addWidget(maplabel);
00088 
00089         if (! showpolar)
00090         {
00091                 actionPolarAnglesM->setDisabled(true);
00092                 actionPolarAnglesM->setVisible(false);
00093                 actionPolarAnglesTB->setDisabled(true);
00094                 actionPolarAnglesTB->setVisible(false);
00095         }
00096 /*
00097                         Create the progress and range control windows.
00098 */
00099 
00100         ctl = new ControlDialog(this);
00101         rngctl = ctl->getRangeControl();
00102 /*
00103                         Define the connections.
00104 */
00105         connect(actionOpen,              SIGNAL(activated()), this,   SLOT(fileLoad()));
00106         connect(actionReload,            SIGNAL(activated()), this,   SLOT(fileReload()));
00107         connect(actionNew,               SIGNAL(activated()), this,   SLOT(fileNew()));
00108         connect(actionSnapshot,          SIGNAL(activated()), this,   SLOT(fileSnapshot()));
00109         connect(actionClose,             SIGNAL(activated()), this,   SLOT(fileClose()));
00110         connect(actionExit,              SIGNAL(activated()), this,   SLOT(fileExit()));
00111 
00112         connect(action3D_Sphere_tb,      SIGNAL(activated()), this,   SLOT(proj3Dsphere()));
00113         connect(action3D_Sphere_m,       SIGNAL(activated()), this,   SLOT(proj3Dsphere()));
00114         connect(actionMollweide_tb,      SIGNAL(activated()), this,   SLOT(projMollweide()));
00115         connect(actionMollweide_m,       SIGNAL(activated()), this,   SLOT(projMollweide()));
00116 
00117         connect(actionTemperature,       SIGNAL(activated()), this,   SLOT(mapTemperature()));
00118         connect(actionQ_Polarization,    SIGNAL(activated()), this,   SLOT(mapQPolarization()));
00119         connect(actionU_Polarization,    SIGNAL(activated()), this,   SLOT(mapUPolarization()));
00120         connect(actionP_Polarization,    SIGNAL(activated()), this,   SLOT(mapPPolarization()));
00121         connect(actionNum_Obs,           SIGNAL(activated()), this,   SLOT(mapNumObs()));
00122 
00123         connect(actionPolarAnglesTB,     SIGNAL(activated()), this,   SLOT(mapPolVectTB()));
00124         connect(actionPolarAnglesM,      SIGNAL(activated()), this,   SLOT(mapPolVectM()));
00125 
00126 
00127         connect(actionHelp,              SIGNAL(activated()), viewer, SLOT(help()));
00128 
00129 
00130         connect(rngctl, SIGNAL(reTextureNeeded()),      this, SLOT(reTexture()));
00131         connect(rngctl, SIGNAL(changeProjRigging()),    this, SLOT(newRigging()));
00132         connect(rngctl, SIGNAL(changeFieldInfo()),      this, SLOT(newField()));
00133         connect(rngctl, SIGNAL(changePolVect()),        this, SLOT(newPolVect()));
00134 
00135         connect(ctl,    SIGNAL(resetPixels(std::vector<int>)),  this,   SLOT(unselectPixels(std::vector<int>)));
00136         connect(ctl,    SIGNAL(recenterOnPixel(int)),           this,   SLOT(recenterOnPixel(int)));
00137 /*
00138                         Remaining initialization.
00139 */
00140         QSize sz;
00141         sz = viewer->size();
00142         delta = size() - sz;
00143         viewmoll = false;
00144         action3D_Sphere_tb->setChecked(! viewmoll); 
00145         action3D_Sphere_m->setChecked(! viewmoll);
00146         actionMollweide_tb->setChecked(viewmoll); 
00147         actionMollweide_m->setChecked(viewmoll);
00148 
00149         rigging->generate (rngctl->getRigging(), viewmoll);
00150         whiterig->generate(rngctl->getRigging(), viewmoll, WhiteRiggingRadius);
00151         ctl->clearStatus();
00152         ctl->show();
00153         
00154 }
00155 /* ------------------------------------------------------------------------------------
00156 The class destructor.
00157 
00158 Arguments:
00159         None.
00160 
00161 Written by Michael R. Greason, ADNET, 23 August 2007.
00162 ------------------------------------------------------------------------------------ */
00163 mainWindow::~mainWindow(void)
00164 {
00165         if (map != NULL) delete map;
00166         map = NULL;
00167         if (texture != NULL) delete texture;
00168         texture = NULL;
00169         if (rigging != NULL) delete rigging;
00170         rigging = NULL;
00171         if (whiterig != NULL) delete whiterig;
00172         whiterig = NULL;
00173         if (polarsphere != NULL) delete polarsphere;
00174         polarsphere = NULL;
00175 }
00176 /* ------------------------------------------------------------------------------------
00177 'resizeEvent' responds to a resize event, telling the QGLviewer to change its
00178 size accordingly.
00179 
00180 Arguments:
00181         event - The event to process.
00182 
00183 Returned:
00184         Nothing.
00185 
00186 Written by Michael R. Greason, ADNET, 27 August 2007.
00187 ------------------------------------------------------------------------------------ */
00188 void mainWindow::resizeEvent(QResizeEvent *event)
00189 {
00190 /*
00191                         Adjust the size of the viewer.
00192 */
00193         viewer->resize(event->size() - delta);  
00194 /*
00195                         Give the parent class its shot at the event.
00196 */
00197         QMainWindow::resizeEvent(event);
00198 }
00199 /* ------------------------------------------------------------------------------------
00200 'readFile' reads a FITS file.  The name of the file is specified as either a null-
00201 terminated strinkg or as a QSTRING.  The internal filename is set and the work is
00202 passed off to the other version of this method that takes no arguments.
00203 
00204 Arguments:
00205         file - The name of the file.
00206 
00207 Returned:
00208         Nothing.
00209 
00210 Written by Michael R. Greason, ADNET, 24 August 2007.
00211 ------------------------------------------------------------------------------------ */
00212 void mainWindow::readFile (const char *file)
00213 {
00214         if (file == NULL) return;
00215         QString tmp = file;
00216         readFile(tmp);
00217 }
00218 void mainWindow::readFile (const QString file)
00219 {
00220         QString tmp;
00221         QFileInfo fi;
00222         if (file.length() <= 0) return;
00223         filename = file;
00224         fi.setFile(filename);
00225         tmp = fi.completeSuffix();
00226         tmp = (tmp.length() > 0) ? (fi.baseName() + tr(".") + tmp) : fi.baseName();
00227         filelabel->setText(tmp);
00228         ctl->startFile(tmp);
00229         readFile();
00230         //initMinMax();
00231 }
00232 /* ------------------------------------------------------------------------------------
00233 'readFile' reads a FITS file.  The name of the file is supplied through the internal
00234 filename variable.  This routine actually goes out and reads the file.
00235 
00236 Arguments:
00237         None.
00238 
00239 Returned:
00240         Nothing.
00241 
00242 Written by Michael R. Greason, ADNET, 24 August 2007.
00243 ------------------------------------------------------------------------------------ */
00244 void mainWindow::readFile ()
00245 {
00246         if (filename.length() <= 0) return;
00247 /*
00248                         Allocate space for the map.
00249 */
00250         if (map == NULL) map = new HealpixMap();
00251         if (map == NULL) 
00252         {
00253                 QMessageBox::critical(this, tr("Skyviewer"),
00254                         tr("Unable to allocate memory for the map!"),
00255                         QMessageBox::Ok);
00256                 return;
00257         }
00258 /*
00259                         Read the map.
00260 */
00261         try {
00262                 map->readFITS(filename, ctl);
00263         }
00264         catch (MapException &exc)
00265         {
00266                 QString msg(tr("Unable to read map: "));
00267                 QMessageBox::critical(this, tr("Skyviewer Load Error"),
00268                         (msg + filename + "\nError: " + exc.Message()),
00269                         QMessageBox::Ok);
00270                 return;
00271         }
00272         ctl->init(map);
00273         setFieldEnables();
00274         
00275 /*
00276                         Create the texture and polarization angle vectors (if needed).
00277 */
00278         if (showtex)
00279         {
00280                 try {
00281                         texture->set(map, rngctl);
00282                         viewer->update();
00283                 }
00284                 catch (MapException &exc)
00285                 {
00286                         QString msg(tr("Unable to read map: "));
00287                         QMessageBox::critical(this, tr("Skyviewer"),
00288                                 (exc.Comment() == NULL) ? (msg + filename) : tr(exc.Comment()),
00289                                 QMessageBox::Ok);
00290                         return;
00291                 }
00292         }
00293         if (showpolar && map->has_Polarization())
00294         {
00295                 if (polarsphere != NULL) polarsphere->set(map);
00296         }
00297 /*
00298                         Clear the list of selected pixels.  The window is taken care of at a lower
00299                         level (as the file is being read).
00300 */
00301 }
00302 /* ------------------------------------------------------------------------------------
00303 'undefined' is called when a response routine is currently not implemented.
00304 
00305 Arguments:
00306         None.
00307 
00308 Returned:
00309         Nothing.
00310 
00311 Written by Nicholas Phillips.
00312 QT4 implementation.  Michael R. Greason, ADNET, 23 August 2007.
00313 ------------------------------------------------------------------------------------ */
00314 void mainWindow::undefined()
00315 {
00316         QMessageBox::warning(this, tr("Skyviewer"),
00317                 tr("This feature has not yet been defined!"),
00318                 QMessageBox::Ok); 
00319 }
00320 /* ------------------------------------------------------------------------------------
00321 'fileNew' prompts the user to specify a new file to be displayed.
00322         To be openned in a new viewer window.
00323         Not implemented yet.
00324 
00325 Arguments:
00326         None.
00327 
00328 Returned:
00329         Nothing.
00330 
00331 Written by Nicholas Phillips.
00332 ------------------------------------------------------------------------------------ */
00333 void mainWindow::fileNew()
00334 {
00335         undefined();
00336 }
00337 /* ------------------------------------------------------------------------------------
00338 'fileLoad' prompts the user to specify a new file to be displayed.
00339 
00340 Arguments:
00341         None.
00342 
00343 Returned:
00344         Nothing.
00345 
00346 Written by Nicholas Phillips.
00347 QT4 implementation.  Michael R. Greason, ADNET, 23 August 2007.
00348 ------------------------------------------------------------------------------------ */
00349 void mainWindow::fileLoad()
00350 {
00351         QString dir(".");
00352         if (filename.length() > 0)
00353         {
00354                 QFileInfo fi(filename);
00355                 dir = fi.absolutePath();
00356         }
00357         QString fil = QFileDialog::getOpenFileName(this, tr("Open FITS File"),
00358                 dir, tr("FITS (*.fits);;Any(*)"));
00359         if (fil.length() <= 0) return;
00360         readFile(fil);
00361 }
00362 /* ------------------------------------------------------------------------------------
00363 'fileReload' causes the current file to be reloaded and redisplayed.
00364 
00365 Arguments:
00366         None.
00367 
00368 Returned:
00369         Nothing.
00370 
00371 Written by Nicholas Phillips.
00372 QT4 implementation.  Michael R. Greason, ADNET, 23 August 2007.
00373 ------------------------------------------------------------------------------------ */
00374 void mainWindow::fileReload()
00375 {
00376         readFile();
00377 }
00378 /* ------------------------------------------------------------------------------------
00379 'fileSnapshot' takes a snapshot of the current view.
00380 
00381 Arguments:
00382         None.
00383 
00384 Returned:
00385         Nothing.
00386 
00387 Written by Nicholas Phillips.
00388 QT4 implementation.  Michael R. Greason, ADNET, 23 August 2007.
00389 ------------------------------------------------------------------------------------ */
00390 void mainWindow::fileSnapshot()
00391 {
00392         //undefined();
00393         viewer->saveSnapshot(false);
00394 }
00395 /* ------------------------------------------------------------------------------------
00396 'fileClose' closes the current main window; if others are still open the application
00397 does not terminate.
00398 
00399 Arguments:
00400         None.
00401 
00402 Returned:
00403         Nothing.
00404 
00405 Written by Nicholas Phillips.
00406 QT4 implementation.  Michael R. Greason, ADNET, 23 August 2007.
00407 ------------------------------------------------------------------------------------ */
00408 void mainWindow::fileClose()
00409 {
00410         close();
00411 }
00412 /* ------------------------------------------------------------------------------------
00413 'fileExit' shuts down the application.
00414 
00415 Arguments:
00416         None.
00417 
00418 Returned:
00419         Nothing.
00420 
00421 Written by Nicholas Phillips.
00422 QT4 implementation.  Michael R. Greason, ADNET, 23 August 2007.
00423 ------------------------------------------------------------------------------------ */
00424 void mainWindow::fileExit()
00425 {
00426         QApplication::exit(0);
00427 }
00428 
00429 //=====================================================================================
00430 //                     Handle Changing the Projection/Rigging
00431 //=====================================================================================
00432 /* ------------------------------------------------------------------------------------
00433 'proj3Dsphere' 
00434 'projMollweide'
00435         responds to a change in choice of projection. rangeControl is told of the
00436         change. If it decides, it will signal a need to change the rigging
00437 
00438 
00439 Written by Nicholas Phillips.
00440 QT4 implementation.  Michael R. Greason, ADNET, 23 August 2007.
00441 Modified by NGP, 8/12/08
00442 ------------------------------------------------------------------------------------ */
00443 void mainWindow::proj3Dsphere()
00444 {
00445         if( rngctl->getProjection() == Spherical ) {
00446                 action3D_Sphere_tb->setChecked(true); 
00447                 action3D_Sphere_m->setChecked(true);
00448                 return;
00449         }
00450         rngctl->setProjection(Spherical);
00451 }
00452 void mainWindow::projMollweide()
00453 {
00454         if( rngctl->getProjection() == Mollweide ) {
00455                 actionMollweide_tb->setChecked(true); 
00456                 actionMollweide_m->setChecked(true);
00457                 return;
00458         }
00459         rngctl->setProjection(Mollweide);
00460 }
00461 /* ------------------------------------------------------------------------------------
00462 'newRigging' updates the viewer when the user requests a change in the rigging size.
00463 
00464 Arguments:
00465         None.
00466 
00467 Returned:
00468         Nothing.
00469 
00470 Written by Nicholas Phillips.
00471 QT4 implementation.  Michael R. Greason, ADNET, 23 August 2007.
00472 ------------------------------------------------------------------------------------ */
00473 void mainWindow::newRigging(void)
00474 {
00475         try {
00476                 viewmoll = rngctl->getProjection() == Mollweide;
00477                 viewer->constrainMollweide(viewmoll);
00478                 rigging->generate (rngctl->getRigging(), viewmoll);
00479                 whiterig->generate(rngctl->getRigging(), viewmoll, WhiteRiggingRadius);
00480                 polarsphere->setMollweide(viewmoll);
00481                 viewer->update();
00482         }
00483         catch (MapException &exc)
00484         {
00485                 const char *comm = exc.Comment();
00486                 QMessageBox::critical(this, tr("Skyviewer"),
00487                         tr((comm != NULL) ? comm : "newRigging error!"),
00488                         QMessageBox::Ok);
00489         }
00490         // Update GUI.
00491         action3D_Sphere_tb->setChecked(! viewmoll); 
00492         action3D_Sphere_m->setChecked(! viewmoll);
00493         actionMollweide_tb->setChecked(viewmoll); 
00494         actionMollweide_m->setChecked(viewmoll);
00495         projlabel->setText(viewmoll ? "Projection: Mollweide" : "Projection: 3D Sphere");
00496 
00497 }
00498 
00499 
00500 
00501 //=====================================================================================
00502 //                     Handle Changing the Display Map Field
00503 //=====================================================================================
00504 /* ------------------------------------------------------------------------------------
00505 'setFieldEnables' Set the ToolBar's Field selections enabled according to new map
00506 Arguments:
00507         None.
00508 Written by Nicholas Phillips.
00509 QT4 implementation.  Michael R. Greason, ADNET, 23 August 2007.
00510 Updated by NGP, 8/13/08
00511 ------------------------------------------------------------------------------------ */
00512 void mainWindow::setFieldEnables()
00513 {
00514         actionTemperature->setEnabled(map->has_Temperature());
00515         actionQ_Polarization->setEnabled(map->has_Polarization());
00516         actionU_Polarization->setEnabled(map->has_Polarization());
00517         actionP_Polarization->setEnabled(map->has_Polarization());
00518         actionNum_Obs->setEnabled(map->has_Nobs());
00519 
00520         actionPolarAnglesTB->setEnabled(map->has_Polarization());
00521         actionPolarAnglesM->setEnabled(map->has_Polarization());
00522 
00523         return;
00524 }
00525 /* ------------------------------------------------------------------------------------
00526 'mapTemperature'
00527 'mapQPolarization()'
00528 'mapUPolarization()'
00529 'mapPPolarization()'
00530 'mapNumObs()'
00531         Responds to changing the displayed map field action.
00532         rangeControl is told of the change and decides what to do.
00533 
00534 
00535 Written by Nicholas Phillips.
00536 QT4 implementation.  Michael R. Greason, ADNET, 23 August 2007.
00537 ------------------------------------------------------------------------------------ */
00538 void mainWindow::mapTemperature()       { rngctl->setField(I); }
00539 void mainWindow::mapQPolarization()     { rngctl->setField(Q); }
00540 void mainWindow::mapUPolarization()     { rngctl->setField(U); }
00541 void mainWindow::mapPPolarization()     { rngctl->setField(P); }
00542 void mainWindow::mapNumObs()            { rngctl->setField(Nobs); }
00543 /* ------------------------------------------------------------------------------------
00544 'newField()'
00545         Update the GUI to reflect the state of the displayed field based on the
00546         state of rangeControl
00547 
00548 Written by Nicholas Phillips, 8/13/08
00549 ------------------------------------------------------------------------------------ */
00550 void mainWindow::newField()
00551 {
00552         actionTemperature->setChecked(false);
00553         actionQ_Polarization->setChecked(false);
00554         actionU_Polarization->setChecked(false);
00555         actionP_Polarization->setChecked(false);
00556         actionNum_Obs->setChecked(false);
00557         switch( rngctl->getField() ) {
00558                 case I:
00559                         actionTemperature->setChecked(true);
00560                         maplabel->setText(tr("Map: Temperature"));
00561                         break;
00562                 case Q:
00563                         actionQ_Polarization->setChecked(true);
00564                         maplabel->setText(tr("Map: Q Polarization"));
00565                         break;
00566                 case U:
00567                         actionU_Polarization->setChecked(true);
00568                         maplabel->setText(tr("Map: U Polarization"));
00569                         break;
00570                 case P:
00571                         actionP_Polarization->setChecked(true);
00572                         maplabel->setText(tr("Map: P Polarization"));
00573                         break;
00574                 case Nobs:
00575                         actionNum_Obs->setChecked(true);
00576                         maplabel->setText(tr("Map: Num Obs"));
00577                         break;
00578         }
00579         return;
00580 }
00581 //=====================================================================================
00582 /* ------------------------------------------------------------------------------------
00583 'mapPolVectM' and 'mapPolVectTB' toggle the polarization vectors on and off.
00584 
00585 Arguments:
00586         None.
00587 
00588 Returned:
00589         Nothing.
00590 
00591 Written by Nicholas Phillips.
00592 QT4 implementation.  Michael R. Greason, ADNET, 30 August 2007.
00593 ------------------------------------------------------------------------------------ */
00594 void mainWindow::mapPolVectM()
00595 {
00596         rngctl->setPolarVect(actionPolarAnglesM->isChecked() ? On : Off );
00597 }
00598 void mainWindow::mapPolVectTB()
00599 {
00600         rngctl->setPolarVect(actionPolarAnglesTB->isChecked() ? On : Off );
00601 }
00602 /* ------------------------------------------------------------------------------------
00603 'newPolVect' Responds to rangeDialog indicating a change in state of displaying
00604                 the polarization vectors.
00605 
00606 Written by Nicholas Phillips, 8/13/08
00607 ------------------------------------------------------------------------------------ */
00608 void mainWindow::newPolVect()
00609 {
00610         bool b = rngctl->getPolVect() == On;
00611         actionPolarAnglesTB->setChecked(b);
00612         actionPolarAnglesM->setChecked(b);
00613         if (polarsphere != NULL) polarsphere->setOn(b);
00614 }
00615 //=====================================================================================
00616 /* ------------------------------------------------------------------------------------
00617 'reTexture'  updates the map texture and instructs the viewer to repaint itself.
00618 
00619 This routine should be called when something occurs to modify the texture.
00620 
00621 Arguments:
00622         None.
00623 
00624 Returned:
00625         Nothing.
00626 
00627 Written Michael R. Greason, ADNET, 23 August 2007.
00628 ------------------------------------------------------------------------------------ */
00629 void mainWindow::reTexture(void)
00630 {
00631         if (! showtex) return;
00632         try {
00633                 texture->set(map, rngctl);
00634                 viewer->update();
00635         }
00636         catch (MapException &exc)
00637         {
00638                 const char *comm = exc.Comment();
00639                 QMessageBox::critical(this, tr("Skyviewer"),
00640                         tr((comm != NULL) ? comm : "reTextureOld error!"),
00641                         QMessageBox::Ok);
00642         }
00643 }
00644 //=====================================================================================
00645 /* ------------------------------------------------------------------------------------
00646 'selectPixel' responds to the selection of a pixel in the viewer.  This version gets
00647 the pixel to process from its arguments.
00648 
00649 Arguments:
00650         pix - The pixel to process
00651 
00652 Returned:
00653         pix - The pixel id.
00654 
00655 Written by Michael R. Greason, ADNET, 29 August 2007.
00656 ------------------------------------------------------------------------------------ */
00657 int mainWindow::selectPixel (int pix)
00658 {
00659         if( ! ctl->selectPixel(pix,&((*map)[pix])) ) {
00660                 texture->highlite(pix, 1.0);
00661         }
00662         if ( ctl->numselected() <= 0) {
00663                 if (viewer->animationIsStarted()) viewer->stopAnimation();
00664         }
00665         else {
00666                 if (! viewer->animationIsStarted()) viewer->startAnimation();
00667         }
00668         viewer->update();
00669         return pix;
00670 }
00671 /* ------------------------------------------------------------------------------------
00672 'selectPixel' responds to the selection of a pixel in the viewer.  This version
00673 converts the coordinates into a pixel id and passes execution to the other version.
00674 
00675 Arguments:
00676         theta - The colatitude of the selected pixel, in radians, measured from the
00677                  North Pole.
00678         phi   - The longitude of the selected pixel, in radians.
00679 
00680 Returned:
00681         pix   - The pixel id.
00682 
00683 Written by Michael R. Greason, ADNET, 29 August 2007.
00684 ------------------------------------------------------------------------------------ */
00685 int mainWindow::selectPixel (double theta, double phi)
00686 {
00687         int pix;
00688         long p;
00689 
00690         //Convert the coordinate into a pixel number.
00691         map->angles2pixel(theta, phi, p);
00692         pix = int(p);
00693 
00694         // Process the pixel.
00695         return selectPixel(pix);
00696 }
00697 /* ------------------------------------------------------------------------------------
00698 'highlightPixels' adjusts the opacity of the selected pixels.
00699 
00700 Arguments:
00701         hlite - The opacity level to assign to the selected pixels.
00702 
00703 Returned:
00704         Nothing.
00705 
00706 Written by Michael R. Greason, ADNET, 29 August 2007.
00707 ------------------------------------------------------------------------------------ */
00708 void mainWindow::highlightPixels (double hlite)
00709 {
00710         for(int i = 0; i < ctl->numselected(); i ++ )
00711                 texture->highlite(ctl->pixnum(i), float(hlite));
00712 }
00713 void mainWindow::unselectPixels(std::vector<int> pixs)
00714 {
00715         for(uint i = 0; i < pixs.size(); i ++ )
00716                 texture->highlite(pixs[i], 1.0);
00717         return;
00718 }
00719 /* ----------------------------------------------------------------------------
00720 'recenterOnPixel' recenters the current view to be centered on the passed
00721         pixel number. Slot to receive signal from double-clicking on the list
00722         of selected pixels.
00723 
00724 Arguments:
00725         int pixnum: Pixel number to center on, assumed to index into the
00726                         current set sky map.
00727 
00728 Returned:
00729         None.
00730 
00731 Written by Nicholas Phillips, 10/14/08
00732 ---------------------------------------------------------------------------- */
00733 void mainWindow::recenterOnPixel(int pixnum)
00734 {
00735         double theta,phi;
00736         map->pixel2angles(pixnum, theta, phi);
00737         //viewer->recenterAt(cos(phi)*sin(theta),sin(phi)*sin(theta),cos(theta));
00738         viewer->recenterAt(theta,phi);
00739         return;
00740 }

Generated on Fri Feb 6 15:32:42 2009 for Skyviewer by  doxygen 1.4.7