Commit 77353288 authored by Samikshan Bairagya's avatar Samikshan Bairagya

Followed naming conventions. Hope I did not miss any. Removed redundant code in places.

parent e8737265
......@@ -53,10 +53,6 @@ void ModelManager::updateModels()
{
KStarsData *data = KStarsData::Instance();
//double TLM = obsconditions->getTrueMagLim();
baseCatList << "Planets" << "Stars" << "Constellations" << "Deep-sky Objects" ;
deepSkyList << "Galaxies" << "Clusters" << "Nebulae";
KSFileReader fileReader;
if ( !fileReader.open("Interesting.dat") ) return;
......@@ -70,12 +66,10 @@ void ModelManager::updateModels()
{
if (o->type() == 3 || o->type() == 4 || o->type() == 14 )
{
kDebug()<<"Cluster object";
initobjects["Cluster"].append(o);
}
else if (o->type() == 5 || o->type() == 6 || o->type() == 15)
{
kDebug()<<"Nebulae object";
initobjects["Nebula"].append(o);
}
else
......@@ -117,7 +111,6 @@ void ModelManager::updateModels()
foreach(SkyObject *so, initobjects.value("Cluster"))
{
kDebug()<<"Cluster object"<<so->name()<<so->typeName();
if (obsconditions->isVisible(data->geo(), data->lst(), so))
{
clustModel->addSkyObject(new SkyObjItem(so));
......@@ -133,7 +126,7 @@ void ModelManager::updateModels()
}
}
foreach ( const QString &name, data->skyComposite()->objectNames( SkyObject::PLANET ) )
foreach ( const QString &name, data->skyComposite()->objectNames( SkyObject::PLANET ))
{
SkyObject *so = data->skyComposite()->findByName( name );
//kDebug()<<so->name()<<so->mag();
......@@ -141,6 +134,7 @@ void ModelManager::updateModels()
{
// SkyObjectItem *planetItem = new SkyObjectItem(o);
// planetItem->setText(o->name());
if (so->name() == "Sun") continue;
planetsModel->addSkyObject(new SkyObjItem(so));
}
}
......@@ -150,19 +144,19 @@ SkyObjListModel* ModelManager::returnModel(int type)
{
switch(type)
{
case 0:
case 0: //Planet type
return planetsModel;
case 1:
case 1: //Star type
return starsModel;
case 2:
case 2: //Constellation type
return conModel;
case 3:
case 3: //Galaxy Type
return galModel;
case 4:
case 4: //Cluster type
return clustModel;
case 5:
case 5: //Nebula type
return nebModel;
default:
return (new SkyObjListModel());
return 0;
}
}
......@@ -15,7 +15,6 @@
* *
***************************************************************************/
//#include <QStandardItemModel>
#include "skyobjlistmodel.h"
#include "kstarsdata.h"
#include "obsconditions.h"
......@@ -23,7 +22,6 @@
class ModelManager
{
public:
enum LIST_TYPE { BaseList, DeepSkyObjects, Planets, Stars, Galaxies, Constellations, Clusters, Nebulae };
ModelManager(ObsConditions *obs);
~ModelManager();
void updateModels();
......@@ -34,5 +32,5 @@ private:
ObsConditions *obsconditions;
SkyObjListModel *planetsModel, *starsModel, *galModel, *conModel, *clustModel, *nebModel;
QStringList baseCatList, planetaryList, deepSkyList;
QHash < QString , QList < SkyObject * > > initobjects;
QHash < QString, QList <SkyObject *> > initobjects;
};
......@@ -19,22 +19,17 @@
#include "math.h"
#include "kdebug.h"
ObsConditions::ObsConditions(int bortle, Equipment eq, double ap, EquipmentType tp)
ObsConditions::ObsConditions(int bortle, double aperture, Equipment equip, EquipmentType eqType):
m_BortleClass(bortle), m_Aperture(aperture), m_Equip(equip), m_EqType(eqType)
{
bortleClass = bortle;
equip = eq;
aperture = ap;
// 't' parameter
switch ( type = tp )
switch ( m_EqType )
{
case Reflector:
t = 0.7;
m_tParam = 0.7;
break;
case Refractor:
t = 0.9;
break;
default:
m_tParam = 0.9;
break;
}
setLimMagnitude();
......@@ -42,49 +37,39 @@ ObsConditions::ObsConditions(int bortle, Equipment eq, double ap, EquipmentType
ObsConditions::~ObsConditions() {}
void ObsConditions::setEquipment(Equipment eq)
{
equip = eq;
}
void ObsConditions::setEquipmentType(EquipmentType t)
{
type = t;
}
void ObsConditions::setLimMagnitude()
{
switch ( bortleClass )
switch ( m_BortleClass )
{
case 1:
LM = 7.8; //Excellent dark-sky site
m_LM = 7.8; //Excellent dark-sky site
break;
case 2:
LM = 7.3; //Typical truly dark site
m_LM = 7.3; //Typical truly dark site
break;
case 3:
LM = 6.8; //Rural sky
m_LM = 6.8; //Rural sky
break;
case 4:
LM = 6.3;
m_LM = 6.3;
break;
case 5:
LM = 5.8;
m_LM = 5.8;
break;
case 6:
LM = 5.3;
m_LM = 5.3;
break;
case 7:
LM = 4.8;
m_LM = 4.8;
break;
case 8:
LM = 4.3;
m_LM = 4.3;
break;
case 9:
LM = 3.8;
m_LM = 3.8;
break;
default:
LM = 4.0;
m_LM = 4.0;
break;
}
}
......@@ -92,8 +77,8 @@ void ObsConditions::setLimMagnitude()
double ObsConditions::getOptimumMAG()
{
double power = ( 2.81 + 2.814 * LM - 0.3694 * pow( LM , 2 ) ) / 5;
return 0.1333 * aperture * sqrt(t) * pow( power , 10 );
double power = ( 2.81 + 2.814 * m_LM - 0.3694 * pow( m_LM , 2 ) ) / 5;
return 0.1333 * m_Aperture * sqrt( m_tParam ) * pow( power , 10 );
}
......@@ -113,7 +98,7 @@ double ObsConditions::getTrueMagLim()
* telescope's aperture to eye's pupil surface ratio.
*/
//kDebug() << (LM + 5*log10(aperture/7.5));
return (LM + 5*log10(aperture/7.5));
return m_LM + 5*log10(m_Aperture/7.5);
}
bool ObsConditions::isVisible(GeoLocation* geo, dms* lst, SkyObject* so)
......
......@@ -25,22 +25,22 @@ class ObsConditions
public:
enum Equipment {Telescope = 0, Binoculars, Both, None };
enum EquipmentType { Reflector = 0, Refractor };
ObsConditions(int bortleClass, Equipment eq, double aperture, EquipmentType tp);
ObsConditions(int bortle, double aperture, Equipment equip, EquipmentType eqType);
~ObsConditions();
void setEquipment(Equipment eq);
void setEquipmentType(EquipmentType t);
inline void setEquipment(Equipment equip) { m_Equip = equip; }
inline void setEquipmentType(EquipmentType eqType) { m_EqType = eqType; }
void setLimMagnitude();
double getOptimumMAG();
double getTrueMagLim();
bool isVisible(GeoLocation* geo, dms* lst, SkyObject* so);
private:
int bortleClass;
Equipment equip;
EquipmentType type;
double aperture;
double t;
double LM;
int m_BortleClass;
Equipment m_Equip;
EquipmentType m_EqType;
double m_Aperture;
double m_tParam;
double m_LM;
};
#endif
......@@ -19,10 +19,10 @@
#include "kstarsdata.h"
#include "skyobjitem.h"
SkyObjItem::SkyObjItem(SkyObject* sobj, QObject* parent) : QObject(parent),
m_Name(sobj->name()), m_TypeName(sobj->typeName())
SkyObjItem::SkyObjItem(SkyObject* so, QObject* parent) : QObject(parent),
m_Name(so->name()), m_TypeName(so->typeName()), m_So(so)
{
switch (sobj->type())
switch (so->type())
{
case SkyObject::PLANET:
m_Type = Planet;
......@@ -48,7 +48,7 @@ SkyObjItem::SkyObjItem(SkyObject* sobj, QObject* parent) : QObject(parent),
break;
}
setPosition(so=sobj);
setPosition(m_So);
}
QVariant SkyObjItem::data(int role)
......@@ -124,25 +124,5 @@ QString SkyObjItem::getDesc() const
QString SkyObjItem::getMagnitude() const
{
return QString("Magnitude : ")+(QString::number(so->mag()));
}
int SkyObjItem::getType() const
{
switch (m_Type)
{
case Planet:
return 0;
case Star:
return 1;
case Constellation:
return 2;
case Galaxy:
return 3;
case Cluster:
return 4;
case Nebula:
return 5;
}
return -1;
return QString("Magnitude : ")+(QString::number(m_So->mag()));
}
......@@ -28,24 +28,24 @@ class SkyObjItem : public QObject
public:
enum SkyObjectRoles {DispNameRole = Qt::UserRole + 1 , CategoryRole, CategoryNameRole };
enum Type {Planet, Star, Constellation, Galaxy, Cluster, Nebula};
explicit SkyObjItem( SkyObject *sobj=0, QObject *parent = 0);
explicit SkyObjItem( SkyObject *so=0, QObject *parent = 0);
QVariant data(int role);
QHash<int, QByteArray> roleNames() const;
inline QString getName() const { return m_Name; }
inline QString getTypeName() const { return m_TypeName; }
inline int getType() const { return int(m_Type); }
inline QString getPosition() const { return m_Position; }
inline SkyObject* getSkyObject() { return so; }
inline SkyObject* getSkyObject() { return m_So; }
QString getDesc() const;
QString getMagnitude() const;
void setPosition(SkyObject* so);
int getType() const;
private:
QString m_Name;
QString m_TypeName;
QString m_Position;
Type m_Type;
SkyObject* so;
SkyObject* m_So;
};
#endif // SKYOBJITEM_H
......@@ -37,14 +37,17 @@ void WIUserSettings::makeConnections()
void WIUserSettings::slotFinished( int )
{
eq = noEquipCheck->isEnabled() ? (ObsConditions::None) : (telescopeCheck->isChecked()
?(binocularsCheck->isChecked() ? ObsConditions::Both : ObsConditions::Telescope)
:(binocularsCheck->isChecked() ? ObsConditions::Binoculars : ObsConditions::None));
eq = noEquipCheck->isEnabled()
? (ObsConditions::None)
: (telescopeCheck->isChecked()
? (binocularsCheck->isChecked() ? ObsConditions::Both : ObsConditions::Telescope)
: (binocularsCheck->isChecked() ? ObsConditions::Binoculars : ObsConditions::None));
type = (equipmentType->currentText()=="Reflector") ? ObsConditions::Reflector : ObsConditions::Refractor;
kDebug()<<bortleClass->value()<<eq<<aperture->value()<<type;
WIView *wi = new WIView(0, new ObsConditions(bortleClass->value(), eq, aperture->value(), type));
WIView *wi = new WIView(0, new ObsConditions(bortleClass->value(), aperture->value(), eq, type));
}
void WIUserSettings::slotTelescopeCheck(bool on)
......
......@@ -27,24 +27,24 @@ WIView::WIView ( QObject *parent, ObsConditions *obs) : QObject(parent)
m = new ModelManager(obs);
QDeclarativeView *baseView = new QDeclarativeView();
ctxt = baseView->rootContext();
baseView->setSource(KStandardDirs::locate("appdata","tools/whatsinteresting/qml/wiview.qml") );
baseObj = dynamic_cast<QObject *> (baseView->rootObject());
baseView->setSource(KStandardDirs::locate("appdata","tools/whatsinteresting/qml/wiview.qml"));
//soTypeTextObj = baseObj->findChild<QObject *>("soTypeTextObj");
m_BaseObj = dynamic_cast<QObject *> (baseView->rootObject());
containerObj = baseObj->findChild<QObject *>("containerObj");
//soTypeTextObj = m_BaseObj->findChild<QObject *>("soTypeTextObj");
viewsRowObj = baseObj->findChild<QObject *>("viewsRowObj");
connect(viewsRowObj, SIGNAL(categorySelected(int)), this, SLOT(onCategorySelected(int)));
m_ViewsRowObj = m_BaseObj->findChild<QObject *>("viewsRowObj");
connect(m_ViewsRowObj, SIGNAL(categorySelected(int)), this, SLOT(onCategorySelected(int)));
soListObj = baseObj->findChild<QObject *>("soListObj");
connect(soListObj, SIGNAL(soListItemClicked(int, QString, int)), this, SLOT(onSoListItemClicked(int, QString, int)));
m_SoListObj = m_BaseObj->findChild<QObject *>("soListObj");
connect(m_SoListObj, SIGNAL(soListItemClicked(int, QString, int)), this, SLOT(onSoListItemClicked(int, QString, int)));
detailsViewObj = baseObj->findChild<QObject *>("detailsViewObj");
nextObj = baseObj->findChild<QObject *>("nextObj");
connect(nextObj, SIGNAL(nextObjTextClicked()), this, SLOT(onNextObjTextClicked()));
m_DetailsViewObj = m_BaseObj->findChild<QObject *>("detailsViewObj");
m_NextObj = m_BaseObj->findChild<QObject *>("nextObj");
connect(m_NextObj, SIGNAL(nextObjTextClicked()), this, SLOT(onNextObjTextClicked()));
m_OptMag = obs->getOptimumMAG();
......@@ -55,33 +55,23 @@ WIView::WIView ( QObject *parent, ObsConditions *obs) : QObject(parent)
WIView::~WIView()
{
delete m;
delete curSoItem;
delete m_CurSoItem;
}
void WIView::onCategorySelected(int type)
{
QString oMagText = QString("Suggested optimum magnification : ") + QString::number(m_OptMag);
QObject* oMagTextObj = baseObj->findChild<QObject *>("oMagTextObj");
QObject* oMagTextObj = m_BaseObj->findChild<QObject *>("oMagTextObj");
switch(type)
{
case 0:
ctxt->setContextProperty("soListModel", m->returnModel( type ));
break;
case 1:
ctxt->setContextProperty("soListModel", m->returnModel( type ));
break;
case 2:
ctxt->setContextProperty("soListModel", m->returnModel( type ));
break;
case 3:
ctxt->setContextProperty("soListModel", m->returnModel( type ));
oMagTextObj->setProperty("text", oMagText);
break;
case 4:
ctxt->setContextProperty("soListModel", m->returnModel( type ));
oMagTextObj->setProperty("text", oMagText);
break;
case 5:
ctxt->setContextProperty("soListModel", m->returnModel( type ));
oMagTextObj->setProperty("text", oMagText);
......@@ -91,30 +81,7 @@ void WIView::onCategorySelected(int type)
void WIView::onSoListItemClicked(int type, QString typeName, int index)
{
SkyObjItem *soitem;
kDebug()<<type;
switch (type)
{
case 0:
soitem = m->returnModel(type)->getSkyObjItem(index);
break;
case 1:
soitem = m->returnModel(type)->getSkyObjItem(index);
break;
case 2:
soitem = m->returnModel(type)->getSkyObjItem(index);
break;
case 3:
soitem = m->returnModel(type)->getSkyObjItem(index);
break;
case 4:
soitem = m->returnModel(type)->getSkyObjItem(index);
break;
case 5:
soitem = m->returnModel(type)->getSkyObjItem(index);
break;
}
SkyObjItem *soitem = m->returnModel(type)->getSkyObjItem(index);
kDebug()<<soitem->getName()<<soitem->getType();
// soTypeTextObj->setProperty("text", typeName);
......@@ -126,10 +93,10 @@ void WIView::onSoListItemClicked(int type, QString typeName, int index)
void WIView::loadDetailsView(SkyObjItem* soitem, int index)
{
QObject* sonameObj = detailsViewObj->findChild<QObject *>("sonameObj");
QObject* posTextObj = detailsViewObj->findChild<QObject *>("posTextObj");
QObject* descTextObj = detailsViewObj->findChild<QObject *>("descTextObj");
QObject* magTextObj = detailsViewObj->findChild<QObject *>("magTextObj");
QObject* sonameObj = m_DetailsViewObj->findChild<QObject *>("sonameObj");
QObject* posTextObj = m_DetailsViewObj->findChild<QObject *>("posTextObj");
QObject* descTextObj = m_DetailsViewObj->findChild<QObject *>("descTextObj");
QObject* magTextObj = m_DetailsViewObj->findChild<QObject *>("magTextObj");
sonameObj->setProperty("text", soitem->getName());
posTextObj->setProperty("text", soitem->getPosition());
descTextObj->setProperty("text", soitem->getDesc());
......@@ -144,13 +111,13 @@ void WIView::loadDetailsView(SkyObjItem* soitem, int index)
data->map()->setDestination( *data->map()->focusPoint() );
}
curSoItem = soitem;
m_CurSoItem = soitem;
m_CurIndex = index;
}
void WIView::onNextObjTextClicked()
{
int modelSize = m->returnModel(curSoItem->getType())->rowCount();
SkyObjItem *nextItem = m->returnModel(curSoItem->getType())->getSkyObjItem((m_CurIndex+1)%modelSize);
int modelSize = m->returnModel(m_CurSoItem->getType())->rowCount();
SkyObjItem *nextItem = m->returnModel(m_CurSoItem->getType())->getSkyObjItem((m_CurIndex+1)%modelSize);
loadDetailsView(nextItem, (m_CurIndex+1)%modelSize);
}
......@@ -17,6 +17,7 @@
#include "QtDeclarative/QDeclarativeView"
#include "QtDeclarative/QDeclarativeContext"
#include "QtDeclarative/QDeclarativeItem"
#include "QModelIndex"
#include "skyobject.h"
#include "modelmanager.h"
......@@ -36,10 +37,10 @@ public slots:
void onSoListItemClicked(int type, QString typeName, int index);
void onNextObjTextClicked();
private:
QObject *baseObj, *containerObj, *viewsRowObj, *soListObj, *detailsViewObj, *nextObj;
QObject *m_BaseObj, *m_ViewsRowObj, *m_SoListObj, *m_DetailsViewObj, *m_NextObj;
QDeclarativeContext *ctxt;
ModelManager *m;
SkyObjItem *curSoItem;
SkyObjItem *m_CurSoItem;
int m_CurIndex;
double m_OptMag;
};
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