Ocular.cpp   Ocular.cpp 
skipping to change at line 32 skipping to change at line 32
Ocular::Ocular() Ocular::Ocular()
{ {
} }
Ocular::Ocular(const QObject& other) Ocular::Ocular(const QObject& other)
{ {
this->m_appearentFOV = other.property("appearentFOV").toDouble(); this->m_appearentFOV = other.property("appearentFOV").toDouble();
this->m_effectiveFocalLength = other.property("effectiveFocalLength" ).toDouble(); this->m_effectiveFocalLength = other.property("effectiveFocalLength" ).toDouble();
this->m_fieldStop = other.property("fieldStop").toDouble(); this->m_fieldStop = other.property("fieldStop").toDouble();
this->m_name = other.property("name").toString(); this->m_name = other.property("name").toString();
this->m_binoculars = other.property("binoculars").toBool();
} }
Ocular::~Ocular() Ocular::~Ocular()
{ {
} }
static QMap<int, QString> mapping; static QMap<int, QString> mapping;
QMap<int, QString> Ocular::propertyMap() QMap<int, QString> Ocular::propertyMap()
{ {
if(mapping.isEmpty()) { if(mapping.isEmpty()) {
mapping = QMap<int, QString>(); mapping = QMap<int, QString>();
mapping[0] = "name"; mapping[0] = "name";
mapping[1] = "appearentFOV"; mapping[1] = "appearentFOV";
mapping[2] = "effectiveFocalLength"; mapping[2] = "effectiveFocalLength";
mapping[3] = "fieldStop"; mapping[3] = "fieldStop";
mapping[4] = "binoculars";
} }
return mapping; return mapping;
} }
/* ********************************************************************* */ /* ********************************************************************* */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark Instance Methods #pragma mark Instance Methods
#endif #endif
/* ********************************************************************* */ /* ********************************************************************* */
double Ocular::actualFOV(Telescope *telescope) const double Ocular::actualFOV(Telescope *telescope) const
{ {
double actualFOV = 0.0; double actualFOV = 0.0;
if (fieldStop() > 0.0) { if (m_binoculars) {
actualFOV = appearentFOV();
} else if (fieldStop() > 0.0) {
actualFOV = fieldStop() / telescope->focalLength() * 57.3; actualFOV = fieldStop() / telescope->focalLength() * 57.3;
} else { } else {
//actualFOV = apparent / mag //actualFOV = apparent / mag
actualFOV = appearentFOV() / (telescope->focalLength() / eff ectiveFocalLength()); actualFOV = appearentFOV() / (telescope->focalLength() / eff ectiveFocalLength());
} }
return actualFOV; return actualFOV;
} }
double Ocular::magnification(Telescope *telescope) const double Ocular::magnification(Telescope *telescope) const
{ {
return telescope->focalLength() / effectiveFocalLength(); double magnifiction = 0.0;
if (m_binoculars) {
magnifiction = effectiveFocalLength();
} else {
magnifiction = telescope->focalLength() / effectiveFocalLeng
th();
}
return magnifiction;
} }
/* ********************************************************************* */ /* ********************************************************************* */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark Accessors & Mutators #pragma mark Accessors & Mutators
#endif #endif
/* ********************************************************************* */ /* ********************************************************************* */
const QString Ocular::name() const const QString Ocular::name() const
{ {
skipping to change at line 120 skipping to change at line 130
double Ocular::fieldStop() const double Ocular::fieldStop() const
{ {
return m_fieldStop; return m_fieldStop;
} }
void Ocular::setFieldStop(double fs) void Ocular::setFieldStop(double fs)
{ {
m_fieldStop = fs; m_fieldStop = fs;
} }
bool Ocular::isBinoculars() const
{
return m_binoculars;
}
void Ocular::setBinoculars(bool flag)
{
m_binoculars = flag;
}
/* ********************************************************************* */ /* ********************************************************************* */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark Static Methods #pragma mark Static Methods
#endif #endif
/* ********************************************************************* */ /* ********************************************************************* */
Ocular* Ocular::ocularFromSettings(QSettings* theSettings, int ocularIndex) Ocular* Ocular::ocularFromSettings(QSettings* theSettings, int ocularIndex)
{ {
Ocular* ocular = new Ocular(); Ocular* ocular = new Ocular();
QString prefix = "ocular/" + QVariant(ocularIndex).toString() + "/"; QString prefix = "ocular/" + QVariant(ocularIndex).toString() + "/";
ocular->setName(theSettings->value(prefix + "name", "").toString()); ocular->setName(theSettings->value(prefix + "name", "").toString());
ocular->setAppearentFOV(theSettings->value(prefix + "afov", "0.0").t oDouble()); ocular->setAppearentFOV(theSettings->value(prefix + "afov", "0.0").t oDouble());
ocular->setEffectiveFocalLength(theSettings->value(prefix + "efl", " 0.0").toDouble()); ocular->setEffectiveFocalLength(theSettings->value(prefix + "efl", " 0.0").toDouble());
ocular->setFieldStop(theSettings->value(prefix + "fieldStop", "0.0") .toDouble()); ocular->setFieldStop(theSettings->value(prefix + "fieldStop", "0.0") .toDouble());
ocular->setBinoculars(theSettings->value(prefix + "binoculars", "fal se").toBool());
if (!(ocular->appearentFOV() > 0.0 && ocular->effectiveFocalLength() > 0.0)) { if (!(ocular->appearentFOV() > 0.0 && ocular->effectiveFocalLength() > 0.0)) {
qWarning() << "WARNING: Invalid data for ocular. Ocular valu es must be positive. \n" qWarning() << "WARNING: Invalid data for ocular. Ocular valu es must be positive. \n"
<< "\tafov: " << ocular->appearentFOV() << "\n" << "\tafov: " << ocular->appearentFOV() << "\n"
<< "\tefl: " << ocular->effectiveFocalLength() << "\n" << "\tefl: " << ocular->effectiveFocalLength() << "\n"
<< "\tThis ocular will be ignored."; << "\tThis ocular will be ignored.";
delete ocular; delete ocular;
ocular = NULL; ocular = NULL;
} }
return ocular; return ocular;
} }
Ocular* Ocular::ocularModel() Ocular* Ocular::ocularModel()
{ {
Ocular* model = new Ocular(); Ocular* model = new Ocular();
model->setName("My Ocular"); model->setName("My Ocular");
model->setAppearentFOV(68); model->setAppearentFOV(68);
model->setEffectiveFocalLength(32); model->setEffectiveFocalLength(32);
model->setFieldStop(0); model->setFieldStop(0);
model->setBinoculars(false);
return model; return model;
} }
 End of changes. 7 change blocks. 
2 lines changed or deleted 25 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/