~guillaume-chereau/stellarium/fix-orbits

« back to all changes in this revision

Viewing changes to src/gui/SearchDialog.cpp

  • Committer: Guillaume Chereau
  • Date: 2017-01-03 00:38:49 UTC
  • mfrom: (8528.1.525 trunk)
  • Revision ID: guillaume@noctua-software.com-20170103003849-cgf0w0doticpzzff
Merge branch 'stellarium' into fix-orbits

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "StelLocaleMgr.hpp"
28
28
#include "StelTranslator.hpp"
29
29
#include "Planet.hpp"
 
30
#include "CustomObjectMgr.hpp"
30
31
 
31
32
#include "StelObjectMgr.hpp"
32
33
#include "StelGui.hpp"
129
130
SearchDialog::SearchDialogStaticData SearchDialog::staticData;
130
131
QString SearchDialog::extSearchText = "";
131
132
 
132
 
SearchDialog::SearchDialog(QObject* parent) : StelDialog(parent), simbadReply(NULL)
 
133
SearchDialog::SearchDialog(QObject* parent)
 
134
        : StelDialog(parent)
 
135
        , simbadReply(NULL)
133
136
{
134
137
        dialogName = "Search";
135
138
        ui = new Ui_searchDialogForm;
142
145
        conf = StelApp::getInstance().getSettings();
143
146
        useSimbad = conf->value("search/flag_search_online", true).toBool();    
144
147
        useStartOfWords = conf->value("search/flag_start_words", false).toBool();
 
148
        useLockPosition = conf->value("search/flag_lock_position", true).toBool();
145
149
        simbadServerUrl = conf->value("search/simbad_server_url", DEF_SIMBAD_URL).toString();
146
150
        setCurrentCoordinateSystemKey(conf->value("search/coordinate_system", "equatorialJ2000").toString());
147
151
}
209
213
        csys->addItem(qc_("Equatorial", "coordinate system"), "equatorial");
210
214
        csys->addItem(qc_("Horizontal", "coordinate system"), "horizontal");
211
215
        csys->addItem(qc_("Galactic", "coordinate system"), "galactic");
 
216
        csys->addItem(qc_("Supergalactic", "coordinate system"), "supergalactic");
212
217
        csys->addItem(qc_("Ecliptic", "coordinate system"), "ecliptic");
213
218
        csys->addItem(qc_("Ecliptic (J2000.0)", "coordinate system"), "eclipticJ2000");
214
219
 
261
266
                case ecliptic:
262
267
                case eclipticJ2000:
263
268
                case galactic:
 
269
                case supergalactic:
264
270
                {
265
271
                        ui->AxisXLabel->setText(q_("Longitude"));
266
272
                        ui->AxisXSpinBox->setDisplayFormat(AngleSpinBox::DMSSymbolsUnsigned);
361
367
        connect(ui->psiPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked()));
362
368
        connect(ui->omegaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked()));
363
369
 
364
 
        connect(ui->checkBoxUseSimbad, SIGNAL(clicked(bool)), this, SLOT(enableSimbadSearch(bool)));
365
 
        ui->checkBoxUseSimbad->setChecked(useSimbad);
 
370
        connect(ui->simbadGroupBox, SIGNAL(clicked(bool)), this, SLOT(enableSimbadSearch(bool)));
 
371
        ui->simbadGroupBox->setChecked(useSimbad);
366
372
 
367
373
        populateSimbadServerList();
368
374
        idx = ui->serverListComboBox->findData(simbadServerUrl, Qt::UserRole, Qt::MatchCaseSensitive);
377
383
        connect(ui->checkBoxUseStartOfWords, SIGNAL(clicked(bool)), this, SLOT(enableStartOfWordsAutofill(bool)));
378
384
        ui->checkBoxUseStartOfWords->setChecked(useStartOfWords);
379
385
 
 
386
        connect(ui->checkBoxLockPosition, SIGNAL(clicked(bool)), this, SLOT(enableLockPosition(bool)));
 
387
        ui->checkBoxLockPosition->setChecked(useLockPosition);
 
388
 
380
389
        // list views initialization
381
390
        connect(ui->objectTypeComboBox, SIGNAL(activated(int)), this, SLOT(updateListWidget(int)));
382
391
        connect(ui->searchInListLineEdit, SIGNAL(textChanged(QString)), this, SLOT(searchListChanged(QString)));
406
415
        conf->setValue("search/flag_start_words", useStartOfWords);
407
416
}
408
417
 
 
418
void SearchDialog::enableLockPosition(bool enable)
 
419
{
 
420
        useLockPosition = enable;
 
421
        conf->setValue("search/flag_lock_position", useLockPosition);
 
422
}
 
423
 
409
424
void SearchDialog::setSimpleStyle()
410
425
{
411
426
        ui->AxisXSpinBox->setVisible(false);
490
505
                        }
491
506
                        break;
492
507
                }
 
508
                case supergalactic:
 
509
                {
 
510
                        StelUtils::spheToRect(spinLong, spinLat, pos);
 
511
                        pos = core->supergalacticToJ2000(pos);
 
512
                        if ( (mountMode==StelMovementMgr::MountSupergalactic) && (fabs(spinLat)> (0.9*M_PI/2.0)) )
 
513
                        {
 
514
                                // make up vector more stable.
 
515
                                mvmgr->setViewUpVector(Vec3d(-cos(spinLong), -sin(spinLong), 0.) * (spinLat>0. ? 1. : -1. ));
 
516
                                aimUp=mvmgr->getViewUpVectorJ2000();
 
517
                        }
 
518
                        break;
 
519
                }
493
520
                case eclipticJ2000:
494
521
                {
495
522
                        double ra, dec;
508
535
        }
509
536
        mvmgr->setFlagTracking(false);
510
537
        mvmgr->moveToJ2000(pos, aimUp, 0.05);
 
538
        mvmgr->setFlagLockEquPos(useLockPosition);
511
539
}
512
540
 
513
541
void SearchDialog::onSearchTextChanged(const QString& text)
640
668
        StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementMgr);
641
669
        if (simbadResults.contains(nameI18n))
642
670
        {
643
 
                close();
644
 
                Vec3d pos = simbadResults[nameI18n];
645
 
                Vec3d aimUp;
646
 
                objectMgr->unSelect();
647
 
                mvmgr->setViewUpVector(Vec3d(0., 0., 1.));
648
 
                aimUp=mvmgr->getViewUpVectorJ2000();
649
 
                mvmgr->moveToJ2000(pos, aimUp, mvmgr->getAutoMoveDuration());
650
 
                ui->lineEditSearchSkyObject->clear();
651
 
                ui->completionLabel->clearValues();
 
671
                if (objectMgr->findAndSelect(nameI18n))
 
672
                {
 
673
                        const QList<StelObjectP> newSelected = objectMgr->getSelectedObject();
 
674
                        if (!newSelected.empty())
 
675
                        {
 
676
                                close();
 
677
                                ui->lineEditSearchSkyObject->clear();
 
678
                                ui->completionLabel->clearValues();
 
679
                                // Can't point to home planet
 
680
                                if (newSelected[0]->getEnglishName()!=StelApp::getInstance().getCore()->getCurrentLocation().planetName)
 
681
                                {
 
682
                                        mvmgr->moveToObject(newSelected[0], mvmgr->getAutoMoveDuration());
 
683
                                        mvmgr->setFlagTracking(true);
 
684
                                }
 
685
                                else
 
686
                                {
 
687
                                        GETSTELMODULE(StelObjectMgr)->unSelect();
 
688
                                }
 
689
                        }
 
690
                }
 
691
                else
 
692
                {
 
693
                        close();
 
694
                        GETSTELMODULE(CustomObjectMgr)->addCustomObject(nameI18n, simbadResults[nameI18n]);
 
695
                        ui->lineEditSearchSkyObject->clear();
 
696
                        ui->completionLabel->clearValues();
 
697
                        if (objectMgr->findAndSelect(nameI18n))
 
698
                        {
 
699
                                const QList<StelObjectP> newSelected = objectMgr->getSelectedObject();
 
700
                                // Can't point to home planet
 
701
                                if (newSelected[0]->getEnglishName()!=StelApp::getInstance().getCore()->getCurrentLocation().planetName)
 
702
                                {
 
703
                                        mvmgr->moveToObject(newSelected[0], mvmgr->getAutoMoveDuration());
 
704
                                        mvmgr->setFlagTracking(true);
 
705
                                }
 
706
                                else
 
707
                                {
 
708
                                        GETSTELMODULE(StelObjectMgr)->unSelect();
 
709
                                }
 
710
                        }
 
711
                }
652
712
        }
653
713
        else if (objectMgr->findAndSelectI18n(nameI18n) || objectMgr->findAndSelect(nameI18n))
654
714
        {