~ubuntu-branches/debian/experimental/stellarium/experimental

« back to all changes in this revision

Viewing changes to src/core/modules/NebulaMgr.cpp

  • Committer: Package Import Robot
  • Author(s): Tomasz Buchert
  • Date: 2013-04-23 18:31:29 UTC
  • mfrom: (1.2.11)
  • Revision ID: package-import@ubuntu.com-20130423183129-u1bus3c87vywlmku
Tags: 0.12.1-1
* Imported Upstream version 0.12.1
* Installing icons provided by upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
        void operator()(StelRegionObject* obj)
130
130
        {
131
131
                Nebula* n = static_cast<Nebula*>(obj);
 
132
                StelSkyDrawer *drawer = core->getSkyDrawer();
 
133
                // filter out DSOs which are too dim to be seen (e.g. for bino observers)
 
134
                if ((drawer->getFlagNebulaMagnitudeLimit()) && (n->mag > drawer->getCustomNebulaMagnitudeLimit())) return;
 
135
 
132
136
                if (n->angularSize>angularSizeLimit || (checkMaxMagHints && n->mag <= maxMagHints))
133
137
                {
134
138
                        float refmag_add=0; // value to adjust hints visibility threshold.
161
165
        const SphericalRegionP& p = prj->getViewportConvexPolygon(margin, margin);
162
166
 
163
167
        // Print all the nebulae of all the selected zones
164
 
        float maxMagHints = skyDrawer->getLimitMagnitude()*1.2f-2.f+(hintsAmount*1.2f)-2.f;
165
 
        float maxMagLabels = skyDrawer->getLimitMagnitude()-2.f+(labelsAmount*1.2f)-2.f;
 
168
        float maxMagHints  = skyDrawer->getLimitMagnitude()*1.2f-2.f+(hintsAmount *1.2f)-2.f;
 
169
        float maxMagLabels = skyDrawer->getLimitMagnitude()     -2.f+(labelsAmount*1.2f)-2.f;
166
170
        
167
171
        renderer->setFont(nebulaFont);
168
172
        nebulaHintTextures.lazyInit(renderer);
176
180
        }
177
181
}
178
182
 
 
183
// Draw the pointer around the object if selected
179
184
void NebulaMgr::drawPointer(const StelCore* core, StelRenderer* renderer)
180
185
{
181
186
        const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
243
248
        }
244
249
 
245
250
        // If no match found, try search by catalog reference
246
 
        static QRegExp catNumRx("^(M|NGC|IC)\\s*(\\d+)$");
 
251
        static QRegExp catNumRx("^(M|NGC|IC|C)\\s*(\\d+)$");
247
252
        if (catNumRx.exactMatch(uname))
248
253
        {
249
254
                QString cat = catNumRx.capturedTexts().at(1);
252
257
                if (cat == "M") return searchM(num);
253
258
                if (cat == "NGC") return searchNGC(num);
254
259
                if (cat == "IC") return searchIC(num);
 
260
                if (cat == "C") return searchC(num);
255
261
        }
256
262
        return NebulaP();
257
263
}
336
342
        return NebulaP();
337
343
}
338
344
 
 
345
NebulaP NebulaMgr::searchC(unsigned int C)
 
346
{
 
347
        foreach (const NebulaP& n, nebArray)
 
348
                if (n->C_nb == C)
 
349
                        return n;
 
350
        return NebulaP();
 
351
}
 
352
 
 
353
 
339
354
#if 0
340
355
// read from stream
341
356
bool NebulaMgr::loadNGCOld(const QString& catNGC)
459
474
                {
460
475
                        // If the name is not a messier number perhaps one is already
461
476
                        // defined for this object
462
 
                        if (name.left(2).toUpper() != "M ")
 
477
                        if (name.left(2).toUpper() != "M " && name.left(2).toUpper() != "C ")
463
478
                        {
464
479
                                if (transRx.exactMatch(name)) {
465
480
                                        e->englishName = transRx.capturedTexts().at(1).trimmed();
469
484
                                        e->englishName = name;
470
485
                                }
471
486
                        }
472
 
                        else
 
487
                        else if (name.left(2).toUpper() != "M " && name.left(2).toUpper() == "C ")
 
488
                        {
 
489
                                // If it's a caldwellnumber, we will call it a caldwell if there is no better name
 
490
                                name = name.mid(2); // remove "C "
 
491
 
 
492
                                // read the Caldwell number
 
493
                                QTextStream istr(&name);
 
494
                                int num;
 
495
                                istr >> num;
 
496
                                if (istr.status()!=QTextStream::Ok)
 
497
                                {
 
498
                                        qWarning() << "cannot read Caldwell number at line" << lineNumber << "of" << catNGCNames;
 
499
                                        continue;
 
500
                                }
 
501
 
 
502
                                e->C_nb=(unsigned int)(num);
 
503
                                e->englishName = QString("C%1").arg(num);
 
504
                        }
 
505
                        else if (name.left(2).toUpper() == "M " && name.left(2).toUpper() != "C ")
473
506
                        {
474
507
                                // If it's a messiernumber, we will call it a messier if there is no better name
475
508
                                name = name.mid(2); // remove "M "
488
521
                                e->englishName = QString("M%1").arg(num);
489
522
                        }
490
523
 
 
524
 
491
525
                        readOk++;
492
526
                }
493
527
                else
541
575
                }
542
576
        }
543
577
 
 
578
        // Search by Caldwell numbers (possible formats are "C31" or "C 31")
 
579
        if (objw.mid(0, 1) == "C")
 
580
        {
 
581
                foreach (const NebulaP& n, nebArray)
 
582
                {
 
583
                        if (QString("C%1").arg(n->C_nb) == objw || QString("C %1").arg(n->C_nb) == objw)
 
584
                                return qSharedPointerCast<StelObject>(n);
 
585
                }
 
586
        }
 
587
 
544
588
        return StelObjectP();
545
589
}
546
590
 
579
623
                }
580
624
        }
581
625
 
 
626
        // Search by Caldwell numbers (possible formats are "C31" or "C 31")
 
627
        if (objw.mid(0, 1) == "C")
 
628
        {
 
629
                foreach (const NebulaP& n, nebArray)
 
630
                {
 
631
                        if (QString("C%1").arg(n->C_nb) == objw || QString("C %1").arg(n->C_nb) == objw)
 
632
                                return qSharedPointerCast<StelObject>(n);
 
633
                }
 
634
        }
 
635
 
582
636
        return NULL;
583
637
}
584
638
 
628
682
                        result << constw;
629
683
        }
630
684
 
 
685
        // Search by caldwell objects number (possible formats are "C31" or "C 31")
 
686
        if (objw.size()>=1 && objw[0]=='C')
 
687
        {
 
688
                foreach (const NebulaP& n, nebArray)
 
689
                {
 
690
                        if (n->C_nb==0) continue;
 
691
                        QString constw = QString("C%1").arg(n->C_nb);
 
692
                        QString constws = constw.mid(0, objw.size());
 
693
                        if (constws==objw)
 
694
                        {
 
695
                                result << constw;
 
696
                                continue;       // Prevent adding both forms for name
 
697
                        }
 
698
                        constw = QString("C %1").arg(n->C_nb);
 
699
                        constws = constw.mid(0, objw.size());
 
700
                        if (constws==objw)
 
701
                                result << constw;
 
702
                }
 
703
        }
 
704
 
631
705
        // Search by common names
632
706
        foreach (const NebulaP& n, nebArray)
633
707
        {
642
716
        return result;
643
717
}
644
718
 
 
719
//! Find and return the list of at most maxNbItem objects auto-completing the passed object English name
 
720
QStringList NebulaMgr::listMatchingObjects(const QString& objPrefix, int maxNbItem) const
 
721
{
 
722
        QStringList result;
 
723
        if (maxNbItem==0) return result;
 
724
 
 
725
        QString objw = objPrefix.toUpper();
 
726
 
 
727
        // Search by messier objects number (possible formats are "M31" or "M 31")
 
728
        if (objw.size()>=1 && objw[0]=='M')
 
729
        {
 
730
                foreach (const NebulaP& n, nebArray)
 
731
                {
 
732
                        if (n->M_nb==0) continue;
 
733
                        QString constw = QString("M%1").arg(n->M_nb);
 
734
                        QString constws = constw.mid(0, objw.size());
 
735
                        if (constws==objw)
 
736
                        {
 
737
                                result << constw;
 
738
                                continue;       // Prevent adding both forms for name
 
739
                        }
 
740
                        constw = QString("M %1").arg(n->M_nb);
 
741
                        constws = constw.mid(0, objw.size());
 
742
                        if (constws==objw)
 
743
                                result << constw;
 
744
                }
 
745
        }
 
746
 
 
747
        // Search by NGC numbers (possible formats are "NGC31" or "NGC 31")
 
748
        foreach (const NebulaP& n, nebArray)
 
749
        {
 
750
                if (n->NGC_nb==0) continue;
 
751
                QString constw = QString("NGC%1").arg(n->NGC_nb);
 
752
                QString constws = constw.mid(0, objw.size());
 
753
                if (constws==objw)
 
754
                {
 
755
                        result << constw;
 
756
                        continue;
 
757
                }
 
758
                constw = QString("NGC %1").arg(n->NGC_nb);
 
759
                constws = constw.mid(0, objw.size());
 
760
                if (constws==objw)
 
761
                        result << constw;
 
762
        }
 
763
 
 
764
        // Search by caldwell objects number (possible formats are "C31" or "C 31")
 
765
        if (objw.size()>=1 && objw[0]=='C')
 
766
        {
 
767
                foreach (const NebulaP& n, nebArray)
 
768
                {
 
769
                        if (n->C_nb==0) continue;
 
770
                        QString constw = QString("C%1").arg(n->C_nb);
 
771
                        QString constws = constw.mid(0, objw.size());
 
772
                        if (constws==objw)
 
773
                        {
 
774
                                result << constw;
 
775
                                continue;       // Prevent adding both forms for name
 
776
                        }
 
777
                        constw = QString("C %1").arg(n->C_nb);
 
778
                        constws = constw.mid(0, objw.size());
 
779
                        if (constws==objw)
 
780
                                result << constw;
 
781
                }
 
782
        }
 
783
 
 
784
        // Search by common names
 
785
        foreach (const NebulaP& n, nebArray)
 
786
        {
 
787
                QString constw = n->englishName.mid(0, objw.size()).toUpper();
 
788
                if (constw==objw)
 
789
                        result << n->englishName;
 
790
        }
 
791
 
 
792
        result.sort();
 
793
        if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, result.end());
 
794
 
 
795
        return result;
 
796
}
 
797