Ocular.cpp   Ocular.cpp 
skipping to change at line 22 skipping to change at line 22
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include "Ocular.hpp" #include "Ocular.hpp"
#include "Telescope.hpp" #include "Telescope.hpp"
#include <QDebug> Ocular::Ocular()
#include <QSettings> {
}
Ocular::Ocular(QSqlRecord record) Ocular::Ocular(const QObject& other)
{ {
ocularID = record.value("id").toInt(); this->m_appearentFOV = other.property("appearentFOV").toDouble();
name = record.value("name").toString(); this->m_effectiveFocalLength = other.property("effectiveFocalLength"
appearentFOV = record.value("afov").toDouble(); ).toDouble();
effectiveFocalLength = record.value("efl").toDouble(); this->m_fieldStop = other.property("fieldStop").toDouble();
fieldStop = record.value("fieldStop").toDouble(); this->m_name = other.property("name").toString();
} }
Ocular::~Ocular() Ocular::~Ocular()
{ {
} }
static QMap<int, QString> mapping;
QMap<int, QString> Ocular::propertyMap()
{
if(mapping.isEmpty()) {
mapping = QMap<int, QString>();
mapping[0] = "name";
mapping[1] = "appearentFOV";
mapping[2] = "effectiveFocalLength";
mapping[3] = "fieldStop";
}
return mapping;
}
/* ********************************************************************* */ /* ********************************************************************* */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark Instance Methods #pragma mark Instance Methods
#endif #endif
/* ********************************************************************* */ /* ********************************************************************* */
double Ocular::getActualFOV(Telescope *telescope) double Ocular::actualFOV(Telescope *telescope) const
{ {
double actualFOV = 0.0; double actualFOV = 0.0;
if (fieldStop > 0.0) { if (fieldStop() > 0.0) {
actualFOV = fieldStop / telescope->getFocalLength() * 57.3; actualFOV = fieldStop() / telescope->focalLength() * 57.3;
} else { } else {
//actualFOV = apparent / mag //actualFOV = apparent / mag
actualFOV = appearentFOV / (telescope->getFocalLength() / ef fectiveFocalLength); actualFOV = appearentFOV() / (telescope->focalLength() / eff ectiveFocalLength());
} }
return actualFOV; return actualFOV;
} }
double Ocular::getMagnification(Telescope *telescope) double Ocular::magnification(Telescope *telescope) const
{
return telescope->getFocalLength() / effectiveFocalLength;
}
double Ocular::getExitCircle(Telescope *telescope)
{ {
return telescope->getDiameter() * effectiveFocalLength / telescope-> getFocalLength(); return telescope->focalLength() / effectiveFocalLength();
} }
/* ********************************************************************* */ /* ********************************************************************* */
#if 0 #if 0
#pragma mark - #pragma mark -
#pragma mark Accessors & Mutators #pragma mark Accessors & Mutators
#endif #endif
/* ********************************************************************* */ /* ********************************************************************* */
const QString Ocular::getName() const QString Ocular::name() const
{ {
return name; return m_name;
} }
int Ocular::getOcularID() void Ocular::setName(QString aName)
{ {
return ocularID; m_name = aName;
} }
double Ocular::getAppearentFOV() double Ocular::appearentFOV() const
{ {
return appearentFOV; return m_appearentFOV;
} }
double Ocular::getEffectiveFocalLength() void Ocular::setAppearentFOV(double fov)
{ {
return effectiveFocalLength; m_appearentFOV = fov;
}
double Ocular::effectiveFocalLength() const
{
return m_effectiveFocalLength;
}
void Ocular::setEffectiveFocalLength(double fl)
{
m_effectiveFocalLength = fl;
}
double Ocular::fieldStop() const
{
return m_fieldStop;
}
void Ocular::setFieldStop(double fs)
{
m_fieldStop = fs;
}
/* ********************************************************************* */
#if 0
#pragma mark -
#pragma mark Static Methods
#endif
/* ********************************************************************* */
Ocular* Ocular::ocularFromSettings(QSettings* theSettings, int ocularIndex)
{
Ocular* ocular = new Ocular();
QString prefix = "ocular/" + QVariant(ocularIndex).toString() + "/";
ocular->setName(theSettings->value(prefix + "name", "").toString());
ocular->setAppearentFOV(theSettings->value(prefix + "afov", "0.0").t
oDouble());
ocular->setEffectiveFocalLength(theSettings->value(prefix + "efl", "
0.0").toDouble());
ocular->setFieldStop(theSettings->value(prefix + "fieldStop", "0.0")
.toDouble());
if (!(ocular->appearentFOV() > 0.0 && ocular->effectiveFocalLength()
> 0.0)) {
qWarning() << "WARNING: Invalid data for ocular. Ocular valu
es must be positive. \n"
<< "\tafov: " << ocular->appearentFOV() << "\n"
<< "\tefl: " << ocular->effectiveFocalLength() << "\n"
<< "\tThis ocular will be ignored.";
delete ocular;
ocular = NULL;
}
return ocular;
} }
double Ocular::getFieldStop() Ocular* Ocular::ocularModel()
{ {
return fieldStop; Ocular* model = new Ocular();
model->setName("My Ocular");
model->setAppearentFOV(68);
model->setEffectiveFocalLength(32);
model->setFieldStop(0);
return model;
} }
 End of changes. 19 change blocks. 
29 lines changed or deleted 97 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/