Commit 3aedf672 authored by Akarsh Simha's avatar Akarsh Simha

Prepare CatalogComponent to be sub-classed.

1. Make private members protected.

2. Make loadData() and selected() virtual

3. Add a parameter to the constructor that enables / disables the
   calling of loadData() at construct time.

4. Make loadData() a proxy for a protected method _loadData( bool )
   that actually loads the data.

5. Make provisions for having "fake" catalogs, where the catalog name
   and ID are not official and should not be used as names.
parent 26d87871
......@@ -40,24 +40,29 @@ QStringList CatalogComponent::m_Columns
CatalogComponent::CatalogComponent(SkyComposite *parent,
const QString &catname,
bool showerrs, int index)
bool showerrs, int index, bool callLoadData )
: ListComponent(parent), m_catName(catname),
m_Showerrs(showerrs), m_ccIndex(index) {
loadData();
if( callLoadData )
loadData();
}
CatalogComponent::~CatalogComponent() {
}
void CatalogComponent::loadData() {
emitProgressText( i18n("Loading custom catalog: %1", m_catName ) );
void CatalogComponent::_loadData( bool includeCatalogDesignation ) {
if( includeCatalogDesignation )
emitProgressText( i18n("Loading custom catalog: %1", m_catName ) );
else
emitProgressText( i18n("Loading internal catalog: %1", m_catName ) );
QList < QPair <int, QString> > names;
KStarsData::Instance()->catalogdb()->GetAllObjects(m_catName,
m_ObjectList,
names,
this);
this,
includeCatalogDesignation);
for (int iter = 0; iter < names.size(); iter++) {
if (names.at(iter).first <= SkyObject::TYPE_UNKNOWN) {
//FIXME JM 2016-06-02: inefficient and costly check
......@@ -124,6 +129,7 @@ void CatalogComponent::draw( SkyPainter *skyp ) {
update( 0 );
//Draw Custom Catalog objects
// FIXME: Improve using HTM!
foreach ( SkyObject *obj, m_ObjectList ) {
if ( obj->type()==0 ) {
StarObject *starobj = static_cast<StarObject*>(obj);
......@@ -136,6 +142,8 @@ void CatalogComponent::draw( SkyPainter *skyp ) {
// PA for Deep-Sky objects is 90 + PA because major axis is
// horizontal at PA=0
// double pa = 90. + map->findPA( dso, o.x(), o.y() );
//
// ^ Not sure if above is still valid -- asimha 2016/08/16
DeepSkyObject *dso = static_cast<DeepSkyObject*>(obj);
skyp->drawDeepSkyObject(dso, true);
}
......
......@@ -44,7 +44,7 @@ public:
*@short Constructor
*@p parent Pointer to the parent SkyComposite object
*/
CatalogComponent( SkyComposite*, const QString &fname, bool showerrs, int index );
CatalogComponent( SkyComposite*, const QString &fname, bool showerrs, int index, bool callLoadData = true );
/**
*@short Destructor. Delete list members
......@@ -77,19 +77,24 @@ public:
*/
inline bool getVisibility() { return (Options::showCatalog()[m_ccIndex] > 0) ? true : false; }
private:
protected:
/** @short Load data into custom catalog */
void loadData();
virtual void loadData() { _loadData( true ); }
/** @short Load data into custom catalog */
virtual void _loadData( bool includeCatalogDesignation );
// FIXME: There seems to be no way to remove catalogs from the program. -- asimha
// FIXME: There is no way to remove catalogs from the program.
/**
* @brief Returns true if this catalog is to be drawn
* Overridden from SkyComponent::selected
* @return bool
**/
bool selected();
virtual bool selected();
QString m_catName, m_catPrefix, m_catColor, m_catFluxFreq, m_catFluxUnit;
float m_catEpoch;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment